mirror of
https://github.com/hoornet/vega.git
synced 2026-05-10 22:29:11 -07:00
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:
@@ -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(() => []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user