refactor: remove event caches
This commit is contained in:
@ -4,19 +4,14 @@ import {
|
||||
NostrEvent,
|
||||
NostrSystem,
|
||||
ProfileLoaderService,
|
||||
ReqFilter,
|
||||
socialGraphInstance,
|
||||
TaggedNostrEvent,
|
||||
} from "@snort/system";
|
||||
import * as Comlink from "comlink";
|
||||
|
||||
import { RelayMetrics, SystemDb, UserCache, UserRelays } from "@/Cache";
|
||||
import { addEventToFuzzySearch } from "@/Db/FuzzySearch";
|
||||
import IndexedDBWorker from "@/Db/IndexedDB?worker";
|
||||
import { LoginStore } from "@/Utils/Login";
|
||||
import { hasWasm, WasmOptimizer } from "@/Utils/wasm";
|
||||
|
||||
export const indexedDB = Comlink.wrap(new IndexedDBWorker());
|
||||
/**
|
||||
* Singleton nostr system
|
||||
*/
|
||||
@ -39,30 +34,8 @@ System.on("auth", async (c, r, cb) => {
|
||||
System.on("event", (_, ev) => {
|
||||
addEventToFuzzySearch(ev);
|
||||
socialGraphInstance.handleEvent(ev);
|
||||
if (CONFIG.useIndexedDBEvents && socialGraphInstance.getFollowDistance(ev.pubkey) <= 2) {
|
||||
indexedDB.handleEvent(ev);
|
||||
}
|
||||
});
|
||||
|
||||
System.on("request", (filter: ReqFilter) => {
|
||||
if (CONFIG.useIndexedDBEvents) {
|
||||
indexedDB.find(
|
||||
filter,
|
||||
Comlink.proxy((e: TaggedNostrEvent) => {
|
||||
System.HandleEvent(e);
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (CONFIG.useIndexedDBEvents) {
|
||||
// load all profiles
|
||||
indexedDB.find(
|
||||
{ kinds: [0] },
|
||||
Comlink.proxy((e: TaggedNostrEvent) => System.HandleEvent(e)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add profile loader fn
|
||||
*/
|
||||
|
Reference in New Issue
Block a user