summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/use-note-capture.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2023-12-19 09:07:32 +0000
committerdakkar <dakkar@thenautilus.net>2023-12-23 14:09:51 +0000
commit683b4aafb2928f2d8dfa626352584542e3df8e3a (patch)
tree156e0a8fe4ea1646fee22b9857eaa62635f8c0c4 /packages/frontend/src/scripts/use-note-capture.ts
parentmerge: upstream (diff)
downloadsharkey-683b4aafb2928f2d8dfa626352584542e3df8e3a.tar.gz
sharkey-683b4aafb2928f2d8dfa626352584542e3df8e3a.tar.bz2
sharkey-683b4aafb2928f2d8dfa626352584542e3df8e3a.zip
real-time updates on note detail view
`useNoteCapture` already subscribes to all updates for a note, so we can tell it when a note gets replied to, too Since I'm not actually adding any extra subscription in the client, just an extra callback, there should be no overhead when replies are not coming in. Also, all the timelines already call `useNoteCapture` for each note displayed, so we know the whole `GlobalEventService` thing works fine. Many thanks to VueJS for taking care of all the DOM complications
Diffstat (limited to 'packages/frontend/src/scripts/use-note-capture.ts')
-rw-r--r--packages/frontend/src/scripts/use-note-capture.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/frontend/src/scripts/use-note-capture.ts b/packages/frontend/src/scripts/use-note-capture.ts
index ab232598cd..8692d056b0 100644
--- a/packages/frontend/src/scripts/use-note-capture.ts
+++ b/packages/frontend/src/scripts/use-note-capture.ts
@@ -14,6 +14,7 @@ export function useNoteCapture(props: {
note: Ref<Misskey.entities.Note>;
pureNote: Ref<Misskey.entities.Note>;
isDeletedRef: Ref<boolean>;
+ onReplyCallback: (note, replyNote: Misskey.entities.Note) => void | undefined;
}) {
const note = props.note;
const pureNote = props.pureNote !== undefined ? props.pureNote : props.note;
@@ -25,6 +26,17 @@ export function useNoteCapture(props: {
if ((id !== note.value.id) && (id !== pureNote.value.id)) return;
switch (type) {
+ case 'replied': {
+ if (!props.onReplyCallback) break;
+
+ const replyNote = await os.api("notes/show", {
+ noteId: body.id,
+ });
+
+ await props.onReplyCallback(pureNote, replyNote);
+ break;
+ }
+
case 'reacted': {
const reaction = body.reaction;