Add AccountDelegate.accountDidInitialize method, so that the delegate can set the account’s nameForDisplay before anything else happens. Fix #247.
This commit is contained in:
parent
1d9a1c0c67
commit
23769bc391
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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? {
|
||||
|
|
Loading…
Reference in New Issue