diff --git a/src/hooks/useBlossomServerCacheSync.ts b/src/hooks/useBlossomServerCacheSync.ts deleted file mode 100644 index 68aacfe..0000000 --- a/src/hooks/useBlossomServerCacheSync.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Hook to keep blossom server cache in sync with EventStore - * - * Subscribes to kind:10063 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 blossomServerCache from "@/services/blossom-server-cache"; - -export function useBlossomServerCacheSync() { - const eventStore = useEventStore(); - - useEffect(() => { - // Subscribe to EventStore for auto-caching - blossomServerCache.subscribeToEventStore(eventStore); - - // Cleanup on unmount - return () => { - blossomServerCache.unsubscribe(); - }; - }, [eventStore]); -} diff --git a/src/hooks/useRelayListCacheSync.ts b/src/hooks/useRelayListCacheSync.ts deleted file mode 100644 index 666e245..0000000 --- a/src/hooks/useRelayListCacheSync.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * 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]); -} diff --git a/src/services/db.ts b/src/services/db.ts index 4e346e3..79be877 100644 --- a/src/services/db.ts +++ b/src/services/db.ts @@ -37,14 +37,6 @@ export interface RelayAuthPreference { updatedAt: number; } -export interface CachedRelayList { - pubkey: string; - event: NostrEvent; - read: string[]; - write: string[]; - updatedAt: number; -} - export interface RelayLivenessEntry { url: string; state: "online" | "offline" | "dead"; @@ -54,6 +46,22 @@ export interface RelayLivenessEntry { backoffUntil?: number; } +/** + * @deprecated Use CachedReplaceableEvent instead + * Kept for backward compatibility with old database versions + */ +export interface CachedRelayList { + pubkey: string; + event: NostrEvent; + read: string[]; + write: string[]; + updatedAt: number; +} + +/** + * @deprecated Use CachedReplaceableEvent instead + * Kept for backward compatibility with old database versions + */ export interface CachedBlossomServerList { pubkey: string; event: NostrEvent; @@ -105,8 +113,10 @@ class GrimoireDb extends Dexie { nips!: Table; relayInfo!: Table; relayAuthPreferences!: Table; + /** @deprecated Use replaceableEvents table instead */ relayLists!: Table; relayLiveness!: Table; + /** @deprecated Use replaceableEvents table instead */ blossomServers!: Table; replaceableEvents!: Table; spells!: Table; @@ -347,16 +357,16 @@ class GrimoireDb extends Dexie { spellbooks: "&id, slug, title, createdAt, isPublished, deletedAt", }); - // Version 16: Add generic replaceable event cache + // Version 16: Add generic replaceable event cache, deprecate old kind-specific tables this.version(16).stores({ profiles: "&pubkey", nip05: "&nip05", nips: "&id", relayInfo: "&url", relayAuthPreferences: "&url", - relayLists: "&pubkey, updatedAt", + relayLists: null, // Deprecated - migrated to replaceableEvents relayLiveness: "&url", - blossomServers: "&pubkey, updatedAt", + blossomServers: null, // Deprecated - migrated to replaceableEvents replaceableEvents: "[pubkey+kind+d], [pubkey+kind], kind, updatedAt", spells: "&id, alias, createdAt, isPublished, deletedAt", spellbooks: "&id, slug, title, createdAt, isPublished, deletedAt",