dm cache
This commit is contained in:
9
packages/app/src/Hooks/useDmsCache.tsx
Normal file
9
packages/app/src/Hooks/useDmsCache.tsx
Normal 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()
|
||||
);
|
||||
}
|
@ -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(() => {
|
||||
|
Reference in New Issue
Block a user