From 5d7f3e1863a2d1a0542b1885fdcf107f7e21d6e9 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 17 Nov 2022 13:01:57 -0600 Subject: [PATCH] Invalidate profiles cache on direct load --- src/state/models/profile-view.ts | 1 + src/state/models/profiles-view.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/state/models/profile-view.ts b/src/state/models/profile-view.ts index 2cb48193..8386fbbc 100644 --- a/src/state/models/profile-view.ts +++ b/src/state/models/profile-view.ts @@ -140,6 +140,7 @@ export class ProfileViewModel { const res = await this.rootStore.api.app.bsky.actor.getProfile( this.params, ) + this.rootStore.profiles.overwrite(this.params.actor, res) // cache invalidation this._replaceAll(res) this._xIdle() } catch (e: any) { diff --git a/src/state/models/profiles-view.ts b/src/state/models/profiles-view.ts index 4dc5a399..d9fe98b3 100644 --- a/src/state/models/profiles-view.ts +++ b/src/state/models/profiles-view.ts @@ -41,4 +41,10 @@ export class ProfilesViewModel { throw e } } + + overwrite(did: string, res: GetProfile.Response) { + if (this.cache.has(did)) { + this.cache.set(did, res) + } + } }