06/23 Fix Medium//Low-impact issues

This commit is contained in:
Nguyen Ngo
2026-06-23 18:03:40 -04:00
parent a1afea095d
commit fc571b3faa
5 changed files with 173 additions and 39 deletions
+22
View File
@@ -7,6 +7,7 @@ struct ContentView: View {
@EnvironmentObject private var auth: AuthManager
@EnvironmentObject private var sync: SyncManager
@StateObject private var updateChecker = UpdateChecker.shared
@Environment(\.scenePhase) private var scenePhase
var body: some View {
Group {
@@ -42,6 +43,27 @@ struct ContentView: View {
// normal app use.
await updateChecker.checkForUpdate()
}
// Stop the 60s notification poll when the app goes to background and
// restart it when it returns to the foreground. iOS suspends Tasks
// automatically in the background anyway, but explicitly managing the
// poll task here:
// Prevents the Task object from accumulating sleep-resume cycles
// that never fired while suspended.
// Triggers an immediate sync+poll when the inspector returns to the
// app after being away, rather than waiting up to 60s for the next
// scheduled poll tick.
// Makes the lifecycle intent explicit and avoids relying on implicit
// iOS suspension behaviour.
.onChange(of: scenePhase) { _, newPhase in
switch newPhase {
case .background:
SyncManager.shared.suspendPolling()
case .active:
SyncManager.shared.resumePolling()
default:
break
}
}
.alert("Update Available", isPresented: $updateChecker.updateAvailable) {
Button("Update") {
if let url = updateChecker.appStoreURL {