Chat system refactor
This commit is contained in:
@ -2,9 +2,9 @@ import { NostrEvent } from "@snort/system";
|
||||
import { FeedCache } from "@snort/shared";
|
||||
import { db } from "Db";
|
||||
|
||||
class DMCache extends FeedCache<NostrEvent> {
|
||||
export class ChatCache extends FeedCache<NostrEvent> {
|
||||
constructor() {
|
||||
super("DMCache", db.dms);
|
||||
super("ChatCache", db.chats);
|
||||
}
|
||||
|
||||
key(of: NostrEvent): string {
|
||||
@ -23,13 +23,7 @@ class DMCache extends FeedCache<NostrEvent> {
|
||||
return ret;
|
||||
}
|
||||
|
||||
allDms(): Array<NostrEvent> {
|
||||
takeSnapshot(): Array<NostrEvent> {
|
||||
return [...this.cache.values()];
|
||||
}
|
||||
|
||||
takeSnapshot(): Array<NostrEvent> {
|
||||
return this.allDms();
|
||||
}
|
||||
}
|
||||
|
||||
export const DmCache = new DMCache();
|
@ -1,16 +1,16 @@
|
||||
import { UserProfileCache, UserRelaysCache, RelayMetricCache } from "@snort/system";
|
||||
import { DmCache } from "./DMCache";
|
||||
import { InteractionCache } from "./EventInteractionCache";
|
||||
import { ChatCache } from "./ChatCache";
|
||||
|
||||
export const UserCache = new UserProfileCache();
|
||||
export const UserRelays = new UserRelaysCache();
|
||||
export const RelayMetrics = new RelayMetricCache();
|
||||
export { DmCache };
|
||||
export const Chats = new ChatCache();
|
||||
|
||||
export async function preload(follows?: Array<string>) {
|
||||
const preloads = [
|
||||
UserCache.preload(follows),
|
||||
DmCache.preload(),
|
||||
Chats.preload(),
|
||||
InteractionCache.preload(),
|
||||
UserRelays.preload(follows),
|
||||
RelayMetrics.preload(),
|
||||
|
Reference in New Issue
Block a user