1
0
Fork 1
mirror of https://example.com synced 2024-11-22 11:16:38 +09:00

fix: prevent unison-reload on make-private

This commit is contained in:
sup39 2023-10-18 02:34:35 +09:00 committed by naskya
parent 4b2e23e28e
commit 5d577e280e
Signed by: naskya
GPG key ID: 164DFF24E2D40139
4 changed files with 28 additions and 16 deletions

View file

@ -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(),
});
});

View file

@ -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) {

View file

@ -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();
});
}

View file

@ -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;
}
}