Fix scene selection state

This commit is contained in:
Shadow
2026-02-07 13:55:59 -06:00
committed by Shadow
parent bda9995ed8
commit 66d84d91c2
3 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -73,7 +73,7 @@ struct ApiDocsView: View {
Text("Scene Filter")
.font(.headline)
Picker("Scene", selection: $selectedSceneId) {
Text("All scenes").tag(Optional<UUID>.none)
Text("All scenes").tag(Optional(SceneSelection.allScenesId))
ForEach(scenes, id: \.uniqueIdentifier) { scene in
Text(scene.name).tag(Optional(scene.uniqueIdentifier))
}
@@ -89,7 +89,7 @@ struct ApiDocsView: View {
}
private var selectedScene: HMActionSet? {
guard let selectedSceneId else { return nil }
guard let selectedSceneId, selectedSceneId != SceneSelection.allScenesId else { return nil }
return scenes.first { $0.uniqueIdentifier == selectedSceneId }
}
+4
View File
@@ -58,3 +58,7 @@ struct CasaScene {
let type: String
let isExecuting: Bool
}
enum SceneSelection {
static let allScenesId = UUID(uuidString: "00000000-0000-0000-0000-000000000001")!
}
+2 -3
View File
@@ -128,7 +128,6 @@ private enum MainSelection: Hashable {
private struct SidebarView: View {
static let allScenesId = UUID(uuidString: "00000000-0000-0000-0000-000000000001")!
@EnvironmentObject private var model: CasaAppModel
@ObservedObject private var settings = CasaSettings.shared
let accessories: [HMAccessory]
@@ -183,10 +182,10 @@ private struct SidebarView: View {
Section("Scenes") {
Button {
sceneSelection = SidebarView.allScenesId
sceneSelection = SceneSelection.allScenesId
accessorySelection = nil
} label: {
sidebarRow(title: "All scenes", isSelected: sceneSelection == SidebarView.allScenesId)
sidebarRow(title: "All scenes", isSelected: sceneSelection == SceneSelection.allScenesId)
}
.buttonStyle(.plain)