Fix removal of old lists from saved feeds (#1823)
* Fix removal of old lists from saved feeds * Fix saved feed removal race condition
This commit is contained in:
		
							parent
							
								
									a4baf14e4b
								
							
						
					
					
						commit
						7ffbee18b5
					
				
					 3 changed files with 20 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue