about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-11-17 13:01:57 -0600
committerPaul Frazee <pfrazee@gmail.com>2022-11-17 13:01:57 -0600
commit5d7f3e1863a2d1a0542b1885fdcf107f7e21d6e9 (patch)
treee286594bbb99197d51194c97ee70b1cd88b1b795
parent0d70a097779716a3334811d25f04a6706e7ba38e (diff)
downloadvoidsky-5d7f3e1863a2d1a0542b1885fdcf107f7e21d6e9.tar.zst
Invalidate profiles cache on direct load
-rw-r--r--src/state/models/profile-view.ts1
-rw-r--r--src/state/models/profiles-view.ts6
2 files changed, 7 insertions, 0 deletions
diff --git a/src/state/models/profile-view.ts b/src/state/models/profile-view.ts
index 2cb481936..8386fbbc4 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 4dc5a3999..d9fe98b3f 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)
+    }
+  }
 }