remove no-op Connection.cachedNotes and Connection.cacheNote

This commit is contained in:
Hazelnoot 2025-04-01 12:28:16 -04:00
parent 3455223fec
commit 2e2ae21a09
12 changed files with 0 additions and 43 deletions

View file

@ -36,8 +36,6 @@ export default class Connection {
public subscriber: StreamEventEmitter;
private channels = new Map<string, Channel>();
private subscribingNotes = new Map<string, number>();
// TODO see if we should remove this, now that it has no more reads
private cachedNotes = new Map<string, Packed<'Note'>>();
public userProfile: MiUserProfile | null = null;
public following: Record<string, Pick<MiFollowing, 'withReplies'> | undefined> = {};
public followingChannels: Set<string> = new Set();
@ -155,24 +153,6 @@ export default class Connection {
this.sendMessageToWs(data.type, data.body);
}
@bindThis
public cacheNote(note: Packed<'Note'>) {
const add = (note: Packed<'Note'>) => {
this.cachedNotes.set(note.id, note);
while (this.cachedNotes.size > MAX_CACHED_NOTES_PER_CONNECTION) {
// Map maintains insertion order, so first key is always the oldest
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const oldestKey = this.cachedNotes.keys().next().value!;
this.cachedNotes.delete(oldestKey);
}
};
add(note);
if (note.reply) add(note.reply);
if (note.renote) add(note.renote);
}
@bindThis
private onReadNotification(payload: JsonValue | undefined) {
this.notificationService.readAllNotification(this.user!.id);
@ -371,6 +351,5 @@ export default class Connection {
this.fetchIntervalId = null;
this.channels.clear();
this.subscribingNotes.clear();
this.cachedNotes.clear();
}
}

View file

@ -43,8 +43,6 @@ class AntennaChannel extends Channel {
if (this.isNoteMutedOrBlocked(note)) return;
this.connection.cacheNote(note);
this.send('note', note);
} else {
this.send(data.type, data.body);

View file

@ -66,8 +66,6 @@ class BubbleTimelineChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
}

View file

@ -52,8 +52,6 @@ class ChannelChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
}

View file

@ -63,8 +63,6 @@ class GlobalTimelineChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
}

View file

@ -48,8 +48,6 @@ class HashtagChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
}

View file

@ -84,8 +84,6 @@ class HomeTimelineChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
}

View file

@ -101,8 +101,6 @@ class HybridTimelineChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
}

View file

@ -73,8 +73,6 @@ class LocalTimelineChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
}

View file

@ -39,7 +39,6 @@ class MainChannel extends Channel {
const note = await this.noteEntityService.pack(data.body.note.id, this.user, {
detail: true,
});
this.connection.cacheNote(note);
data.body.note = note;
}
break;
@ -52,7 +51,6 @@ class MainChannel extends Channel {
const note = await this.noteEntityService.pack(data.body.id, this.user, {
detail: true,
});
this.connection.cacheNote(note);
data.body = note;
}
break;

View file

@ -51,8 +51,6 @@ class RoleTimelineChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
} else {
this.send(data.type, data.body);

View file

@ -114,8 +114,6 @@ class UserListChannel extends Channel {
const clonedNote = await this.assignMyReaction(note);
await this.hideNote(clonedNote);
this.connection.cacheNote(clonedNote);
this.send('note', clonedNote);
}