From 2a7c51abda0ec73b9e6d750c59f41046001cd1a8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Tue, 13 Dec 2022 20:15:54 +0100 Subject: [PATCH] Don't perform feed operations if not signed in --- Model/FeedModel.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Model/FeedModel.swift b/Model/FeedModel.swift index 76bd966f..3923abc8 100644 --- a/Model/FeedModel.swift +++ b/Model/FeedModel.swift @@ -107,7 +107,7 @@ final class FeedModel: ObservableObject, CacheModel { } func calculateUnwatchedFeed() { - guard let account = accounts.current else { return } + 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 @@ -130,7 +130,7 @@ final class FeedModel: ObservableObject, CacheModel { } func markAllFeedAsWatched() { - guard let account = accounts.current else { return } + guard let account = accounts.current, accounts.signedIn else { return } let mark = { [weak self] in self?.backgroundContext.perform { [weak self] in @@ -149,7 +149,7 @@ final class FeedModel: ObservableObject, CacheModel { } var canMarkAllFeedAsWatched: Bool { - guard let account = accounts.current else { return false } + guard let account = accounts.current, accounts.signedIn else { return false } return (unwatched[account] ?? 0) > 0 } @@ -183,7 +183,7 @@ final class FeedModel: ObservableObject, CacheModel { } func playUnwatchedFeed() { - guard let account = accounts.current else { return } + guard let account = accounts.current, accounts.signedIn else { return } let videos = cacheModel.retrieveFeed(account: account) guard !videos.isEmpty else { return } @@ -208,7 +208,7 @@ final class FeedModel: ObservableObject, CacheModel { } var canPlayUnwatchedFeed: Bool { - guard let account = accounts.current else { return false } + guard let account = accounts.current, accounts.signedIn else { return false } return (unwatched[account] ?? 0) > 0 } @@ -225,7 +225,7 @@ final class FeedModel: ObservableObject, CacheModel { } private func loadCachedFeed(_ onCompletion: @escaping () -> Void = {}) { - guard let account = accounts.current else { return } + guard let account = accounts.current, accounts.signedIn else { return } let cache = cacheModel.retrieveFeed(account: account) if !cache.isEmpty { DispatchQueue.main.async(qos: .userInteractive) { [weak self] in