1f7a81aae7
* update deps
* node16
* wip
* wip
* wip
* Update test-utils.ts
* wip
* Update tsconfig.json
* wip
* Update package.json
* wip
* Update following.vue
* Update followers.vue
* Update index.vue
* Update share.vue
* Update MkUserPopup.vue
* Update MkPostForm.vue
* wip
* Update MkTokenGenerateWindow.vue
* Update MkPagination.vue
* refactor
* update deps
* update deps
* Update sw.ts
* wip
* wip
* wip
* Update FetchInstanceMetadataService.ts
* Update FetchInstanceMetadataService.ts
* update node
* update deps
* 🎨
61 lines
1.2 KiB
TypeScript
61 lines
1.2 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import * as Misskey from 'misskey-js';
|
|
import { i18n } from '@/i18n';
|
|
|
|
/**
|
|
* 投稿を表す文字列を取得します。
|
|
* @param {*} note (packされた)投稿
|
|
*/
|
|
export const getNoteSummary = (note: Misskey.entities.Note): string => {
|
|
if (note.deletedAt) {
|
|
return `(${i18n.ts.deletedNote})`;
|
|
}
|
|
|
|
if (note.isHidden) {
|
|
return `(${i18n.ts.invisibleNote})`;
|
|
}
|
|
|
|
let summary = '';
|
|
|
|
// 本文
|
|
if (note.cw != null) {
|
|
summary += note.cw;
|
|
} else {
|
|
summary += note.text ? note.text : '';
|
|
}
|
|
|
|
// ファイルが添付されているとき
|
|
if ((note.files || []).length !== 0) {
|
|
summary += ` (${i18n.t('withNFiles', { n: note.files.length })})`;
|
|
}
|
|
|
|
// 投票が添付されているとき
|
|
if (note.poll) {
|
|
summary += ` (${i18n.ts.poll})`;
|
|
}
|
|
|
|
// 返信のとき
|
|
if (note.replyId) {
|
|
if (note.reply) {
|
|
summary += `\n\nRE: ${getNoteSummary(note.reply)}`;
|
|
} else {
|
|
summary += '\n\nRE: ...';
|
|
}
|
|
}
|
|
|
|
// Renoteのとき
|
|
if (note.renoteId) {
|
|
if (note.renote) {
|
|
summary += `\n\nRN: ${getNoteSummary(note.renote)}`;
|
|
} else {
|
|
summary += '\n\nRN: ...';
|
|
}
|
|
}
|
|
|
|
return summary.trim();
|
|
};
|