From 0424ba3bb778631aded4e0fed76645d336006feb Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 23 Sep 2019 10:27:17 -0500 Subject: [PATCH] Make unread counts show up for new feeds added by share extension --- Frameworks/Account/Account.swift | 5 +++-- Frameworks/Account/FeedMetadataFile.swift | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index f3a2ed70e..9f0a7f88e 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -184,7 +184,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, typealias FeedMetadataDictionary = [String: FeedMetadata] var feedMetadata = FeedMetadataDictionary() - private var startingUp = true + var startingUp = true public var unreadCount = 0 { didSet { @@ -406,10 +406,11 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } - public func resetAllFeedMetadata() { + public func resetFeedMetadataAndUnreadCounts() { for feed in flattenedFeeds() { feed.metadata = feedMetadata(feedURL: feed.url, feedID: feed.feedID) } + fetchAllUnreadCounts() NotificationCenter.default.post(name: .FeedMetadataDidChange, object: self, userInfo: nil) } diff --git a/Frameworks/Account/FeedMetadataFile.swift b/Frameworks/Account/FeedMetadataFile.swift index e9314a4f0..d56f2a749 100644 --- a/Frameworks/Account/FeedMetadataFile.swift +++ b/Frameworks/Account/FeedMetadataFile.swift @@ -49,7 +49,9 @@ private extension FeedMetadataFile { let decoder = PropertyListDecoder() account.feedMetadata = (try? decoder.decode(Account.FeedMetadataDictionary.self, from: fileData)) ?? Account.FeedMetadataDictionary() account.feedMetadata.values.forEach { $0.delegate = account } - account.resetAllFeedMetadata() + if !account.startingUp { + account.resetFeedMetadataAndUnreadCounts() + } } })