okay i got it to work

had to enable bg modes and stuff
and made it call on appear of the shell and not the tab strip 💀
This commit is contained in:
neon443
2025-08-24 21:00:59 +01:00
parent a7783eab47
commit d4f31fda32
3 changed files with 16 additions and 11 deletions

View File

@@ -22,5 +22,9 @@
<string>JetBrainsMonoNerdFontMono-Italic.ttf</string> <string>JetBrainsMonoNerdFontMono-Italic.ttf</string>
<string>JetBrainsMonoNerdFontMono-BoldItalic.ttf</string> <string>JetBrainsMonoNerdFontMono-BoldItalic.ttf</string>
</array> </array>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
</dict> </dict>
</plist> </plist>

View File

@@ -23,6 +23,7 @@ class Backgrounder: NSObject, CLLocationManagerDelegate, ObservableObject {
} }
func startBgTracking() { func startBgTracking() {
// guard mana
manager.allowsBackgroundLocationUpdates = true manager.allowsBackgroundLocationUpdates = true
manager.pausesLocationUpdatesAutomatically = false manager.pausesLocationUpdatesAutomatically = false
manager.startMonitoringSignificantLocationChanges() manager.startMonitoringSignificantLocationChanges()
@@ -53,6 +54,6 @@ class Backgrounder: NSObject, CLLocationManagerDelegate, ObservableObject {
} }
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("tracking started yay") print("tracking started fr")
} }
} }

View File

@@ -149,12 +149,6 @@ struct ShellTabView: View {
} }
} }
.frame(height: 30) .frame(height: 30)
.onDisappear {
UIApplication.shared.isIdleTimerDisabled = false
if container.sessions.isEmpty {
Backgrounder.shared.stopBgTracking()
}
}
.onAppear { .onAppear {
if selectedID == nil { if selectedID == nil {
if let handler { if let handler {
@@ -163,10 +157,6 @@ struct ShellTabView: View {
dismiss() dismiss()
} }
} }
UIApplication.shared.isIdleTimerDisabled = hostsManager.settings.caffeinate
if hostsManager.settings.locationPersist {
Backgrounder.shared.startBgTracking()
}
} }
} }
@@ -177,6 +167,12 @@ struct ShellTabView: View {
handler: session.handler, handler: session.handler,
hostsManager: hostsManager hostsManager: hostsManager
) )
.onAppear {
UIApplication.shared.isIdleTimerDisabled = hostsManager.settings.caffeinate
if hostsManager.settings.locationPersist {
Backgrounder.shared.startBgTracking()
}
}
.onDisappear { .onDisappear {
if !checkShell(session.handler.state) { if !checkShell(session.handler.state) {
if let lastSession = container.sessionIDs.last { if let lastSession = container.sessionIDs.last {
@@ -185,6 +181,10 @@ struct ShellTabView: View {
dismiss() dismiss()
} }
} }
UIApplication.shared.isIdleTimerDisabled = false
if container.sessions.isEmpty {
Backgrounder.shared.stopBgTracking()
}
} }
.id(selectedID) .id(selectedID)
.transition(.opacity) .transition(.opacity)