Default Smart Feeds and Accounts to being expanded in Sidebar
This commit is contained in:
parent
f16fd36e70
commit
9fa003d545
|
@ -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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue