mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-11 16:07:15 +02:00
25 lines
650 B
TypeScript
25 lines
650 B
TypeScript
/**
|
|
* Hook to keep relay list cache in sync with EventStore
|
|
*
|
|
* Subscribes to kind:10002 events and automatically caches them in Dexie.
|
|
* Should be used once at app root level.
|
|
*/
|
|
|
|
import { useEffect } from "react";
|
|
import { useEventStore } from "applesauce-react/hooks";
|
|
import relayListCache from "@/services/relay-list-cache";
|
|
|
|
export function useRelayListCacheSync() {
|
|
const eventStore = useEventStore();
|
|
|
|
useEffect(() => {
|
|
// Subscribe to EventStore for auto-caching
|
|
relayListCache.subscribeToEventStore(eventStore);
|
|
|
|
// Cleanup on unmount
|
|
return () => {
|
|
relayListCache.unsubscribe();
|
|
};
|
|
}, [eventStore]);
|
|
}
|