From c4fdf5a47c34ef47862a9abe4f8c7c10c961c950 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sun, 6 Jul 2025 20:47:31 +0900 Subject: [PATCH] chore(frontend): fix type errors --- packages/frontend/src/types/post-form.ts | 6 ++-- .../frontend/src/utility/get-note-menu.ts | 29 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/frontend/src/types/post-form.ts b/packages/frontend/src/types/post-form.ts index 5bb04a95a0..10e68d2d4a 100644 --- a/packages/frontend/src/types/post-form.ts +++ b/packages/frontend/src/types/post-form.ts @@ -6,9 +6,9 @@ import * as Misskey from 'misskey-js'; export interface PostFormProps { - reply?: Misskey.entities.Note; - renote?: Misskey.entities.Note; - channel?: Misskey.entities.Channel; // TODO + reply?: Misskey.entities.Note | null; + renote?: Misskey.entities.Note | null; + channel?: Misskey.entities.Channel | null; // TODO mention?: Misskey.entities.User; specified?: Misskey.entities.UserDetailed; initialText?: string; diff --git a/packages/frontend/src/utility/get-note-menu.ts b/packages/frontend/src/utility/get-note-menu.ts index 5361c1252d..11c87dc653 100644 --- a/packages/frontend/src/utility/get-note-menu.ts +++ b/packages/frontend/src/utility/get-note-menu.ts @@ -180,6 +180,7 @@ export function getNoteMenu(props: { currentClip?: Misskey.entities.Clip; }) { const appearNote = getAppearNote(props.note); + const link = appearNote.url ?? appearNote.uri; const cleanups = [] as (() => void)[]; @@ -189,6 +190,7 @@ export function getNoteMenu(props: { text: i18n.ts.noteDeleteConfirm, }).then(({ canceled }) => { if (canceled) return; + if ($i == null) return; misskeyApi('notes/delete', { noteId: appearNote.id, @@ -208,6 +210,7 @@ export function getNoteMenu(props: { text: i18n.ts.deleteAndEditConfirm, }).then(({ canceled }) => { if (canceled) return; + if ($i == null) return; misskeyApi('notes/delete', { noteId: appearNote.id, @@ -317,22 +320,25 @@ export function getNoteMenu(props: { action: copyContent, }, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)); - if (appearNote.url || appearNote.uri) { + if (link) { menuItems.push({ icon: 'ti ti-link', text: i18n.ts.copyRemoteLink, action: () => { - copyToClipboard(appearNote.url ?? appearNote.uri); + copyToClipboard(link); }, }, { icon: 'ti ti-external-link', text: i18n.ts.showOnRemote, action: () => { - window.open(appearNote.url ?? appearNote.uri, '_blank', 'noopener'); + window.open(link, '_blank', 'noopener'); }, }); } else { - menuItems.push(getNoteEmbedCodeMenu(appearNote, i18n.ts.embed)); + const embedMenu = getNoteEmbedCodeMenu(appearNote, i18n.ts.embed); + if (embedMenu != null) { + menuItems.push(embedMenu); + } } if (isSupportShare()) { @@ -475,22 +481,25 @@ export function getNoteMenu(props: { action: copyContent, }, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)); - if (appearNote.url || appearNote.uri) { + if (link != null) { menuItems.push({ icon: 'ti ti-link', text: i18n.ts.copyRemoteLink, action: () => { - copyToClipboard(appearNote.url ?? appearNote.uri); + copyToClipboard(link); }, }, { icon: 'ti ti-external-link', text: i18n.ts.showOnRemote, action: () => { - window.open(appearNote.url ?? appearNote.uri, '_blank', 'noopener'); + window.open(link, '_blank', 'noopener'); }, }); } else { - menuItems.push(getNoteEmbedCodeMenu(appearNote, i18n.ts.embed)); + const embedMenu = getNoteEmbedCodeMenu(appearNote, i18n.ts.embed); + if (embedMenu != null) { + menuItems.push(embedMenu); + } } } @@ -625,7 +634,7 @@ export function getRenoteMenu(props: { }); } }, - }, (props.mock) ? undefined : { + }, ...(props.mock ? [] : [{ text: i18n.ts.quote, icon: 'ti ti-quote', action: () => { @@ -633,7 +642,7 @@ export function getRenoteMenu(props: { renote: appearNote, }); }, - }]); + }])]); normalExternalChannelRenoteItems.push({ type: 'parent',