import { NostrEvent } from "@snort/system"; import { FeedCache } from "@snort/shared"; import { db } from "Db"; export class ChatCache extends FeedCache { constructor() { super("ChatCache", db.chats); } key(of: NostrEvent): string { return of.id; } override async preload(): Promise { await super.preload(); // load all dms to memory await this.buffer([...this.onTable]); } newest(): number { let ret = 0; this.cache.forEach(v => (ret = v.created_at > ret ? v.created_at : ret)); return ret; } takeSnapshot(): Array { return [...this.cache.values()]; } }