(to view: Content)
| 432 | } |
| 433 | |
| 434 | private func applyShortcutStateChanges<Content: View>(to view: Content) -> some View { |
| 435 | view |
| 436 | .onAppear { |
| 437 | self.handleContentAppear() |
| 438 | } |
| 439 | .onChange(of: self.accessibilityEnabled) { _, enabled in |
| 440 | if enabled { |
| 441 | self.finishAccessibilityPermissionFlow() |
| 442 | } |
| 443 | |
| 444 | if enabled && self.hotkeyManager != nil && !self.hotkeyManagerInitialized { |
| 445 | DebugLogger.shared.debug("Accessibility enabled, reinitializing hotkey manager", source: "ContentView") |
| 446 | self.hotkeyManager?.reinitialize() |
| 447 | } |
| 448 | } |
| 449 | .onChange(of: self.selectedModel) { _, newValue in |
| 450 | if newValue != "__ADD_MODEL__" { |
| 451 | self.selectedModelByProvider[self.currentProvider] = newValue |
| 452 | SettingsStore.shared.selectedModelByProvider = self.selectedModelByProvider |
| 453 | } |
| 454 | } |
| 455 | .onChange(of: self.selectedProviderID) { _, newValue in |
| 456 | SettingsStore.shared.selectedProviderID = newValue |
| 457 | } |
| 458 | .onChange(of: self.activeShortcutRecordingTarget) { _, _ in |
| 459 | self.hotkeyManager?.resetModifierOnlyShortcutTracking() |
| 460 | } |
| 461 | .onChange(of: self.commandModeHotkeyShortcut) { _, newValue in |
| 462 | SettingsStore.shared.commandModeHotkeyShortcut = newValue |
| 463 | self.hotkeyManager?.updateCommandModeShortcut(newValue) |
| 464 | } |
| 465 | .onChange(of: self.isPromptModeShortcutEnabled) { newValue in |
| 466 | self.handlePromptShortcutEnabledChange(newValue) |
| 467 | } |
| 468 | .onChange(of: self.isCommandModeShortcutEnabled) { newValue in |
| 469 | self.handleCommandShortcutEnabledChange(newValue) |
| 470 | } |
| 471 | .onChange(of: self.isRewriteModeShortcutEnabled) { newValue in |
| 472 | self.handleRewriteShortcutEnabledChange(newValue) |
| 473 | } |
| 474 | .onChange(of: self.pasteLastTranscriptionHotkeyShortcut) { _, newValue in |
| 475 | // The hotkey manager reads this value live from SettingsStore, so persisting is enough. |
| 476 | SettingsStore.shared.pasteLastTranscriptionHotkeyShortcut = newValue |
| 477 | } |
| 478 | .onChange(of: self.isPasteLastTranscriptionShortcutEnabled) { newValue in |
| 479 | self.handlePasteLastTranscriptionShortcutEnabledChange(newValue) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | private func handlePasteLastTranscriptionShortcutEnabledChange(_ isEnabled: Bool) { |
| 484 | SettingsStore.shared.pasteLastTranscriptionShortcutEnabled = isEnabled |
no test coverage detected