Default Smart Feeds and Accounts to being expanded in Sidebar

This commit is contained in:
Maurice Parker 2020-07-04 09:18:56 -05:00
parent f16fd36e70
commit 9fa003d545
1 changed files with 12 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import Account
final class SidebarExpandedContainers: ObservableObject { final class SidebarExpandedContainers: ObservableObject {
@Published var expandedTable = Set<ContainerIdentifier>() @Published var expandedTable = [ContainerIdentifier: Bool]()
var objectDidChange = PassthroughSubject<Void, Never>() var objectDidChange = PassthroughSubject<Void, Never>()
var data: Data { var data: Data {
@ -23,21 +23,24 @@ final class SidebarExpandedContainers: ObservableObject {
} }
set { set {
let decoder = PropertyListDecoder() let decoder = PropertyListDecoder()
expandedTable = (try? decoder.decode(Set<ContainerIdentifier>.self, from: newValue)) ?? Set<ContainerIdentifier>() expandedTable = (try? decoder.decode([ContainerIdentifier: Bool].self, from: newValue)) ?? [ContainerIdentifier: Bool]()
} }
} }
subscript(_ containerID: ContainerIdentifier) -> Bool { subscript(_ containerID: ContainerIdentifier) -> Bool {
get { get {
return expandedTable.contains(containerID) if let result = expandedTable[containerID] {
return result
}
switch containerID {
case .smartFeedController, .account:
return true
default:
return false
}
} }
set(newValue) { set(newValue) {
if newValue { expandedTable[containerID] = newValue
expandedTable.insert(containerID)
} else {
expandedTable.remove(containerID)
}
objectDidChange.send()
} }
} }