From 4b94997e63eda9ddb292f32c082c8e908c6be523 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:32:35 +0900 Subject: [PATCH 01/10] =?UTF-8?q?fix(frontend):=20=E3=83=AA=E3=83=8E?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=AE=E5=88=A4=E5=AE=9A=E3=81=8C=E7=94=98?= =?UTF-8?q?=E3=81=84=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkNote.vue | 16 ++----- .../src/components/MkNoteDetailed.vue | 14 ++---- .../frontend/src/scripts/get-note-menu.ts | 43 ++++--------------- packages/frontend/src/scripts/note.ts | 29 +++++++++++++ 4 files changed, 44 insertions(+), 58 deletions(-) create mode 100644 packages/frontend/src/scripts/note.ts diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 13273a53b4a1..f63a88418ccc 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.pinnedNote }}
-
+
@@ -200,6 +200,7 @@ import { host } from '@/config.js'; import { isEnabledUrlPreview } from '@/instance.js'; import { type Keymap } from '@/scripts/hotkey.js'; import { focusPrev, focusNext } from '@/scripts/focus.js'; +import { isRenote, getAppearNote } from '@/scripts/note.js'; const props = withDefaults(defineProps<{ note: Misskey.entities.Note; @@ -242,22 +243,13 @@ if (noteViewInterruptors.length > 0) { }); } -const isRenote = ( - note.value.renote != null && - note.value.reply == null && - note.value.text == null && - note.value.cw == null && - note.value.fileIds && note.value.fileIds.length === 0 && - note.value.poll == null -); - const rootEl = shallowRef(); const menuButton = shallowRef(); const renoteButton = shallowRef(); const renoteTime = shallowRef(); const reactButton = shallowRef(); const clipButton = shallowRef(); -const appearNote = computed(() => isRenote ? note.value.renote as Misskey.entities.Note : note.value); +const appearNote = computed(() => getAppearNote(note.value)); const galleryEl = shallowRef>(); const isMyRenote = $i && ($i.id === note.value.userId); const showContent = ref(false); @@ -273,7 +265,7 @@ const translating = ref(false); const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.value.user.instance); const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || (appearNote.value.visibility === 'followers' && appearNote.value.userId === $i?.id)); const renoteCollapsed = ref( - defaultStore.state.collapseRenotes && isRenote && ( + defaultStore.state.collapseRenotes && isRenote(props.note) && ( ($i && ($i.id === note.value.userId || $i.id === appearNote.value.userId)) || // `||` must be `||`! See https://github.com/misskey-dev/misskey/issues/13131 (appearNote.value.myReaction != null) ), diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 9a3e595789c7..8b7a025b6b15 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -235,6 +235,7 @@ import MkPagination, { type Paging } from '@/components/MkPagination.vue'; import MkReactionIcon from '@/components/MkReactionIcon.vue'; import MkButton from '@/components/MkButton.vue'; import { isEnabledUrlPreview } from '@/instance.js'; +import { isRenote, getAppearNote } from '@/scripts/note.js'; import { type Keymap } from '@/scripts/hotkey.js'; const props = withDefaults(defineProps<{ @@ -267,22 +268,13 @@ if (noteViewInterruptors.length > 0) { }); } -const isRenote = ( - note.value.renote != null && - note.value.reply == null && - note.value.text == null && - note.value.cw == null && - note.value.fileIds && note.value.fileIds.length === 0 && - note.value.poll == null -); - const rootEl = shallowRef(); const menuButton = shallowRef(); const renoteButton = shallowRef(); const renoteTime = shallowRef(); const reactButton = shallowRef(); const clipButton = shallowRef(); -const appearNote = computed(() => isRenote ? note.value.renote as Misskey.entities.Note : note.value); +const appearNote = computed(() => getAppearNote(note.value)); const galleryEl = shallowRef>(); const isMyRenote = $i && ($i.id === note.value.userId); const showContent = ref(false); diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index ebb96d1746bb..e9fe7db19ce3 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -20,6 +20,7 @@ import { clipsCache, favoritedChannelsCache } from '@/cache.js'; import { MenuItem } from '@/types/menu.js'; import MkRippleEffect from '@/components/MkRippleEffect.vue'; import { isSupportShare } from '@/scripts/navigator.js'; +import { smallerVisibility, getAppearNote } from '@/scripts/note.js'; export async function getNoteClipMenu(props: { note: Misskey.entities.Note; @@ -34,14 +35,7 @@ export async function getNoteClipMenu(props: { } } - const isRenote = ( - props.note.renote != null && - props.note.text == null && - props.note.fileIds.length === 0 && - props.note.poll == null - ); - - const appearNote = isRenote ? props.note.renote as Misskey.entities.Note : props.note; + const appearNote = getAppearNote(props.note); const clips = await clipsCache.fetch(); const menu: MenuItem[] = [...clips.map(clip => ({ @@ -164,14 +158,8 @@ export function getNoteMenu(props: { isDeleted: Ref; currentClip?: Misskey.entities.Clip; }) { - const isRenote = ( - props.note.renote != null && - props.note.text == null && - props.note.fileIds.length === 0 && - props.note.poll == null - ); - const appearNote = isRenote ? props.note.renote as Misskey.entities.Note : props.note; + const appearNote = getAppearNote(props.note); const cleanups = [] as (() => void)[]; @@ -248,6 +236,7 @@ export function getNoteMenu(props: { } async function unclip(): Promise { + if (!props.currentClip) return; os.apiWithDialog('clips/remove-note', { clipId: props.currentClip.id, noteId: appearNote.id }); props.isDeleted.value = true; } @@ -267,8 +256,8 @@ export function getNoteMenu(props: { function share(): void { navigator.share({ - title: i18n.tsx.noteOf({ user: appearNote.user.name }), - text: appearNote.text, + title: i18n.tsx.noteOf({ user: appearNote.user.name ?? appearNote.user.username }), + text: appearNote.text ?? '', url: `${url}/notes/${appearNote.id}`, }); } @@ -494,29 +483,13 @@ export function getNoteMenu(props: { }; } -type Visibility = (typeof Misskey.noteVisibilities)[number]; - -function smallerVisibility(a: Visibility, b: Visibility): Visibility { - if (a === 'specified' || b === 'specified') return 'specified'; - if (a === 'followers' || b === 'followers') return 'followers'; - if (a === 'home' || b === 'home') return 'home'; - // if (a === 'public' || b === 'public') - return 'public'; -} - export function getRenoteMenu(props: { note: Misskey.entities.Note; renoteButton: ShallowRef; mock?: boolean; }) { - const isRenote = ( - props.note.renote != null && - props.note.text == null && - props.note.fileIds.length === 0 && - props.note.poll == null - ); - - const appearNote = isRenote ? props.note.renote as Misskey.entities.Note : props.note; + + const appearNote = getAppearNote(props.note); const channelRenoteItems: MenuItem[] = []; const normalRenoteItems: MenuItem[] = []; diff --git a/packages/frontend/src/scripts/note.ts b/packages/frontend/src/scripts/note.ts new file mode 100644 index 000000000000..82821f77d4f3 --- /dev/null +++ b/packages/frontend/src/scripts/note.ts @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import * as Misskey from 'misskey-js'; + +export function isRenote(note: Misskey.entities.Note): boolean { + return ( + note.renote != null && + (note.cw == null && note.text == null) && + note.fileIds?.length === 0 && + note.poll == null + ); +} + +export function getAppearNote(note: Misskey.entities.Note): Misskey.entities.Note { + return isRenote(note) ? note.renote! : note; +} + +type Visibility = (typeof Misskey.noteVisibilities)[number]; + +export function smallerVisibility(a: Visibility, b: Visibility): Visibility { + if (a === 'specified' || b === 'specified') return 'specified'; + if (a === 'followers' || b === 'followers') return 'followers'; + if (a === 'home' || b === 'home') return 'home'; + // if (a === 'public' || b === 'public') + return 'public'; +} From d8fe61fd1aada8f05f1e996483b676ed9789f7b6 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:34:59 +0900 Subject: [PATCH 02/10] fix --- packages/frontend/src/scripts/note.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/scripts/note.ts b/packages/frontend/src/scripts/note.ts index 82821f77d4f3..532b2a7b5cbd 100644 --- a/packages/frontend/src/scripts/note.ts +++ b/packages/frontend/src/scripts/note.ts @@ -8,8 +8,10 @@ import * as Misskey from 'misskey-js'; export function isRenote(note: Misskey.entities.Note): boolean { return ( note.renote != null && - (note.cw == null && note.text == null) && - note.fileIds?.length === 0 && + note.reply == null && + note.text == null && + note.cw == null && + (note.fileIds == null || note.fileIds.length === 0) && note.poll == null ); } From a485b8291cc96b99fd5e78e3b6824813e6be5b1b Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:41:52 +0900 Subject: [PATCH 03/10] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89c90bb6633e..01c416ec66d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Fix: ページ遷移に失敗することがある問題を修正 - Fix: iOSでユーザー名などがリンクとして誤検知される現象を抑制 - Fix: mCaptchaを使用していてもbotプロテクションに関する警告が消えないのを修正 +- Fix: 特定の条件下でノートの削除ボタンが出ないのを修正 ### Server - Fix: WSの`readAllNotifications` メッセージが `body` を持たない場合に動作しない問題 #14374 From 88ec6567ca0ddbb2a2e13437171ba398ca9e9337 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:45:28 +0900 Subject: [PATCH 04/10] fix --- packages/frontend/src/scripts/get-note-menu.ts | 12 +++++++++++- packages/frontend/src/scripts/note.ts | 10 ---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index e9fe7db19ce3..dfd5137d3c5b 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -20,7 +20,7 @@ import { clipsCache, favoritedChannelsCache } from '@/cache.js'; import { MenuItem } from '@/types/menu.js'; import MkRippleEffect from '@/components/MkRippleEffect.vue'; import { isSupportShare } from '@/scripts/navigator.js'; -import { smallerVisibility, getAppearNote } from '@/scripts/note.js'; +import { getAppearNote } from '@/scripts/note.js'; export async function getNoteClipMenu(props: { note: Misskey.entities.Note; @@ -483,6 +483,16 @@ export function getNoteMenu(props: { }; } +type Visibility = (typeof Misskey.noteVisibilities)[number]; + +function smallerVisibility(a: Visibility, b: Visibility): Visibility { + if (a === 'specified' || b === 'specified') return 'specified'; + if (a === 'followers' || b === 'followers') return 'followers'; + if (a === 'home' || b === 'home') return 'home'; + // if (a === 'public' || b === 'public') + return 'public'; +} + export function getRenoteMenu(props: { note: Misskey.entities.Note; renoteButton: ShallowRef; diff --git a/packages/frontend/src/scripts/note.ts b/packages/frontend/src/scripts/note.ts index 532b2a7b5cbd..fe0d9f7a546d 100644 --- a/packages/frontend/src/scripts/note.ts +++ b/packages/frontend/src/scripts/note.ts @@ -19,13 +19,3 @@ export function isRenote(note: Misskey.entities.Note): boolean { export function getAppearNote(note: Misskey.entities.Note): Misskey.entities.Note { return isRenote(note) ? note.renote! : note; } - -type Visibility = (typeof Misskey.noteVisibilities)[number]; - -export function smallerVisibility(a: Visibility, b: Visibility): Visibility { - if (a === 'specified' || b === 'specified') return 'specified'; - if (a === 'followers' || b === 'followers') return 'followers'; - if (a === 'home' || b === 'home') return 'home'; - // if (a === 'public' || b === 'public') - return 'public'; -} From 5315ff46975bce2a5c62f6458f44a1ef09c99af3 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:51:34 +0900 Subject: [PATCH 05/10] use type assertion --- packages/frontend/src/scripts/note.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/scripts/note.ts b/packages/frontend/src/scripts/note.ts index fe0d9f7a546d..ae9d7a7acfd3 100644 --- a/packages/frontend/src/scripts/note.ts +++ b/packages/frontend/src/scripts/note.ts @@ -5,7 +5,12 @@ import * as Misskey from 'misskey-js'; -export function isRenote(note: Misskey.entities.Note): boolean { +type NonNullableRecord = { + [P in keyof T]-?: NonNullable; +}; +type NoteWithRenote = Omit & NonNullableRecord>; + +export function isRenote(note: Misskey.entities.Note): note is NoteWithRenote { return ( note.renote != null && note.reply == null && @@ -16,6 +21,6 @@ export function isRenote(note: Misskey.entities.Note): boolean { ); } -export function getAppearNote(note: Misskey.entities.Note): Misskey.entities.Note { - return isRenote(note) ? note.renote! : note; +export function getAppearNote(note: Misskey.entities.Note) { + return isRenote(note) ? note.renote : note; } From 1d3ca2e3e0bcc79326561fe0c777c1d38ee04303 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:03:42 +0900 Subject: [PATCH 06/10] fix + add comments --- packages/frontend/src/scripts/note.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/scripts/note.ts b/packages/frontend/src/scripts/note.ts index ae9d7a7acfd3..01f3614f6dc8 100644 --- a/packages/frontend/src/scripts/note.ts +++ b/packages/frontend/src/scripts/note.ts @@ -8,9 +8,18 @@ import * as Misskey from 'misskey-js'; type NonNullableRecord = { [P in keyof T]-?: NonNullable; }; -type NoteWithRenote = Omit & NonNullableRecord>; +type AllNullRecord = { + [P in keyof T]: null; +}; +type Renote = + Omit + & AllNullRecord> + & { files: []; fileIds: []; } + & NonNullableRecord>; + +// TODO: misskey-jsに移す -export function isRenote(note: Misskey.entities.Note): note is NoteWithRenote { +export function isRenote(note: Misskey.entities.Note): note is Renote { return ( note.renote != null && note.reply == null && From 8fbf13046e245e77991a23098a902edd9971a3d3 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:04:34 +0900 Subject: [PATCH 07/10] lint --- packages/frontend/src/scripts/get-note-menu.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index dfd5137d3c5b..00c5fbec2eba 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -158,7 +158,6 @@ export function getNoteMenu(props: { isDeleted: Ref; currentClip?: Misskey.entities.Clip; }) { - const appearNote = getAppearNote(props.note); const cleanups = [] as (() => void)[]; @@ -498,7 +497,6 @@ export function getRenoteMenu(props: { renoteButton: ShallowRef; mock?: boolean; }) { - const appearNote = getAppearNote(props.note); const channelRenoteItems: MenuItem[] = []; From a99dff14fda96711dbe579f1211f2c774532cd33 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:19:25 +0900 Subject: [PATCH 08/10] =?UTF-8?q?misskey-js=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkNote.vue | 8 +++-- .../src/components/MkNoteDetailed.vue | 6 ++-- .../frontend/src/scripts/get-appear-note.ts | 10 ++++++ .../frontend/src/scripts/get-note-menu.ts | 2 +- packages/frontend/src/scripts/note.ts | 35 ------------------- packages/misskey-js/etc/misskey-js.api.md | 22 +++++++++++- packages/misskey-js/src/entities.ts | 14 ++++++++ packages/misskey-js/src/index.ts | 3 +- packages/misskey-js/src/note.ts | 12 +++++++ 9 files changed, 69 insertions(+), 43 deletions(-) create mode 100644 packages/frontend/src/scripts/get-appear-note.ts delete mode 100644 packages/frontend/src/scripts/note.ts create mode 100644 packages/misskey-js/src/note.ts diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index f63a88418ccc..32d1cc5640ff 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.pinnedNote }}
-
+
@@ -200,7 +200,7 @@ import { host } from '@/config.js'; import { isEnabledUrlPreview } from '@/instance.js'; import { type Keymap } from '@/scripts/hotkey.js'; import { focusPrev, focusNext } from '@/scripts/focus.js'; -import { isRenote, getAppearNote } from '@/scripts/note.js'; +import { getAppearNote } from '@/scripts/get-appear-note.js'; const props = withDefaults(defineProps<{ note: Misskey.entities.Note; @@ -243,6 +243,8 @@ if (noteViewInterruptors.length > 0) { }); } +const isRenote = Misskey.note.isPureRenote(note.value); + const rootEl = shallowRef(); const menuButton = shallowRef(); const renoteButton = shallowRef(); @@ -265,7 +267,7 @@ const translating = ref(false); const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.value.user.instance); const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || (appearNote.value.visibility === 'followers' && appearNote.value.userId === $i?.id)); const renoteCollapsed = ref( - defaultStore.state.collapseRenotes && isRenote(props.note) && ( + defaultStore.state.collapseRenotes && isRenote && ( ($i && ($i.id === note.value.userId || $i.id === appearNote.value.userId)) || // `||` must be `||`! See https://github.com/misskey-dev/misskey/issues/13131 (appearNote.value.myReaction != null) ), diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 8b7a025b6b15..2b7d2afa0493 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -235,7 +235,7 @@ import MkPagination, { type Paging } from '@/components/MkPagination.vue'; import MkReactionIcon from '@/components/MkReactionIcon.vue'; import MkButton from '@/components/MkButton.vue'; import { isEnabledUrlPreview } from '@/instance.js'; -import { isRenote, getAppearNote } from '@/scripts/note.js'; +import { getAppearNote } from '@/scripts/get-appear-note.js'; import { type Keymap } from '@/scripts/hotkey.js'; const props = withDefaults(defineProps<{ @@ -268,6 +268,8 @@ if (noteViewInterruptors.length > 0) { }); } +const isRenote = Misskey.note.isPureRenote(note.value); + const rootEl = shallowRef(); const menuButton = shallowRef(); const renoteButton = shallowRef(); diff --git a/packages/frontend/src/scripts/get-appear-note.ts b/packages/frontend/src/scripts/get-appear-note.ts new file mode 100644 index 000000000000..40ce80eac9fc --- /dev/null +++ b/packages/frontend/src/scripts/get-appear-note.ts @@ -0,0 +1,10 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import * as Misskey from 'misskey-js'; + +export function getAppearNote(note: Misskey.entities.Note) { + return Misskey.note.isPureRenote(note) ? note.renote : note; +} diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 00c5fbec2eba..2563b0baf308 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -20,7 +20,7 @@ import { clipsCache, favoritedChannelsCache } from '@/cache.js'; import { MenuItem } from '@/types/menu.js'; import MkRippleEffect from '@/components/MkRippleEffect.vue'; import { isSupportShare } from '@/scripts/navigator.js'; -import { getAppearNote } from '@/scripts/note.js'; +import { getAppearNote } from '@/scripts/get-appear-note.js'; export async function getNoteClipMenu(props: { note: Misskey.entities.Note; diff --git a/packages/frontend/src/scripts/note.ts b/packages/frontend/src/scripts/note.ts deleted file mode 100644 index 01f3614f6dc8..000000000000 --- a/packages/frontend/src/scripts/note.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and misskey-project - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import * as Misskey from 'misskey-js'; - -type NonNullableRecord = { - [P in keyof T]-?: NonNullable; -}; -type AllNullRecord = { - [P in keyof T]: null; -}; -type Renote = - Omit - & AllNullRecord> - & { files: []; fileIds: []; } - & NonNullableRecord>; - -// TODO: misskey-jsに移す - -export function isRenote(note: Misskey.entities.Note): note is Renote { - return ( - note.renote != null && - note.reply == null && - note.text == null && - note.cw == null && - (note.fileIds == null || note.fileIds.length === 0) && - note.poll == null - ); -} - -export function getAppearNote(note: Misskey.entities.Note) { - return isRenote(note) ? note.renote : note; -} diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 16cb560a52c0..9918e74e55a1 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -1172,6 +1172,7 @@ declare namespace entities { export { ID, DateString, + PureRenote, PageEvent, ModerationLog, ServerStats, @@ -2277,6 +2278,9 @@ type ISigninHistoryRequest = operations['i___signin-history']['requestBody']['co // @public (undocumented) type ISigninHistoryResponse = operations['i___signin-history']['responses']['200']['content']['application/json']; +// @public (undocumented) +function isPureRenote(note: Note): note is PureRenote; + // @public (undocumented) type IUnpinRequest = operations['i___unpin']['requestBody']['content']['application/json']; @@ -2510,6 +2514,13 @@ type MyAppsResponse = operations['my___apps']['responses']['200']['content']['ap // @public (undocumented) type Note = components['schemas']['Note']; +declare namespace note { + export { + isPureRenote + } +} +export { note } + // @public (undocumented) type NoteFavorite = components['schemas']['NoteFavorite']; @@ -2750,6 +2761,15 @@ type PinnedUsersResponse = operations['pinned-users']['responses']['200']['conte // @public (undocumented) type PromoReadRequest = operations['promo___read']['requestBody']['content']['application/json']; +// Warning: (ae-forgotten-export) The symbol "AllNullRecord" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "NonNullableRecord" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type PureRenote = Omit & AllNullRecord> & { + files: []; + fileIds: []; +} & NonNullableRecord>; + // @public (undocumented) type QueueCount = components['schemas']['QueueCount']; @@ -3226,7 +3246,7 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody'][' // Warnings were encountered during analysis: // -// src/entities.ts:35:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts +// src/entities.ts:49:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index ce58fb29709a..3b0ff5bbfab9 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -3,6 +3,7 @@ import { Announcement, EmojiDetailed, MeDetailed, + Note, Page, Role, RolePolicies, @@ -16,6 +17,19 @@ export * from './autogen/models.js'; export type ID = string; export type DateString = string; +type NonNullableRecord = { + [P in keyof T]-?: NonNullable; +}; +type AllNullRecord = { + [P in keyof T]: null; +}; + +export type PureRenote = + Omit + & AllNullRecord> + & { files: []; fileIds: []; } + & NonNullableRecord>; + export type PageEvent = { pageId: Page['id']; event: string; diff --git a/packages/misskey-js/src/index.ts b/packages/misskey-js/src/index.ts index 28007a8ade3c..c3b8f6af4216 100644 --- a/packages/misskey-js/src/index.ts +++ b/packages/misskey-js/src/index.ts @@ -29,4 +29,5 @@ export const moderationLogTypes = consts.moderationLogTypes; import * as api from './api.js'; import * as entities from './entities.js'; import * as acct from './acct.js'; -export { api, entities, acct }; +import * as note from './note.js'; +export { api, entities, acct, note }; diff --git a/packages/misskey-js/src/note.ts b/packages/misskey-js/src/note.ts new file mode 100644 index 000000000000..5c8298c7e4f5 --- /dev/null +++ b/packages/misskey-js/src/note.ts @@ -0,0 +1,12 @@ +import type { Note, PureRenote } from './entities.js'; + +export function isPureRenote(note: Note): note is PureRenote { + return ( + note.renote != null && + note.reply == null && + note.text == null && + note.cw == null && + (note.fileIds == null || note.fileIds.length === 0) && + note.poll == null + ); +} From baf2b3ecd671026189703e9b0939a5c45a368168 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 12 Aug 2024 22:56:01 +0900 Subject: [PATCH 09/10] PureRenote -> Renote --- packages/frontend/src/components/MkNote.vue | 2 +- .../src/components/MkNoteDetailed.vue | 2 +- .../frontend/src/scripts/get-appear-note.ts | 2 +- packages/misskey-js/etc/misskey-js.api.md | 24 +++++++++---------- packages/misskey-js/src/entities.ts | 2 +- packages/misskey-js/src/note.ts | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 32d1cc5640ff..141e10ed4426 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -243,7 +243,7 @@ if (noteViewInterruptors.length > 0) { }); } -const isRenote = Misskey.note.isPureRenote(note.value); +const isRenote = Misskey.note.isRenote(note.value); const rootEl = shallowRef(); const menuButton = shallowRef(); diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 2b7d2afa0493..13afa2a189e5 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -268,7 +268,7 @@ if (noteViewInterruptors.length > 0) { }); } -const isRenote = Misskey.note.isPureRenote(note.value); +const isRenote = Misskey.note.isRenote(note.value); const rootEl = shallowRef(); const menuButton = shallowRef(); diff --git a/packages/frontend/src/scripts/get-appear-note.ts b/packages/frontend/src/scripts/get-appear-note.ts index 40ce80eac9fc..7df48c1f77df 100644 --- a/packages/frontend/src/scripts/get-appear-note.ts +++ b/packages/frontend/src/scripts/get-appear-note.ts @@ -6,5 +6,5 @@ import * as Misskey from 'misskey-js'; export function getAppearNote(note: Misskey.entities.Note) { - return Misskey.note.isPureRenote(note) ? note.renote : note; + return Misskey.note.isRenote(note) ? note.renote : note; } diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 9918e74e55a1..f197f50bbd0d 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -1172,7 +1172,7 @@ declare namespace entities { export { ID, DateString, - PureRenote, + Renote, PageEvent, ModerationLog, ServerStats, @@ -2279,7 +2279,7 @@ type ISigninHistoryRequest = operations['i___signin-history']['requestBody']['co type ISigninHistoryResponse = operations['i___signin-history']['responses']['200']['content']['application/json']; // @public (undocumented) -function isPureRenote(note: Note): note is PureRenote; +function isRenote(note: Note): note is Renote; // @public (undocumented) type IUnpinRequest = operations['i___unpin']['requestBody']['content']['application/json']; @@ -2516,7 +2516,7 @@ type Note = components['schemas']['Note']; declare namespace note { export { - isPureRenote + isRenote } } export { note } @@ -2761,15 +2761,6 @@ type PinnedUsersResponse = operations['pinned-users']['responses']['200']['conte // @public (undocumented) type PromoReadRequest = operations['promo___read']['requestBody']['content']['application/json']; -// Warning: (ae-forgotten-export) The symbol "AllNullRecord" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "NonNullableRecord" needs to be exported by the entry point index.d.ts -// -// @public (undocumented) -type PureRenote = Omit & AllNullRecord> & { - files: []; - fileIds: []; -} & NonNullableRecord>; - // @public (undocumented) type QueueCount = components['schemas']['QueueCount']; @@ -2792,6 +2783,15 @@ type QueueStats = { // @public (undocumented) type QueueStatsLog = QueueStats[]; +// Warning: (ae-forgotten-export) The symbol "AllNullRecord" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "NonNullableRecord" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type Renote = Omit & AllNullRecord> & { + files: []; + fileIds: []; +} & NonNullableRecord>; + // @public (undocumented) type RenoteMuteCreateRequest = operations['renote-mute___create']['requestBody']['content']['application/json']; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 3b0ff5bbfab9..1e24e9ce656f 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -24,7 +24,7 @@ type AllNullRecord = { [P in keyof T]: null; }; -export type PureRenote = +export type Renote = Omit & AllNullRecord> & { files: []; fileIds: []; } diff --git a/packages/misskey-js/src/note.ts b/packages/misskey-js/src/note.ts index 5c8298c7e4f5..51cd1c2a22d7 100644 --- a/packages/misskey-js/src/note.ts +++ b/packages/misskey-js/src/note.ts @@ -1,6 +1,6 @@ -import type { Note, PureRenote } from './entities.js'; +import type { Note, Renote } from './entities.js'; -export function isPureRenote(note: Note): note is PureRenote { +export function isRenote(note: Note): note is Renote { return ( note.renote != null && note.reply == null && From 189295e8a5b4543d6aff30991946f4eb78e4921e Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:19:52 +0900 Subject: [PATCH 10/10] isRenote -> isPureRenote --- packages/frontend/src/components/MkNote.vue | 2 +- .../src/components/MkNoteDetailed.vue | 2 +- .../frontend/src/scripts/get-appear-note.ts | 2 +- packages/misskey-js/etc/misskey-js.api.md | 24 +++++++++---------- packages/misskey-js/src/entities.ts | 2 +- packages/misskey-js/src/note.ts | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 141e10ed4426..32d1cc5640ff 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -243,7 +243,7 @@ if (noteViewInterruptors.length > 0) { }); } -const isRenote = Misskey.note.isRenote(note.value); +const isRenote = Misskey.note.isPureRenote(note.value); const rootEl = shallowRef(); const menuButton = shallowRef(); diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 13afa2a189e5..2b7d2afa0493 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -268,7 +268,7 @@ if (noteViewInterruptors.length > 0) { }); } -const isRenote = Misskey.note.isRenote(note.value); +const isRenote = Misskey.note.isPureRenote(note.value); const rootEl = shallowRef(); const menuButton = shallowRef(); diff --git a/packages/frontend/src/scripts/get-appear-note.ts b/packages/frontend/src/scripts/get-appear-note.ts index 7df48c1f77df..40ce80eac9fc 100644 --- a/packages/frontend/src/scripts/get-appear-note.ts +++ b/packages/frontend/src/scripts/get-appear-note.ts @@ -6,5 +6,5 @@ import * as Misskey from 'misskey-js'; export function getAppearNote(note: Misskey.entities.Note) { - return Misskey.note.isRenote(note) ? note.renote : note; + return Misskey.note.isPureRenote(note) ? note.renote : note; } diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 97a6684d344c..e3943dd3a021 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -1172,7 +1172,7 @@ declare namespace entities { export { ID, DateString, - Renote, + PureRenote, PageEvent, ModerationLog, ServerStats, @@ -2279,7 +2279,7 @@ type ISigninHistoryRequest = operations['i___signin-history']['requestBody']['co type ISigninHistoryResponse = operations['i___signin-history']['responses']['200']['content']['application/json']; // @public (undocumented) -function isRenote(note: Note): note is Renote; +function isPureRenote(note: Note): note is PureRenote; // @public (undocumented) type IUnpinRequest = operations['i___unpin']['requestBody']['content']['application/json']; @@ -2516,7 +2516,7 @@ type Note = components['schemas']['Note']; declare namespace note { export { - isRenote + isPureRenote } } export { note } @@ -2761,6 +2761,15 @@ type PinnedUsersResponse = operations['pinned-users']['responses']['200']['conte // @public (undocumented) type PromoReadRequest = operations['promo___read']['requestBody']['content']['application/json']; +// Warning: (ae-forgotten-export) The symbol "AllNullRecord" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "NonNullableRecord" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type PureRenote = Omit & AllNullRecord> & { + files: []; + fileIds: []; +} & NonNullableRecord>; + // @public (undocumented) type QueueCount = components['schemas']['QueueCount']; @@ -2783,15 +2792,6 @@ type QueueStats = { // @public (undocumented) type QueueStatsLog = QueueStats[]; -// Warning: (ae-forgotten-export) The symbol "AllNullRecord" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "NonNullableRecord" needs to be exported by the entry point index.d.ts -// -// @public (undocumented) -type Renote = Omit & AllNullRecord> & { - files: []; - fileIds: []; -} & NonNullableRecord>; - // @public (undocumented) type RenoteMuteCreateRequest = operations['renote-mute___create']['requestBody']['content']['application/json']; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 1e24e9ce656f..3b0ff5bbfab9 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -24,7 +24,7 @@ type AllNullRecord = { [P in keyof T]: null; }; -export type Renote = +export type PureRenote = Omit & AllNullRecord> & { files: []; fileIds: []; } diff --git a/packages/misskey-js/src/note.ts b/packages/misskey-js/src/note.ts index 51cd1c2a22d7..5c8298c7e4f5 100644 --- a/packages/misskey-js/src/note.ts +++ b/packages/misskey-js/src/note.ts @@ -1,6 +1,6 @@ -import type { Note, Renote } from './entities.js'; +import type { Note, PureRenote } from './entities.js'; -export function isRenote(note: Note): note is Renote { +export function isPureRenote(note: Note): note is PureRenote { return ( note.renote != null && note.reply == null &&