diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index c16755a5a..ac9e59e23 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -330,9 +330,33 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { func restoreWindowState(_ activity: NSUserActivity?) { if let activity = activity, let windowState = activity.userInfo?[UserInfoKey.windowState] as? [AnyHashable: Any] { - restoreWindowState(windowState) + + if let containerExpandedWindowState = windowState[UserInfoKey.containerExpandedWindowState] as? [[AnyHashable: AnyHashable]] { + let containerIdentifers = containerExpandedWindowState.compactMap( { ContainerIdentifier(userInfo: $0) }) + expandedTable = Set(containerIdentifers) + } + + if let readArticlesFilterState = windowState[UserInfoKey.readArticlesFilterState] as? [[AnyHashable: AnyHashable]: Bool] { + for key in readArticlesFilterState.keys { + if let feedIdentifier = FeedIdentifier(userInfo: key) { + readFilterEnabledTable[feedIdentifier] = readArticlesFilterState[key] + } + } + } + + rebuildBackingStores(initialLoad: true) + + // You can't assign the Feeds Read Filter until we've built the backing stores at least once or there is nothing + // for state restoration to work with while we are waiting for the unread counts to initialize. + if let readFeedsFilterState = windowState[UserInfoKey.readFeedsFilterState] as? Bool { + treeControllerDelegate.isReadFiltered = readFeedsFilterState + } + + } else { + + rebuildBackingStores(initialLoad: true) + } - rebuildBackingStores(initialLoad: true) } func handle(_ activity: NSUserActivity) { @@ -1788,23 +1812,6 @@ private extension SceneCoordinator { ] } - func restoreWindowState(_ windowState: [AnyHashable: Any]) { - if let readFeedsFilterState = windowState[UserInfoKey.readFeedsFilterState] as? Bool { - treeControllerDelegate.isReadFiltered = readFeedsFilterState - } - if let containerExpandedWindowState = windowState[UserInfoKey.containerExpandedWindowState] as? [[AnyHashable: AnyHashable]] { - let containerIdentifers = containerExpandedWindowState.compactMap( { ContainerIdentifier(userInfo: $0) }) - expandedTable = Set(containerIdentifers) - } - if let readArticlesFilterState = windowState[UserInfoKey.readArticlesFilterState] as? [[AnyHashable: AnyHashable]: Bool] { - for key in readArticlesFilterState.keys { - if let feedIdentifier = FeedIdentifier(userInfo: key) { - readFilterEnabledTable[feedIdentifier] = readArticlesFilterState[key] - } - } - } - } - func handleSelectFeed(_ userInfo: [AnyHashable : Any]?) { guard let userInfo = userInfo, let feedIdentifierUserInfo = userInfo[UserInfoKey.feedIdentifier] as? [AnyHashable : AnyHashable],