This commit is contained in:
2023-03-29 13:10:22 +01:00
parent 8c44d123bd
commit c731c65661
27 changed files with 384 additions and 239 deletions

View File

@ -0,0 +1,9 @@
import { DmCache } from "Cache";
import { useSyncExternalStore } from "react";
export function useDmCache() {
return useSyncExternalStore(
c => DmCache.hook(c, undefined),
() => DmCache.snapshot()
);
}

View File

@ -1,14 +1,14 @@
import { useEffect, useSyncExternalStore } from "react";
import { HexKey } from "@snort/nostr";
import { MetadataCache } from "State/Users";
import { UserCache } from "State/Users/UserCache";
import { MetadataCache } from "Cache";
import { UserCache } from "Cache/UserCache";
import { ProfileLoader } from "System/ProfileCache";
export function useUserProfile(pubKey?: HexKey): MetadataCache | undefined {
const user = useSyncExternalStore<MetadataCache | undefined>(
h => UserCache.hook(h, pubKey),
() => UserCache.get(pubKey)
() => UserCache.getFromCache(pubKey)
);
useEffect(() => {