From 7279c87be130e1f7c72dace6736e39810ee6aacb Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Thu, 2 Nov 2023 18:27:12 +0100 Subject: [PATCH] Fix updating the colors when the groups color changes --- App/Sources/Core/KeyboardCowboy.swift | 1 + App/Sources/UI/Coordinators/ContentCoordinator.swift | 6 ++++-- App/Sources/UI/Coordinators/DetailCoordinator.swift | 8 ++++++++ App/Sources/UI/Coordinators/SidebarCoordinator.swift | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/App/Sources/Core/KeyboardCowboy.swift b/App/Sources/Core/KeyboardCowboy.swift index 1a4cb9db..f8af78db 100644 --- a/App/Sources/Core/KeyboardCowboy.swift +++ b/App/Sources/Core/KeyboardCowboy.swift @@ -223,6 +223,7 @@ struct KeyboardCowboy: App { EditWorkflowGroupWindow(core.contentStore) { context in core.sidebarCoordinator.handle(context) core.contentCoordinator.handle(context) + core.detailCoordinator.handle(context) } .windowResizability(.contentSize) .windowStyle(.hiddenTitleBar) diff --git a/App/Sources/UI/Coordinators/ContentCoordinator.swift b/App/Sources/UI/Coordinators/ContentCoordinator.swift index 5d8cafb6..07e9f5f6 100644 --- a/App/Sources/UI/Coordinators/ContentCoordinator.swift +++ b/App/Sources/UI/Coordinators/ContentCoordinator.swift @@ -75,9 +75,11 @@ final class ContentCoordinator { switch context { case .add(let workflowGroup): render([workflowGroup.id]) + contentSelectionManager.selectedColor = Color(hex: workflowGroup.color) case .edit(let workflowGroup): - let group = SidebarMapper.map(workflowGroup, applicationStore: applicationStore) - groupPublisher.publish(group) + let workflowGroup = SidebarMapper.map(workflowGroup, applicationStore: applicationStore) + contentSelectionManager.selectedColor = Color(hex: workflowGroup.color) + groupPublisher.publish(workflowGroup) render([workflowGroup.id]) } } diff --git a/App/Sources/UI/Coordinators/DetailCoordinator.swift b/App/Sources/UI/Coordinators/DetailCoordinator.swift index f3b7b909..e35b4c0a 100644 --- a/App/Sources/UI/Coordinators/DetailCoordinator.swift +++ b/App/Sources/UI/Coordinators/DetailCoordinator.swift @@ -47,6 +47,14 @@ final class DetailCoordinator { enableInjection(self, selector: #selector(injected(_:))) } + func handle(_ context: EditWorkflowGroupWindow.Context) { + switch context { + case .add(let workflowGroup), .edit(let workflowGroup): + contentSelectionManager.selectedColor = Color(hex: workflowGroup.color) + commandSelectionManager.selectedColor = Color(hex: workflowGroup.color) + } + } + func handle(_ action: SidebarView.Action) { switch action { case .refresh, .updateConfiguration, .openScene, .addConfiguration, .deleteConfiguraiton: diff --git a/App/Sources/UI/Coordinators/SidebarCoordinator.swift b/App/Sources/UI/Coordinators/SidebarCoordinator.swift index 04ffc811..6ddb9280 100644 --- a/App/Sources/UI/Coordinators/SidebarCoordinator.swift +++ b/App/Sources/UI/Coordinators/SidebarCoordinator.swift @@ -39,9 +39,11 @@ final class SidebarCoordinator { case .add(let group): groupId = group.id store.add(group) + selectionManager.selectedColor = Color(hex: group.color) case .edit(let group): groupId = group.id store.updateGroups([group]) + selectionManager.selectedColor = Color(hex: group.color) } selectionManager.publish([groupId]) if storeWasEmpty {