about summary refs log tree commit diff
path: root/src/state/models/feeds/algo/algo-item.ts
diff options
context:
space:
mode:
authorAnsh Nanda <anshnanda10@gmail.com>2023-05-16 16:07:07 -0700
committerAnsh Nanda <anshnanda10@gmail.com>2023-05-16 16:07:07 -0700
commit3f41d3db2603e75b6443487ce261a05f8e14076d (patch)
tree866d4e4aab297a23b39a60f383ac32a59fca7499 /src/state/models/feeds/algo/algo-item.ts
parentf2e39d8ad24041637810327ca28ad78f9f36bf2f (diff)
downloadvoidsky-3f41d3db2603e75b6443487ce261a05f8e14076d.tar.zst
make sure state is being synced across components
Diffstat (limited to 'src/state/models/feeds/algo/algo-item.ts')
-rw-r--r--src/state/models/feeds/algo/algo-item.ts28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/state/models/feeds/algo/algo-item.ts b/src/state/models/feeds/algo/algo-item.ts
index 39bc760ac..8291b6d86 100644
--- a/src/state/models/feeds/algo/algo-item.ts
+++ b/src/state/models/feeds/algo/algo-item.ts
@@ -67,30 +67,12 @@ export class AlgoItemModel {
     }
   }
 
-  // public apis
-  // =
-  async save() {
-    try {
-      this.toggleSaved = true
-      await this.rootStore.agent.app.bsky.feed.saveFeed({
-        feed: this.data.uri,
-      })
-    } catch (e: any) {
-      this.rootStore.log.error('Failed to save feed', e)
-    }
-  }
-
-  async unsave() {
-    try {
-      this.toggleSaved = false
-      await this.rootStore.agent.app.bsky.feed.unsaveFeed({
-        feed: this.data.uri,
-      })
-    } catch (e: any) {
-      this.rootStore.log.error('Failed to unsanve feed', e)
-    }
+  private rewriteData(data: AppBskyFeedDefs.GeneratorView) {
+    this.data = data
   }
 
+  // public apis
+  // =
   async like() {
     try {
       const res = await this.rootStore.agent.app.bsky.feed.like.create(
@@ -151,7 +133,7 @@ export class AlgoItemModel {
     const res = await this.rootStore.agent.app.bsky.feed.getFeedGenerator({
       feed: this.data.uri,
     })
-    this.data = res.data.view
+    this.rewriteData(res.data.view)
   }
 
   serialize() {