diff --git a/packages/backend/src/server/api/endpoints/notes/make-private.ts b/packages/backend/src/server/api/endpoints/notes/make-private.ts index 749b40b75..a4a26d158 100644 --- a/packages/backend/src/server/api/endpoints/notes/make-private.ts +++ b/packages/backend/src/server/api/endpoints/notes/make-private.ts @@ -4,6 +4,7 @@ import define from "../../define.js"; import { getNote } from "../../common/getters.js"; import { ApiError } from "../../error.js"; import { SECOND, HOUR } from "@/const.js"; +import { publishNoteStream } from "@/services/stream.js"; export const meta = { tags: ["notes"], @@ -57,4 +58,10 @@ export default define(meta, paramDef, async (ps, user) => { visibility: "specified", visibleUserIds: [], }); + + // Publish update event for the updated note details + // TODO: Send "deleted" to other users? + publishNoteStream(note.id, "updated", { + updatedAt: new Date(), + }); }); diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index a14af82d4..73577e590 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -46,9 +46,12 @@ export default async function ( } if (!quiet) { - publishNoteStream(note.id, "deleted", { - deletedAt: deletedAt, - }); + // Only broadcast "deleted" to local if the note is deleted from db + if (deleteFromDb) { + publishNoteStream(note.id, "deleted", { + deletedAt: deletedAt, + }); + } //#region ローカルの投稿なら削除アクティビティを配送 if (Users.isLocalUser(user) && !note.localOnly) { diff --git a/packages/client/src/scripts/get-note-menu.ts b/packages/client/src/scripts/get-note-menu.ts index 30145bc5d..6336f240d 100644 --- a/packages/client/src/scripts/get-note-menu.ts +++ b/packages/client/src/scripts/get-note-menu.ts @@ -10,7 +10,6 @@ import { url } from "@/config"; import { noteActions } from "@/store"; import { shareAvailable } from "@/scripts/share-available"; import { getUserMenu } from "@/scripts/get-user-menu"; -import { unisonReload } from "@/scripts/unison-reload"; import icon from "@/scripts/icon"; export function getNoteMenu(props: { @@ -84,8 +83,6 @@ export function getNoteMenu(props: { await os.api("notes/make-private", { noteId: appearNote.id, }); - - unisonReload(); }); } diff --git a/packages/client/src/scripts/use-note-capture.ts b/packages/client/src/scripts/use-note-capture.ts index 57cf5b84a..e3dd3ede7 100644 --- a/packages/client/src/scripts/use-note-capture.ts +++ b/packages/client/src/scripts/use-note-capture.ts @@ -80,17 +80,22 @@ export function useNoteCapture(props: { } case "updated": { - const editedNote = await os.api("notes/show", { - noteId: id, - }); + try { + const editedNote = await os.api("notes/show", { + noteId: id, + }); - const keys = new Set(); - Object.keys(editedNote) - .concat(Object.keys(note.value)) - .forEach((key) => keys.add(key)); - keys.forEach((key) => { - note.value[key] = editedNote[key]; - }); + const keys = new Set(); + Object.keys(editedNote) + .concat(Object.keys(note.value)) + .forEach((key) => keys.add(key)); + keys.forEach((key) => { + note.value[key] = editedNote[key]; + }); + } catch { + // delete the note if failing to get the edited note + props.isDeletedRef.value = true; + } break; } }