Skip to content

Commit

Permalink
Fix removal of old lists from saved feeds (#1823)
Browse files Browse the repository at this point in the history
* Fix removal of old lists from saved feeds

* Fix saved feed removal race condition
  • Loading branch information
estrattonbailey authored Nov 7, 2023
1 parent a4baf14 commit 7ffbee1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/state/models/content/feed-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/state/models/content/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions src/state/models/ui/saved-feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 7ffbee1

Please sign in to comment.