mirror of
https://github.com/yattee/yattee.git
synced 2025-01-08 22:07:10 +00:00
Fix calculating feed badge
This commit is contained in:
parent
037d3a0481
commit
2028446d03
@ -109,13 +109,12 @@ final class FeedModel: ObservableObject, CacheModel {
|
|||||||
func calculateUnwatchedFeed() {
|
func calculateUnwatchedFeed() {
|
||||||
guard let account = accounts.current, accounts.signedIn else { return }
|
guard let account = accounts.current, accounts.signedIn else { return }
|
||||||
let feed = cacheModel.retrieveFeed(account: account)
|
let feed = cacheModel.retrieveFeed(account: account)
|
||||||
guard !feed.isEmpty else { return }
|
|
||||||
backgroundContext.perform { [weak self] in
|
backgroundContext.perform { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
let watched = self.watchFetchRequestResult(feed, context: self.backgroundContext).filter { $0.finished }
|
let watched = self.watchFetchRequestResult(feed, context: self.backgroundContext).filter { $0.finished }
|
||||||
let unwatched = feed.filter { video in !watched.contains { $0.videoID == video.videoID } }
|
let unwatched = feed.filter { video in !watched.contains { $0.videoID == video.videoID } }
|
||||||
let unwatchedCount = feed.count - watched.count
|
let unwatchedCount = max(0, feed.count - watched.count)
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
Loading…
Reference in New Issue
Block a user