Make AccountManager and ArticleThemesManager self-initing.

This commit is contained in:
Brent Simmons
2025-02-01 19:37:59 -08:00
parent 8a123a0734
commit e9fc4c09ed
5 changed files with 16 additions and 23 deletions

View File

@@ -18,7 +18,7 @@ import RSDatabase
public final class AccountManager: UnreadCountProvider {
public static var shared: AccountManager!
public static let shared = AccountManager()
public static let netNewsWireNewsURL = "https://netnewswire.blog/feed.xml"
private static let jsonNetNewsWireNewsURL = "https://netnewswire.blog/feed.json"
@@ -93,7 +93,10 @@ public final class AccountManager: UnreadCountProvider {
public let combinedRefreshProgress = CombinedRefreshProgress()
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "AccountManager")
public init(accountsFolder: String) {
public init() {
let accountsFolderURL = AppConfig.dataSubfolder(named: "Accounts")
let accountsFolder = accountsFolderURL.path
self.accountsFolder = accountsFolder
// The local "On My Mac" account must always exist, even if it's empty.
@@ -101,8 +104,7 @@ public final class AccountManager: UnreadCountProvider {
do {
try FileManager.default.createDirectory(atPath: localAccountFolder, withIntermediateDirectories: true, attributes: nil)
} catch {
assertionFailure("Could not create folder for OnMyMac account.")
abort()
fatalError("Could not create folder for OnMyMac account.")
}
defaultAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: defaultAccountIdentifier)

View File

@@ -50,11 +50,7 @@ extension Feed {
public extension Article {
var account: Account? {
// The force unwrapped shared instance was crashing Account.framework unit tests.
guard let manager = AccountManager.shared else {
return nil
}
return manager.existingAccount(with: accountID)
AccountManager.shared.existingAccount(with: accountID)
}
var feed: Feed? {