mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 03:13:10 +02:00
fix: make real-time update work with new notes/show changes
This commit is contained in:
parent
4f2fa60a72
commit
7b04c6ade4
1 changed files with 21 additions and 14 deletions
|
@ -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
|
||||||
noteId: body.id,
|
try {
|
||||||
});
|
const replyNote = await os.api('notes/show', {
|
||||||
|
noteId: body.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
await props.onReplyCallback(replyNote);
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
await props.onReplyCallback(replyNote);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,17 +99,20 @@ export function useNoteCapture(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'updated': {
|
case 'updated': {
|
||||||
const editedNote = await os.api("notes/show", {
|
try {
|
||||||
noteId: id,
|
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];
|
||||||
|
});
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
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];
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue