Clean up deleted and inactive accounts from Smartfeeds. Issue #1205

This commit is contained in:
Maurice Parker
2019-11-01 19:26:32 -05:00
parent 6b2de18557
commit 68cb9258c5

View File

@@ -51,8 +51,23 @@ final class SmartFeed: PseudoFeed {
}
@objc func fetchUnreadCounts() {
AccountManager.shared.activeAccounts.forEach { self.fetchUnreadCount(for: $0) }
let activeAccounts = AccountManager.shared.activeAccounts
// Remove any accounts that are no longer active or have been deleted
let activeAccountIDs = activeAccounts.map { $0.accountID }
unreadCounts.keys.forEach { accountID in
if !activeAccountIDs.contains(accountID) {
unreadCounts.removeValue(forKey: accountID)
}
}
if activeAccounts.isEmpty {
updateUnreadCount()
} else {
activeAccounts.forEach { self.fetchUnreadCount(for: $0) }
}
}
}
extension SmartFeed: ArticleFetcher {