about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2023-11-06 20:51:46 -0600
committerGitHub <noreply@github.com>2023-11-06 18:51:46 -0800
commit7ffbee18b578cc7f6d5eff6b7b4740eeb278d387 (patch)
treef796a32dc7ad7a4fa60c90ebe8d0805eee159167 /src
parenta4baf14e4b9516c3611c1d8d988603994ea8a09f (diff)
downloadvoidsky-7ffbee18b578cc7f6d5eff6b7b4740eeb278d387.tar.zst
Fix removal of old lists from saved feeds (#1823)
* Fix removal of old lists from saved feeds

* Fix saved feed removal race condition
Diffstat (limited to 'src')
-rw-r--r--src/state/models/content/feed-source.ts11
-rw-r--r--src/state/models/content/list.ts2
-rw-r--r--src/state/models/ui/saved-feeds.ts14
3 files changed, 20 insertions, 7 deletions
diff --git a/src/state/models/content/feed-source.ts b/src/state/models/content/feed-source.ts
index 79747d6fb..156e3be3b 100644
--- a/src/state/models/content/feed-source.ts
+++ b/src/state/models/content/feed-source.ts
@@ -142,7 +142,8 @@ export class FeedSourceModel {
   }
 
   async unsave() {
-    if (this.type !== 'feed-generator') {
+    // TODO TEMPORARY — see PRF's comment in content/list.ts togglePin
+    if (this.type !== 'feed-generator' && this.type !== 'list') {
       return
     }
     try {
@@ -179,7 +180,13 @@ export class FeedSourceModel {
         name: this.displayName,
         uri: this.uri,
       })
-      return this.rootStore.preferences.removePinnedFeed(this.uri)
+
+      if (this.type === 'list') {
+        // TODO TEMPORARY — see PRF's comment in content/list.ts togglePin
+        return this.unsave()
+      } else {
+        return this.rootStore.preferences.removePinnedFeed(this.uri)
+      }
     }
   }
 
diff --git a/src/state/models/content/list.ts b/src/state/models/content/list.ts
index 115426e5c..fc09eeb9f 100644
--- a/src/state/models/content/list.ts
+++ b/src/state/models/content/list.ts
@@ -361,7 +361,7 @@ export class ListModel {
         name: this.data?.name || '',
         uri: this.uri,
       })
-      // TEMPORARY
+      // TODO TEMPORARY
       // lists are temporarily piggybacking on the saved/pinned feeds preferences
       // we'll eventually replace saved feeds with the bookmarks API
       // until then, we need to unsave lists instead of just unpin them
diff --git a/src/state/models/ui/saved-feeds.ts b/src/state/models/ui/saved-feeds.ts
index fd84edc02..624da4f5f 100644
--- a/src/state/models/ui/saved-feeds.ts
+++ b/src/state/models/ui/saved-feeds.ts
@@ -38,12 +38,18 @@ export class SavedFeedsModel {
     return this.hasLoaded && !this.hasContent
   }
 
-  get pinned() {
-    return this.all.filter(feed => feed.isPinned)
+  get pinned(): FeedSourceModel[] {
+    return this.rootStore.preferences.savedFeeds
+      .filter(feed => this.rootStore.preferences.isPinnedFeed(feed))
+      .map(uri => this.all.find(f => f.uri === uri))
+      .filter(Boolean) as FeedSourceModel[]
   }
 
-  get unpinned() {
-    return this.all.filter(feed => !feed.isPinned)
+  get unpinned(): FeedSourceModel[] {
+    return this.rootStore.preferences.savedFeeds
+      .filter(feed => !this.rootStore.preferences.isPinnedFeed(feed))
+      .map(uri => this.all.find(f => f.uri === uri))
+      .filter(Boolean) as FeedSourceModel[]
   }
 
   get pinnedFeedNames() {