Jun 24 - Implement device registry

This commit is contained in:
Nguyen Ngo
2026-06-25 10:26:22 -04:00
parent e6de1f01b6
commit c05f0029fb
4 changed files with 85 additions and 0 deletions
+12
View File
@@ -42,6 +42,13 @@ struct ContentView: View {
// any failure (offline, parse error, etc.) so it never disrupts
// normal app use.
await updateChecker.checkForUpdate()
// 5. Register device now that auth is fully resolved.
// The .onChange(scenePhase == .active) fires BEFORE restoreSession()
// completes on first launch, so auth.isAuthenticated is false there
// and registration is skipped. This call covers that gap.
if AuthManager.shared.isAuthenticated {
await APIClient.shared.registerDevice()
}
}
// Stop the 60s notification poll when the app goes to background and
// restart it when it returns to the foreground. iOS suspends Tasks
@@ -60,6 +67,11 @@ struct ContentView: View {
SyncManager.shared.suspendPolling()
case .active:
SyncManager.shared.resumePolling()
// Register / update device record on every foreground.
// Fire-and-forget auth guard is inside registerDevice().
if auth.isAuthenticated {
Task { await APIClient.shared.registerDevice() }
}
default:
break
}