mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
remove no-op Connection.cachedNotes and Connection.cacheNote
This commit is contained in:
parent
3455223fec
commit
2e2ae21a09
12 changed files with 0 additions and 43 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue