mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 00:17:02 +02:00
refactor: remove deprecated kind-specific cache tables and hooks
Clean up old caching infrastructure now that generic cache is in place: Database changes: - Mark relayLists and blossomServers tables as deprecated - Remove tables from v16 schema (set to null for deletion) - Keep table definitions for backward compatibility with old versions - Mark CachedRelayList and CachedBlossomServerList interfaces as deprecated Removed deprecated hooks: - Delete useRelayListCacheSync.ts (no longer needed) - Delete useBlossomServerCacheSync.ts (no longer needed) - All caching now handled by useReplaceableEventCacheSync Migration path: - Old databases will automatically migrate to replaceableEvents table - Wrapper classes (RelayListCache, BlossomServerCache) still work - No breaking changes to consuming code
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
@@ -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]);
|
||||
}
|
||||
@@ -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<Nip>;
|
||||
relayInfo!: Table<RelayInfo>;
|
||||
relayAuthPreferences!: Table<RelayAuthPreference>;
|
||||
/** @deprecated Use replaceableEvents table instead */
|
||||
relayLists!: Table<CachedRelayList>;
|
||||
relayLiveness!: Table<RelayLivenessEntry>;
|
||||
/** @deprecated Use replaceableEvents table instead */
|
||||
blossomServers!: Table<CachedBlossomServerList>;
|
||||
replaceableEvents!: Table<CachedReplaceableEvent>;
|
||||
spells!: Table<LocalSpell>;
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user