fix: prevent unison-reload on make-private
This commit is contained in:
parent
4b2e23e28e
commit
5d577e280e
4 changed files with 28 additions and 16 deletions
|
@ -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(),
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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<string>();
|
||||
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<string>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue