From 2028446d03258111b319c2a926bc3c6649ac2e72 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Wed, 14 Dec 2022 13:05:36 +0100 Subject: [PATCH] Fix calculating feed badge --- Model/FeedModel.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Model/FeedModel.swift b/Model/FeedModel.swift index 3923abc8..98200ae1 100644 --- a/Model/FeedModel.swift +++ b/Model/FeedModel.swift @@ -109,13 +109,12 @@ final class FeedModel: ObservableObject, CacheModel { func calculateUnwatchedFeed() { guard let account = accounts.current, accounts.signedIn else { return } let feed = cacheModel.retrieveFeed(account: account) - guard !feed.isEmpty else { return } backgroundContext.perform { [weak self] in guard let self else { return } let watched = self.watchFetchRequestResult(feed, context: self.backgroundContext).filter { $0.finished } 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 guard let self else { return }