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() { 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 return
} }
try { try {
@ -179,9 +180,15 @@ export class FeedSourceModel {
name: this.displayName, name: this.displayName,
uri: this.uri, uri: 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) return this.rootStore.preferences.removePinnedFeed(this.uri)
} }
} }
}
async like() { async like() {
if (this.type !== 'feed-generator') { if (this.type !== 'feed-generator') {

View File

@ -361,7 +361,7 @@ export class ListModel {
name: this.data?.name || '', name: this.data?.name || '',
uri: this.uri, uri: this.uri,
}) })
// TEMPORARY // TODO TEMPORARY
// lists are temporarily piggybacking on the saved/pinned feeds preferences // lists are temporarily piggybacking on the saved/pinned feeds preferences
// we'll eventually replace saved feeds with the bookmarks API // we'll eventually replace saved feeds with the bookmarks API
// until then, we need to unsave lists instead of just unpin them // 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 return this.hasLoaded && !this.hasContent
} }
get pinned() { get pinned(): FeedSourceModel[] {
return this.all.filter(feed => feed.isPinned) 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() { get unpinned(): FeedSourceModel[] {
return this.all.filter(feed => !feed.isPinned) 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() { get pinnedFeedNames() {