mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-05 03:37:41 +00:00
Get selected sidebar item and selected article before doing the state restoration, in case the process of pushing view controllers around overwrites the values in UserDefaults.
This commit is contained in:
1 parent
93f1dc5fe4
commit
6ce3bdadc7
1 file changed
+9
-6
@@ -384,6 +384,9 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
}
|
||||
|
||||
private func restoreWindowStateFromUserDefaults() {
|
||||
let selectedSidebarItem = AppDefaults.shared.selectedSidebarItem
|
||||
let selectedArticle = AppDefaults.shared.selectedArticle
|
||||
|
||||
// Restore containerExpandedWindowState from UserDefaults
|
||||
if let storedState = AppDefaults.shared.expandedContainers {
|
||||
expandedContainers.formUnion(storedState)
|
||||
@@ -399,20 +402,20 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
treeControllerDelegate.isReadFiltered = AppDefaults.shared.hideReadFeeds
|
||||
|
||||
// Restore selectedSidebarItem from UserDefaults
|
||||
if let feedIdentifier = AppDefaults.shared.selectedSidebarItem {
|
||||
restoreSelectedSidebarItem(feedIdentifier)
|
||||
if let selectedSidebarItem {
|
||||
restoreSelectedSidebarItem(selectedSidebarItem, selectedArticle)
|
||||
}
|
||||
}
|
||||
|
||||
private func restoreSelectedSidebarItem(_ feedIdentifier: FeedIdentifier) {
|
||||
guard let feedNode = nodeFor(feedID: feedIdentifier),
|
||||
private func restoreSelectedSidebarItem(_ selectedSidebarItem: FeedIdentifier, _ selectedArticle: ArticleSpecifier?) {
|
||||
guard let feedNode = nodeFor(feedID: selectedSidebarItem),
|
||||
let indexPath = indexPathFor(feedNode) else {
|
||||
return
|
||||
}
|
||||
selectFeed(indexPath: indexPath, animations: []) {
|
||||
// Restore selectedArticle from UserDefaults
|
||||
if let articleSpecifier = AppDefaults.shared.selectedArticle {
|
||||
self.restoreSelectedArticle(articleSpecifier)
|
||||
if let selectedArticle {
|
||||
self.restoreSelectedArticle(selectedArticle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user