diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 7284adbf9..7f9918455 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -124,7 +124,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, self.settingsFile = settingsFile self.dataFolder = dataFolder self.hashValue = accountID.hashValue - + let databaseFilePath = (dataFolder as NSString).appendingPathComponent("DB.sqlite3") self.database = Database(databaseFilePath: databaseFilePath, accountID: accountID) @@ -142,6 +142,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, self.updateUnreadCount() self.fetchAllUnreadCounts() } + + self.delegate.accountDidInitialize(self) } // MARK: - API diff --git a/Frameworks/Account/AccountDelegate.swift b/Frameworks/Account/AccountDelegate.swift index 9a28022b8..5da492f37 100644 --- a/Frameworks/Account/AccountDelegate.swift +++ b/Frameworks/Account/AccountDelegate.swift @@ -18,6 +18,10 @@ public protocol AccountDelegate { func refreshAll(for: Account) + // Called at the end of account’s init method. + + func accountDidInitialize(_ account: Account) + // Called at the end of initializing an Account using data from disk. // Delegate has complete control over what goes in userInfo and what it means. // Called even if userInfo is nil, since the delegate might have other diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index e71326e57..8083562e6 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -26,12 +26,16 @@ final class FeedbinAccountDelegate: AccountDelegate { // MARK: Disk - func update(account: Account, withUserInfo: NSDictionary?) { + func accountDidInitialize(_ account: Account) { // TODO: add username to account name account.nameForDisplay = NSLocalizedString("Feedbin", comment: "Feedbin Account Name") } + func update(account: Account, withUserInfo: NSDictionary?) { + + } + func userInfo(for: Account) -> NSDictionary? { // TODO: save username diff --git a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift index 50cbb48b4..cdd636101 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift @@ -25,11 +25,16 @@ final class LocalAccountDelegate: AccountDelegate { refresher.refreshFeeds(account.flattenedFeeds()) } + func accountDidInitialize(_ account: Account) { + + account.nameForDisplay = NSLocalizedString("On My Mac", comment: "Local Account Name") + } + // MARK: Disk func update(account: Account, withUserInfo: NSDictionary?) { - account.nameForDisplay = NSLocalizedString("On My Mac", comment: "Local Account Name") + } func userInfo(for: Account) -> NSDictionary? {