mirror of
https://github.com/hoornet/vega.git
synced 2026-05-10 14:19:12 -07:00
SQLite-backed followers cache and instant own-profile load
Followers now load instantly from SQLite on startup, then merge relay results in background. Own profile name/picture loads from DB cache so sidebar badge never shows raw npub on slow relays.
This commit is contained in:
@@ -49,3 +49,16 @@ export function dbMarkNotificationRead(ids: string[]): void {
|
||||
export async function dbNewestNotificationTs(ownerPubkey: string, notifType: string): Promise<number | null> {
|
||||
return invoke<number | null>("db_newest_notification_ts", { ownerPubkey, notifType }).catch(() => null);
|
||||
}
|
||||
|
||||
// ── Followers cache ────────────────────────────────────────────────────────
|
||||
|
||||
/** Save follower pubkeys to SQLite. Fire-and-forget. */
|
||||
export function dbSaveFollowers(followers: string[], ownerPubkey: string): void {
|
||||
if (followers.length === 0) return;
|
||||
invoke("db_save_followers", { followers, ownerPubkey }).catch(() => {});
|
||||
}
|
||||
|
||||
/** Load cached follower pubkeys for owner. */
|
||||
export async function dbLoadFollowers(ownerPubkey: string): Promise<string[]> {
|
||||
return invoke<string[]>("db_load_followers", { ownerPubkey }).catch(() => []);
|
||||
}
|
||||
|
||||
@@ -85,10 +85,11 @@ export async function fetchMentions(pubkey: string, since: number, limit = 50):
|
||||
|
||||
export async function fetchFollowers(pubkey: string, limit = 200): Promise<string[]> {
|
||||
const instance = getNDK();
|
||||
// #p queries on kind 3 are slow on most relays — give them extra time
|
||||
const events = await fetchWithTimeout(
|
||||
instance,
|
||||
{ kinds: [3 as NDKKind], "#p": [pubkey], limit },
|
||||
FEED_TIMEOUT,
|
||||
15000,
|
||||
);
|
||||
const followerPubkeys = new Set<string>();
|
||||
for (const e of events) {
|
||||
|
||||
Reference in New Issue
Block a user