Fix removal of old lists from saved feeds (#1823)

* Fix removal of old lists from saved feeds

* Fix saved feed removal race condition
zio/stable
Eric Bailey 2023-11-06 20:51:46 -06:00 committed by GitHub
parent a4baf14e4b
commit 7ffbee18b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View File

@ -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)
}
}
}

View File

@ -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

View File

@ -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() {