mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-29 04:39:53 +00:00
check active token on start
This commit is contained in:
parent
cb77cdd534
commit
c7b6e51f94
2 changed files with 9 additions and 4 deletions
|
@ -542,9 +542,14 @@ func registerToken(token: DeviceToken) {
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
let status = try await apiRegisterToken(token: token, notificationMode: mode)
|
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 {
|
} catch let error {
|
||||||
logger.error("registerToken apiRegisterToken error: \(responseError(error))")
|
logger.error("registerToken apiRegisterToken or apiCheckToken error: \(responseError(error))")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,7 +479,7 @@ struct SettingsView: View {
|
||||||
color = theme.colors.secondary
|
color = theme.colors.secondary
|
||||||
case .invalid:
|
case .invalid:
|
||||||
icon = "bolt.slash"
|
icon = "bolt.slash"
|
||||||
color = theme.colors.secondary
|
color = .red
|
||||||
case .confirmed:
|
case .confirmed:
|
||||||
icon = "bolt.fill"
|
icon = "bolt.fill"
|
||||||
color = .yellow
|
color = .yellow
|
||||||
|
@ -488,7 +488,7 @@ struct SettingsView: View {
|
||||||
color = .green
|
color = .green
|
||||||
case .expired:
|
case .expired:
|
||||||
icon = "bolt.slash.fill"
|
icon = "bolt.slash.fill"
|
||||||
color = theme.colors.secondary
|
color = .red
|
||||||
case .none:
|
case .none:
|
||||||
icon = "bolt"
|
icon = "bolt"
|
||||||
color = theme.colors.secondary
|
color = theme.colors.secondary
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue