From 2292429f66409964d7f171c6f02998c5bbac8827 Mon Sep 17 00:00:00 2001 From: Kieran Date: Tue, 17 Jan 2023 16:49:00 +0000 Subject: [PATCH] bug: profile is up to date --- src/nostr/System.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nostr/System.ts b/src/nostr/System.ts index 354d0b40..e10848a1 100644 --- a/src/nostr/System.ts +++ b/src/nostr/System.ts @@ -156,10 +156,10 @@ export class NostrSystem { async _FetchMetadata() { let missing = new Set(); let meta = await db.users.bulkGet(Array.from(this.WantsMetadata)); - let now = new Date().getTime(); + let expire = new Date().getTime() - ProfileCacheExpire; for (let pk of this.WantsMetadata) { let m = meta.find(a => a?.pubkey === pk); - if (!m || m.loaded < (now - ProfileCacheExpire)) { + if (!m || m.loaded < expire) { missing.add(pk); // cap 100 missing profiles if (missing.size >= 100) { @@ -181,6 +181,8 @@ export class NostrSystem { let existing = await db.users.get(profile.pubkey); if((existing?.created ?? 0) < profile.created) { await db.users.put(profile); + } else if(existing) { + await db.users.update(profile.pubkey, { loaded: new Date().getTime() }); } } }