From 0d942aacf86b677cfe536d8c9b5f0731ca8598cb Mon Sep 17 00:00:00 2001 From: Nya Candy Date: Sat, 27 Jan 2024 00:43:07 +0800 Subject: [PATCH] feat: get note updatedAt from backend --- packages/backend/src/core/GlobalEventService.ts | 1 + packages/backend/src/core/NoteUpdateService.ts | 1 + packages/frontend/src/scripts/use-note-capture.ts | 2 +- packages/misskey-js/src/streaming.types.ts | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/GlobalEventService.ts b/packages/backend/src/core/GlobalEventService.ts index 87aa70713..8cda6d8da 100644 --- a/packages/backend/src/core/GlobalEventService.ts +++ b/packages/backend/src/core/GlobalEventService.ts @@ -120,6 +120,7 @@ export interface NoteEventTypes { updated: { cw: string | null; text: string; + updatedAt: string; }; reacted: { reaction: string; diff --git a/packages/backend/src/core/NoteUpdateService.ts b/packages/backend/src/core/NoteUpdateService.ts index 12e543443..40d5f1746 100644 --- a/packages/backend/src/core/NoteUpdateService.ts +++ b/packages/backend/src/core/NoteUpdateService.ts @@ -86,6 +86,7 @@ export class NoteUpdateService { this.globalEventService.publishNoteStream(note.id, 'updated', { cw: ps.cw, text: ps.text ?? '', // prevent null + updatedAt: ps.updatedAt.toISOString(), }); if (this.userEntityService.isLocalUser(user) && !note.localOnly) { diff --git a/packages/frontend/src/scripts/use-note-capture.ts b/packages/frontend/src/scripts/use-note-capture.ts index 86cff7887..a35f72781 100644 --- a/packages/frontend/src/scripts/use-note-capture.ts +++ b/packages/frontend/src/scripts/use-note-capture.ts @@ -76,7 +76,7 @@ export function useNoteCapture(props: { } case 'updated': { - note.value.updatedAt = new Date().toISOString(); + note.value.updatedAt = body.updatedAt; note.value.cw = body.cw; note.value.text = body.text; break; diff --git a/packages/misskey-js/src/streaming.types.ts b/packages/misskey-js/src/streaming.types.ts index b29a84e71..50288679c 100644 --- a/packages/misskey-js/src/streaming.types.ts +++ b/packages/misskey-js/src/streaming.types.ts @@ -256,6 +256,7 @@ export type NoteUpdatedEvent = { body: { cw: string | null; text: string; + updatedAt: string; }; } | { type: 'pollVoted';