check active token on start

This commit is contained in:
spaced4ndy 2025-02-06 14:09:10 +04:00
parent cb77cdd534
commit c7b6e51f94
2 changed files with 9 additions and 4 deletions

View file

@ -542,9 +542,14 @@ func registerToken(token: DeviceToken) {
Task {
do {
let status = try await apiRegisterToken(token: token, notificationMode: mode)
await MainActor.run { m.tokenStatus = status }
if status == .active {
let checkedStatus = try await apiCheckToken(token: token)
await MainActor.run { m.tokenStatus = checkedStatus }
} else {
await MainActor.run { m.tokenStatus = status }
}
} catch let error {
logger.error("registerToken apiRegisterToken error: \(responseError(error))")
logger.error("registerToken apiRegisterToken or apiCheckToken error: \(responseError(error))")
}
}
}

View file

@ -479,7 +479,7 @@ struct SettingsView: View {
color = theme.colors.secondary
case .invalid:
icon = "bolt.slash"
color = theme.colors.secondary
color = .red
case .confirmed:
icon = "bolt.fill"
color = .yellow
@ -488,7 +488,7 @@ struct SettingsView: View {
color = .green
case .expired:
icon = "bolt.slash.fill"
color = theme.colors.secondary
color = .red
case .none:
icon = "bolt"
color = theme.colors.secondary