diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index a74afc140..a61ca84d0 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -58,7 +58,7 @@ struct AppDefaults { static var windowState: [AnyHashable : Any]? { get { - UserDefaults.standard.object(forKey: Key.windowState) as? [AnyHashable : Any] + return UserDefaults.standard.object(forKey: Key.windowState) as? [AnyHashable : Any] } set { UserDefaults.standard.set(newValue, forKey: Key.windowState) diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index b3d637f51..2c8bdd75d 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -248,11 +248,8 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr // MARK: State Restoration func saveState(to state: inout [AnyHashable : Any]) { - var readArticlesFilterState = [[AnyHashable: AnyHashable]: Bool]() - for key in readFilterEnabledTable.keys { - readArticlesFilterState[key.userInfo] = readFilterEnabledTable[key] - } - state[UserInfoKey.readArticlesFilterState] = readArticlesFilterState + state[UserInfoKey.readArticlesFilterStateKeys] = readFilterEnabledTable.keys.compactMap { $0.userInfo } + state[UserInfoKey.readArticlesFilterStateValues] = readFilterEnabledTable.values.compactMap( { $0 }) if selectedArticles.count == 1 { state[UserInfoKey.articlePath] = selectedArticles.first!.pathUserInfo @@ -260,32 +257,37 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr } func restoreState(from state: [AnyHashable : Any]) { - if let readArticlesFilterState = state[UserInfoKey.readArticlesFilterState] as? [[AnyHashable: AnyHashable]: Bool] { - for key in readArticlesFilterState.keys { - if let feedIdentifier = FeedIdentifier(userInfo: key) { - readFilterEnabledTable[feedIdentifier] = readArticlesFilterState[key] - } + guard let readArticlesFilterStateKeys = state[UserInfoKey.readArticlesFilterStateKeys] as? [[AnyHashable: AnyHashable]], + let readArticlesFilterStateValues = state[UserInfoKey.readArticlesFilterStateValues] as? [Bool] else { + return + } + + for i in 0..