perf(stream): 必要のない既読処理のメッセージが発生しないように (MisskeyIO#907)

This commit is contained in:
あわわわとーにゅ 2025-01-17 18:35:08 +09:00 committed by GitHub
parent 8821e3e81b
commit c4fafbdca7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 50 additions and 13 deletions

View File

@ -51,6 +51,10 @@ class AntennaChannel extends Channel {
if (this.isNoteMutedOrBlocked(note)) return;
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
this.send('note', {
id: note.id, myReaction: note.myReaction,
@ -59,7 +63,6 @@ class AntennaChannel extends Channel {
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
});
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
} else {

View File

@ -57,6 +57,10 @@ class ChannelChannel extends Channel {
}
}
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
this.send('note', {
id: note.id, myReaction: note.myReaction,
@ -65,7 +69,6 @@ class ChannelChannel extends Channel {
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
});
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
}

View File

@ -87,6 +87,10 @@ class GlobalTimelineChannel extends Channel {
}
}
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
this.send('note', {
id: note.id, myReaction: note.myReaction,
@ -95,7 +99,6 @@ class GlobalTimelineChannel extends Channel {
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
});
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
}

View File

@ -60,7 +60,9 @@ class HashtagChannel extends Channel {
}
}
this.connection.cacheNote(note);
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
this.send('note', note);
}

View File

@ -91,6 +91,10 @@ class HomeTimelineChannel extends Channel {
}
}
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
this.send('note', {
id: note.id, myReaction: note.myReaction,
@ -99,7 +103,6 @@ class HomeTimelineChannel extends Channel {
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
});
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
}

View File

@ -105,6 +105,10 @@ class HybridTimelineChannel extends Channel {
}
}
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
this.send('note', {
id: note.id, myReaction: note.myReaction,
@ -113,7 +117,6 @@ class HybridTimelineChannel extends Channel {
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
});
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
}

View File

@ -90,6 +90,10 @@ class LocalTimelineChannel extends Channel {
}
}
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
this.send('note', {
id: note.id, myReaction: note.myReaction,
@ -98,7 +102,6 @@ class LocalTimelineChannel extends Channel {
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
});
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
}

View File

@ -38,7 +38,11 @@ class MainChannel extends Channel {
const note = await this.noteEntityService.pack(data.body.note.id, this.user, {
detail: true,
});
this.connection.cacheNote(note);
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
data.body.note = note;
}
break;
@ -51,7 +55,11 @@ class MainChannel extends Channel {
const note = await this.noteEntityService.pack(data.body.id, this.user, {
detail: true,
});
this.connection.cacheNote(note);
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
data.body = note;
}
break;

View File

@ -73,6 +73,10 @@ class RoleTimelineChannel extends Channel {
}
}
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
this.send('note', {
id: note.id, myReaction: note.myReaction,
@ -81,7 +85,6 @@ class RoleTimelineChannel extends Channel {
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
});
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
} else {

View File

@ -130,6 +130,10 @@ class UserListChannel extends Channel {
}
}
if (this.user && (note.visibleUserIds?.includes(this.user.id) ?? note.mentions?.includes(this.user.id))) {
this.connection.cacheNote(note);
}
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
this.send('note', {
id: note.id, myReaction: note.myReaction,
@ -138,7 +142,6 @@ class UserListChannel extends Channel {
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
});
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
}

View File

@ -60,6 +60,8 @@ export function useNoteCapture(props: {
}
case 'pollVoted': {
if (note.value.poll == null) return;
const choice = body.choice;
const choices = [...note.value.poll.choices];
@ -84,8 +86,9 @@ export function useNoteCapture(props: {
function capture(withHandler = false): void {
if (connection) {
// TODO: このノートがストリーミング経由で流れてきた場合のみ sr する
connection.send(document.body.contains(props.rootEl.value ?? null as Node | null) ? 'sr' : 's', { id: note.value.id });
if ($i && (note.value?.visibleUserIds?.includes($i.id) ?? note.value?.mentions?.includes($i.id))) {
connection.send(document.body.contains(props.rootEl.value ?? null as Node | null) ? 'sr' : 's', { id: note.value.id });
}
if (pureNote.value.id !== note.value.id) connection.send('s', { id: pureNote.value.id });
if (withHandler) connection.on('noteUpdated', onStreamNoteUpdated);
}