perf(timeline): Optimizing for CDN Caching (MisskeyIO#834)

Co-authored-by: あわわわとーにゅ <17376330+u1-liquid@users.noreply.github.com>
This commit is contained in:
たーびん 2024-12-22 04:01:53 +09:00 committed by GitHub
parent 3362c464c5
commit 4ecfae0d85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 205 additions and 27 deletions

View file

@ -17,6 +17,7 @@ class HomeTimelineChannel extends Channel {
public static readonly kind = 'read:account';
private withRenotes: boolean;
private withFiles: boolean;
private idOnly: boolean;
constructor(
private noteEntityService: NoteEntityService,
@ -32,6 +33,7 @@ class HomeTimelineChannel extends Channel {
public async init(params: any) {
this.withRenotes = params.withRenotes ?? true;
this.withFiles = params.withFiles ?? false;
this.idOnly = params.idOnly ?? false;
this.subscriber.on('notesStream', this.onNote);
}
@ -89,9 +91,13 @@ class HomeTimelineChannel extends Channel {
}
}
this.connection.cacheNote(note);
this.send('note', note);
if (this.idOnly && ['public', 'home'].includes(note.visibility)) {
const idOnlyNote = { id: note.id };
this.send('note', idOnlyNote);
} else {
this.connection.cacheNote(note);
this.send('note', note);
}
}
@bindThis