diff --git a/packages/frontend/src/scripts/use-note-capture.ts b/packages/frontend/src/scripts/use-note-capture.ts index 1b3626bff5..89aa023f23 100644 --- a/packages/frontend/src/scripts/use-note-capture.ts +++ b/packages/frontend/src/scripts/use-note-capture.ts @@ -13,16 +13,16 @@ import { misskeyApi } from './misskey-api.js'; export function useNoteCapture(props: { rootEl: ShallowRef; note: Ref; - pureNote: Ref; + pureNote?: Ref; isDeletedRef: Ref; - onReplyCallback: (replyNote: Misskey.entities.Note) => void | undefined; - onDeleteCallback: (id: Misskey.entities.Note['id']) => void | undefined; + onReplyCallback?: (replyNote: Misskey.entities.Note) => void | Promise; + onDeleteCallback?: (id: Misskey.entities.Note['id']) => void | Promise; }) { const note = props.note; const pureNote = props.pureNote !== undefined ? props.pureNote : props.note; const connection = $i ? useStream() : null; - async function onStreamNoteUpdated(noteData): void { + async function onStreamNoteUpdated(noteData): Promise { const { type, id, body } = noteData; if ((id !== note.value.id) && (id !== pureNote.value.id)) return; @@ -39,7 +39,7 @@ export function useNoteCapture(props: { await props.onReplyCallback(replyNote); } catch { /* empty */ } - + break; } @@ -81,7 +81,7 @@ export function useNoteCapture(props: { case 'pollVoted': { const choice = body.choice; - const choices = [...note.value.poll.choices]; + const choices = [...note.value.poll!.choices]; choices[choice] = { ...choices[choice], votes: choices[choice].votes + 1, @@ -90,7 +90,7 @@ export function useNoteCapture(props: { } : {}), }; - note.value.poll.choices = choices; + note.value.poll!.choices = choices; break; } @@ -106,7 +106,7 @@ export function useNoteCapture(props: { const editedNote = await misskeyApi('notes/show', { noteId: id, }); - + const keys = new Set(); Object.keys(editedNote) .concat(Object.keys(note.value))