From 3e53dfbfc6e7bcf59af3345e1db7b312fbe46b9e Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 9 Jun 2024 22:13:47 -0700 Subject: [PATCH] Make SmartFeed MainActor. --- Shared/SmartFeeds/SmartFeed.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Shared/SmartFeeds/SmartFeed.swift b/Shared/SmartFeeds/SmartFeed.swift index ab3513057..219f5c866 100644 --- a/Shared/SmartFeeds/SmartFeed.swift +++ b/Shared/SmartFeeds/SmartFeed.swift @@ -14,7 +14,7 @@ import Database import Core import Images -final class SmartFeed: PseudoFeed { +@MainActor final class SmartFeed: PseudoFeed { var account: Account? = nil @@ -60,19 +60,19 @@ final class SmartFeed: PseudoFeed { private let delegate: SmartFeedDelegate private var unreadCounts = [String: Int]() - @MainActor init(delegate: SmartFeedDelegate) { + init(delegate: SmartFeedDelegate) { self.delegate = delegate NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) queueFetchUnreadCounts() // Fetch unread count at startup } - @MainActor @objc func unreadCountDidChange(_ note: Notification) { + @objc func unreadCountDidChange(_ note: Notification) { if note.object is AppDelegate { queueFetchUnreadCounts() } } - @MainActor func fetchUnreadCounts() async throws { + func fetchUnreadCounts() async throws { let activeAccounts = AccountManager.shared.activeAccounts @@ -110,12 +110,12 @@ extension SmartFeed: ArticleFetcher { private extension SmartFeed { - @MainActor func queueFetchUnreadCounts() { + func queueFetchUnreadCounts() { postponingBlock.runInFuture() } - @MainActor func fetchUnreadCount(for account: Account) async { + func fetchUnreadCount(for account: Account) async { let unreadCount = await delegate.unreadCount(account: account) unreadCounts[account.accountID] = unreadCount @@ -123,7 +123,7 @@ private extension SmartFeed { updateUnreadCount() } - @MainActor func updateUnreadCount() { + func updateUnreadCount() { var unread = 0 for account in AccountManager.shared.activeAccounts {