mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-04 03:08:43 +00:00
Make containerExpandedWindowState typed as Set<ContainerIdentifier>?.
This commit is contained in:
1 parent
0b9ec94cf8
commit
ea6eedb864
2 files changed
+16
-16
No files matched your search
+12
-3
@@ -287,12 +287,21 @@ final class AppDefaults {
|
||||
}
|
||||
}
|
||||
|
||||
var containerExpandedWindowState: [[String: String]]? {
|
||||
var containerExpandedWindowState: Set<ContainerIdentifier>? {
|
||||
get {
|
||||
UserDefaults.standard.array(forKey: Key.containerExpandedWindowState) as? [[String: String]]
|
||||
guard let rawIdentifiers = UserDefaults.standard.array(forKey: Key.containerExpandedWindowState) as? [[String: String]] else {
|
||||
return nil
|
||||
}
|
||||
let containerIdentifiers = rawIdentifiers.compactMap { ContainerIdentifier(userInfo: $0) }
|
||||
return Set(containerIdentifiers)
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.set(newValue, forKey: Key.containerExpandedWindowState)
|
||||
guard let newValue, !newValue.isEmpty else {
|
||||
UserDefaults.standard.set([String: String](), forKey: Key.containerExpandedWindowState)
|
||||
return
|
||||
}
|
||||
let containerIdentifierUserInfos = newValue.compactMap { $0.userInfo }
|
||||
UserDefaults.standard.set(containerIdentifierUserInfos, forKey: Key.containerExpandedWindowState)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -336,7 +336,8 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
}
|
||||
return stringDict.isEmpty ? nil : stringDict
|
||||
}
|
||||
AppDefaults.shared.containerExpandedWindowState = convertedState
|
||||
let containerIdentifiers = convertedState.compactMap { ContainerIdentifier(userInfo: $0) }
|
||||
AppDefaults.shared.containerExpandedWindowState = Set(containerIdentifiers)
|
||||
}
|
||||
|
||||
// readArticlesFilterState
|
||||
@@ -378,8 +379,7 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
private func restoreWindowStateFromUserDefaults() {
|
||||
// Restore containerExpandedWindowState from UserDefaults
|
||||
if let storedState = AppDefaults.shared.containerExpandedWindowState {
|
||||
let containerIdentifiers = storedState.compactMap { ContainerIdentifier(userInfo: $0) }
|
||||
expandedTable = Set(containerIdentifiers)
|
||||
expandedTable.formUnion(storedState)
|
||||
}
|
||||
|
||||
// Restore readArticlesFilterState from UserDefaults
|
||||
@@ -1734,16 +1734,7 @@ private extension SceneCoordinator {
|
||||
}
|
||||
|
||||
private func saveExpandedTableToUserDefaults() {
|
||||
let state = expandedTable.compactMap { containerID -> [String: String]? in
|
||||
var stringDict = [String: String]()
|
||||
for (key, value) in containerID.userInfo {
|
||||
if let keyString = key as? String, let valueString = value as? String {
|
||||
stringDict[keyString] = valueString
|
||||
}
|
||||
}
|
||||
return stringDict.isEmpty ? nil : stringDict
|
||||
}
|
||||
AppDefaults.shared.containerExpandedWindowState = state
|
||||
AppDefaults.shared.containerExpandedWindowState = expandedTable
|
||||
}
|
||||
|
||||
private func saveReadFilterEnabledTableToUserDefaults() {
|
||||
|
||||
Reference in new issue
Block a user