Remove redundant MainActor marks.

This commit is contained in:
Brent Simmons 2024-03-25 23:13:21 -07:00
parent 455f60a224
commit c18bb074d0
1 changed files with 13 additions and 15 deletions

View File

@ -13,8 +13,6 @@ import ArticlesDatabase
import Database import Database
import Secrets import Secrets
// Main thread only.
@MainActor public final class AccountManager: UnreadCountProvider { @MainActor public final class AccountManager: UnreadCountProvider {
@MainActor public static var shared: AccountManager! @MainActor public static var shared: AccountManager!
@ -78,7 +76,7 @@ import Secrets
return lastArticleFetchEndTime return lastArticleFetchEndTime
} }
@MainActor public func existingActiveAccount(forDisplayName displayName: String) -> Account? { public func existingActiveAccount(forDisplayName displayName: String) -> Account? {
return AccountManager.shared.activeAccounts.first(where: { $0.nameForDisplay == displayName }) return AccountManager.shared.activeAccounts.first(where: { $0.nameForDisplay == displayName })
} }
@ -96,7 +94,7 @@ import Secrets
return CombinedRefreshProgress(downloadProgressArray: downloadProgressArray) return CombinedRefreshProgress(downloadProgressArray: downloadProgressArray)
} }
@MainActor public init(accountsFolder: String, secretsProvider: SecretsProvider) { public init(accountsFolder: String, secretsProvider: SecretsProvider) {
self.accountsFolder = accountsFolder self.accountsFolder = accountsFolder
self.secretsProvider = secretsProvider self.secretsProvider = secretsProvider
@ -127,7 +125,7 @@ import Secrets
// MARK: - API // MARK: - API
@MainActor public func createAccount(type: AccountType) -> Account { public func createAccount(type: AccountType) -> Account {
let accountID = type == .cloudKit ? "iCloud" : UUID().uuidString let accountID = type == .cloudKit ? "iCloud" : UUID().uuidString
let accountFolder = (accountsFolder as NSString).appendingPathComponent("\(type.rawValue)_\(accountID)") let accountFolder = (accountsFolder as NSString).appendingPathComponent("\(type.rawValue)_\(accountID)")
@ -148,7 +146,7 @@ import Secrets
return account return account
} }
@MainActor public func deleteAccount(_ account: Account) { public func deleteAccount(_ account: Account) {
guard !account.refreshInProgress else { guard !account.refreshInProgress else {
return return
} }
@ -216,7 +214,7 @@ import Secrets
accounts.forEach { $0.resume() } accounts.forEach { $0.resume() }
} }
@MainActor public func receiveRemoteNotification(userInfo: [AnyHashable : Any]) async { public func receiveRemoteNotification(userInfo: [AnyHashable : Any]) async {
for account in activeAccounts { for account in activeAccounts {
await account.receiveRemoteNotification(userInfo: userInfo) await account.receiveRemoteNotification(userInfo: userInfo)
@ -329,7 +327,7 @@ import Secrets
// These fetch articles from active accounts and return a merged Set<Article>. // These fetch articles from active accounts and return a merged Set<Article>.
@MainActor public func fetchArticles(fetchType: FetchType) async throws -> Set<Article> { public func fetchArticles(fetchType: FetchType) async throws -> Set<Article> {
guard activeAccounts.count > 0 else { guard activeAccounts.count > 0 else {
return Set<Article>() return Set<Article>()
@ -355,7 +353,7 @@ import Secrets
// MARK: - Notifications // MARK: - Notifications
@MainActor @objc func unreadCountDidInitialize(_ notification: Notification) { @objc func unreadCountDidInitialize(_ notification: Notification) {
guard let _ = notification.object as? Account else { guard let _ = notification.object as? Account else {
return return
} }
@ -364,14 +362,14 @@ import Secrets
} }
} }
@MainActor @objc dynamic func unreadCountDidChange(_ notification: Notification) { @objc dynamic func unreadCountDidChange(_ notification: Notification) {
guard let _ = notification.object as? Account else { guard let _ = notification.object as? Account else {
return return
} }
updateUnreadCount() updateUnreadCount()
} }
@MainActor @objc func accountStateDidChange(_ notification: Notification) { @objc func accountStateDidChange(_ notification: Notification) {
updateUnreadCount() updateUnreadCount()
} }
} }
@ -380,15 +378,15 @@ import Secrets
private extension AccountManager { private extension AccountManager {
@MainActor func updateUnreadCount() { func updateUnreadCount() {
unreadCount = calculateUnreadCount(activeAccounts) unreadCount = calculateUnreadCount(activeAccounts)
} }
@MainActor func loadAccount(_ accountSpecifier: AccountSpecifier) -> Account? { func loadAccount(_ accountSpecifier: AccountSpecifier) -> Account? {
return Account(dataFolder: accountSpecifier.folderPath, type: accountSpecifier.type, accountID: accountSpecifier.identifier, secretsProvider: secretsProvider) return Account(dataFolder: accountSpecifier.folderPath, type: accountSpecifier.type, accountID: accountSpecifier.identifier, secretsProvider: secretsProvider)
} }
@MainActor func loadAccount(_ filename: String) -> Account? { func loadAccount(_ filename: String) -> Account? {
let folderPath = (accountsFolder as NSString).appendingPathComponent(filename) let folderPath = (accountsFolder as NSString).appendingPathComponent(filename)
if let accountSpecifier = AccountSpecifier(folderPath: folderPath) { if let accountSpecifier = AccountSpecifier(folderPath: folderPath) {
return loadAccount(accountSpecifier) return loadAccount(accountSpecifier)
@ -396,7 +394,7 @@ private extension AccountManager {
return nil return nil
} }
@MainActor func readAccountsFromDisk() { func readAccountsFromDisk() {
var filenames: [String]? var filenames: [String]?
do { do {