diff --git a/ShhShell/Info.plist b/ShhShell/Info.plist index 06d521d..6e66e9e 100644 --- a/ShhShell/Info.plist +++ b/ShhShell/Info.plist @@ -22,5 +22,9 @@ JetBrainsMonoNerdFontMono-Italic.ttf JetBrainsMonoNerdFontMono-BoldItalic.ttf + UIBackgroundModes + + location + diff --git a/ShhShell/Misc/Backgrounder.swift b/ShhShell/Misc/Backgrounder.swift index e6161b4..4b07b3d 100644 --- a/ShhShell/Misc/Backgrounder.swift +++ b/ShhShell/Misc/Backgrounder.swift @@ -23,6 +23,7 @@ class Backgrounder: NSObject, CLLocationManagerDelegate, ObservableObject { } func startBgTracking() { +// guard mana manager.allowsBackgroundLocationUpdates = true manager.pausesLocationUpdatesAutomatically = false manager.startMonitoringSignificantLocationChanges() @@ -53,6 +54,6 @@ class Backgrounder: NSObject, CLLocationManagerDelegate, ObservableObject { } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { - print("tracking started yay") + print("tracking started fr") } } diff --git a/ShhShell/Views/Terminal/ShellTabView.swift b/ShhShell/Views/Terminal/ShellTabView.swift index 5b57c32..0f0f9d9 100644 --- a/ShhShell/Views/Terminal/ShellTabView.swift +++ b/ShhShell/Views/Terminal/ShellTabView.swift @@ -149,12 +149,6 @@ struct ShellTabView: View { } } .frame(height: 30) - .onDisappear { - UIApplication.shared.isIdleTimerDisabled = false - if container.sessions.isEmpty { - Backgrounder.shared.stopBgTracking() - } - } .onAppear { if selectedID == nil { if let handler { @@ -163,10 +157,6 @@ struct ShellTabView: View { dismiss() } } - UIApplication.shared.isIdleTimerDisabled = hostsManager.settings.caffeinate - if hostsManager.settings.locationPersist { - Backgrounder.shared.startBgTracking() - } } } @@ -177,6 +167,12 @@ struct ShellTabView: View { handler: session.handler, hostsManager: hostsManager ) + .onAppear { + UIApplication.shared.isIdleTimerDisabled = hostsManager.settings.caffeinate + if hostsManager.settings.locationPersist { + Backgrounder.shared.startBgTracking() + } + } .onDisappear { if !checkShell(session.handler.state) { if let lastSession = container.sessionIDs.last { @@ -185,6 +181,10 @@ struct ShellTabView: View { dismiss() } } + UIApplication.shared.isIdleTimerDisabled = false + if container.sessions.isEmpty { + Backgrounder.shared.stopBgTracking() + } } .id(selectedID) .transition(.opacity)