SQLite-backed caching for bookmarks and articles feed

Bookmarks load instantly from DB cache, then fetch missing notes
from relays in background. Articles feed shows cached kind-30023
events immediately on the latest tab. Both persist to SQLite for
instant load on next visit.
This commit is contained in:
Jure
2026-03-29 20:46:18 +02:00
parent d450f8fdeb
commit 5d94220e5d
4 changed files with 205 additions and 42 deletions

View File

@@ -62,3 +62,23 @@ export function dbSaveFollowers(followers: string[], ownerPubkey: string): void
export async function dbLoadFollowers(ownerPubkey: string): Promise<string[]> {
return invoke<string[]>("db_load_followers", { ownerPubkey }).catch(() => []);
}
// ── Bookmarks cache ────────────────────────────────────────────────────────
/** Save bookmarked note events to SQLite. Fire-and-forget. */
export function dbSaveBookmarkedNotes(raws: string[], ownerPubkey: string): void {
if (raws.length === 0) return;
invoke("db_save_bookmarked_notes", { notes: raws, ownerPubkey }).catch(() => {});
}
/** Load cached bookmarked note JSONs for owner. */
export async function dbLoadBookmarkedNotes(ownerPubkey: string): Promise<string[]> {
return invoke<string[]>("db_load_bookmarked_notes", { ownerPubkey }).catch(() => []);
}
// ── Articles cache ─────────────────────────────────────────────────────────
/** Load cached articles (kind 30023) from the notes table. */
export async function dbLoadArticles(limit = 100): Promise<string[]> {
return invoke<string[]>("db_load_articles", { limit }).catch(() => []);
}