File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ final class AppState {
151151
152152 // MARK: - Private
153153 private var isKeyHeld = false
154+ private var accessibilityWasGranted = false
154155
155156 var shortcutDisplayString : String {
156157 KeyCodeMapping . displayString (
@@ -217,12 +218,31 @@ final class AppState {
217218 showOnboarding = true
218219 }
219220
221+ accessibilityWasGranted = PermissionService . isAccessibilityGranted ( )
222+
220223 Task {
221224 await loadSelectedModel ( )
222225 if !groqAPIKey. isEmpty { await verifyAndFetchGroqModels ( ) }
223226 setupHotkey ( )
224227 await MainActor . run { startPersistentOverlay ( ) }
225228 }
229+
230+ startAccessibilityMonitor ( )
231+ }
232+
233+ private func startAccessibilityMonitor( ) {
234+ Timer . scheduledTimer ( withTimeInterval: 1.0 , repeats: true ) { [ weak self] timer in
235+ guard let self else { timer. invalidate ( ) ; return }
236+ let granted = PermissionService . isAccessibilityGranted ( )
237+ if granted && !self . accessibilityWasGranted {
238+ DispatchQueue . main. async {
239+ self . hotkeyService. stop ( )
240+ self . aiHotkeyService. stop ( )
241+ self . setupHotkey ( )
242+ }
243+ }
244+ self . accessibilityWasGranted = granted
245+ }
226246 }
227247
228248 func setupHotkey( ) {
You can’t perform that action at this time.
0 commit comments