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
This commit is contained in:
dakkar 2023-12-19 09:07:32 +00:00
parent b3b89567ee
commit 683b4aafb2
7 changed files with 42 additions and 4 deletions

View file

@ -141,6 +141,7 @@ const likeButton = shallowRef<HTMLElement>();
let appearNote = computed(() => isRenote ? props.note.renote as Misskey.entities.Note : props.note);
const defaultLike = computed(() => defaultStore.state.like ? defaultStore.state.like : null);
const replies = ref<Misskey.entities.Note[]>([]);
const isRenote = (
props.note.renote != null &&
@ -149,10 +150,16 @@ const isRenote = (
props.note.poll == null
);
async function addReplyTo(note, replyNote: Misskey.entities.Note) {
replies.value.unshift(replyNote);
}
useNoteCapture({
rootEl: el,
note: appearNote,
isDeletedRef: isDeleted,
// only update replies if we are, in fact, showing replies
onReplyCallback: props.detail && props.depth < numberOfReplies.value ? addReplyTo : undefined,
});
if ($i) {
@ -259,8 +266,6 @@ watch(() => props.expandAllCws, (expandAllCws) => {
if (expandAllCws !== showContent.value) showContent.value = expandAllCws;
});
let replies = ref<Misskey.entities.Note[]>([]);
function boostVisibility() {
os.popupMenu([
{