Remove strong reference to Account that was preventing Accounts from being deallocated

This commit is contained in:
Maurice Parker 2019-05-22 15:08:22 -05:00
parent c422b4b82c
commit 5d1c7d08ac
1 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ final class SmartFeed: PseudoFeed {
#endif
private let delegate: SmartFeedDelegate
private var unreadCounts = [Account: Int]()
private var unreadCounts = [String: Int]()
init(delegate: SmartFeedDelegate) {
self.delegate = delegate
@ -74,14 +74,14 @@ private extension SmartFeed {
func fetchUnreadCount(for account: Account) {
delegate.fetchUnreadCount(for: account) { (accountUnreadCount) in
self.unreadCounts[account] = accountUnreadCount
self.unreadCounts[account.accountID] = accountUnreadCount
self.updateUnreadCount()
}
}
func updateUnreadCount() {
unreadCount = AccountManager.shared.activeAccounts.reduce(0) { (result, account) -> Int in
if let oneUnreadCount = unreadCounts[account] {
if let oneUnreadCount = unreadCounts[account.accountID] {
return result + oneUnreadCount
}
return result