Skip to content

Commit

Permalink
fix: working marking as read in 'all feeds'
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed Aug 18, 2023
1 parent 68be24c commit a09b825
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,29 @@ func (b Backend) articlesToSuccessMsg(items cache.SortableArticles) FetchArticle

// indexToItem resolves an index to an item.
func (b Backend) indexToItem(feedName string, index int) (*gofeed.Item, error) {
var articles cache.SortableArticles

switch feedName {
case rss.AllFeedsName:
return &b.Cache.GetArticlesBulk(rss.Default.GetAllURLs(), false)[index], nil
articles = b.Cache.GetArticlesBulk(rss.Default.GetAllURLs(), false)

case rss.DownloadedFeedsName:
return &b.Cache.GetDownloaded()[index], nil
articles = b.Cache.GetDownloaded()

default:
url, err := b.Rss.GetFeedURL(feedName)
if err != nil {
return nil, errors.New("getting the article url")
}

items, err := b.Cache.GetArticles(url, false)
articles, err = b.Cache.GetArticles(url, false)
if err != nil {
return nil, errors.New("fetching the article")
}

return &items[index], nil
}

sort.Sort(articles)
return &articles[index], nil
}

// betterDesc returns a styled item description.
Expand Down

0 comments on commit a09b825

Please sign in to comment.