fix: make real-time update work with new notes/show changes

This commit is contained in:
Marie 2023-12-31 19:29:09 +01:00
parent 4f2fa60a72
commit 7b04c6ade4
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828

View file

@ -30,11 +30,15 @@ export function useNoteCapture(props: {
case 'replied': { case 'replied': {
if (!props.onReplyCallback) break; if (!props.onReplyCallback) break;
const replyNote = await os.api("notes/show", { // notes/show may throw if the current user can't see the note
try {
const replyNote = await os.api('notes/show', {
noteId: body.id, noteId: body.id,
}); });
await props.onReplyCallback(replyNote); await props.onReplyCallback(replyNote);
} catch { /* empty */ }
break; break;
} }
@ -95,7 +99,8 @@ export function useNoteCapture(props: {
} }
case 'updated': { case 'updated': {
const editedNote = await os.api("notes/show", { try {
const editedNote = await os.api('notes/show', {
noteId: id, noteId: id,
}); });
@ -106,6 +111,8 @@ export function useNoteCapture(props: {
keys.forEach((key) => { keys.forEach((key) => {
note.value[key] = editedNote[key]; note.value[key] = editedNote[key];
}); });
} catch { /* empty */ }
break; break;
} }
} }