Make unread counts show up for new feeds added by share extension

This commit is contained in:
Maurice Parker 2019-09-23 10:27:17 -05:00
parent 6f9d3953f1
commit 0424ba3bb7
2 changed files with 6 additions and 3 deletions

View File

@ -184,7 +184,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
typealias FeedMetadataDictionary = [String: FeedMetadata] typealias FeedMetadataDictionary = [String: FeedMetadata]
var feedMetadata = FeedMetadataDictionary() var feedMetadata = FeedMetadataDictionary()
private var startingUp = true var startingUp = true
public var unreadCount = 0 { public var unreadCount = 0 {
didSet { didSet {
@ -406,10 +406,11 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
} }
public func resetAllFeedMetadata() { public func resetFeedMetadataAndUnreadCounts() {
for feed in flattenedFeeds() { for feed in flattenedFeeds() {
feed.metadata = feedMetadata(feedURL: feed.url, feedID: feed.feedID) feed.metadata = feedMetadata(feedURL: feed.url, feedID: feed.feedID)
} }
fetchAllUnreadCounts()
NotificationCenter.default.post(name: .FeedMetadataDidChange, object: self, userInfo: nil) NotificationCenter.default.post(name: .FeedMetadataDidChange, object: self, userInfo: nil)
} }

View File

@ -49,7 +49,9 @@ private extension FeedMetadataFile {
let decoder = PropertyListDecoder() let decoder = PropertyListDecoder()
account.feedMetadata = (try? decoder.decode(Account.FeedMetadataDictionary.self, from: fileData)) ?? Account.FeedMetadataDictionary() account.feedMetadata = (try? decoder.decode(Account.FeedMetadataDictionary.self, from: fileData)) ?? Account.FeedMetadataDictionary()
account.feedMetadata.values.forEach { $0.delegate = account } account.feedMetadata.values.forEach { $0.delegate = account }
account.resetAllFeedMetadata() if !account.startingUp {
account.resetFeedMetadataAndUnreadCounts()
}
} }
}) })