Fix RACE to deleteDevice
This commit is contained in:
parent
14601abc88
commit
df3bb9a3c6
|
@ -178,9 +178,10 @@ class MainActivity : AppCompatActivity() {
|
|||
.edit()
|
||||
.remove("PREF_CURRENT_ACCOUNT_STRING")
|
||||
.apply()
|
||||
deleteDevice(this)
|
||||
deleteDevice(this) {
|
||||
StartService.stopService()
|
||||
FailureHandler.clearFails()
|
||||
}
|
||||
showStart()
|
||||
finish()
|
||||
startActivity(intent)
|
||||
|
|
|
@ -106,7 +106,7 @@ object Api {
|
|||
Log.d(TAG, "cSync done.")
|
||||
}
|
||||
|
||||
fun Context.apiDeleteDevice() {
|
||||
fun Context.apiDeleteDevice(block: () -> Unit = {}) {
|
||||
val deviceId = getDeviceId(this) ?: return
|
||||
|
||||
withApiProvider { apiProvider ->
|
||||
|
@ -132,6 +132,7 @@ object Api {
|
|||
|
||||
override fun onComplete() {
|
||||
removeUrl(this@apiDeleteDevice)
|
||||
block()
|
||||
}
|
||||
})
|
||||
removeDeviceId(this)
|
||||
|
|
|
@ -108,13 +108,13 @@ object Distributor {
|
|||
return TOKEN_NOK
|
||||
}
|
||||
|
||||
fun deleteDevice(context: Context) {
|
||||
fun deleteDevice(context: Context, block: () -> Unit = {}) {
|
||||
val db = getDb(context)
|
||||
db.listTokens().forEach {
|
||||
sendUnregistered(context, it)
|
||||
db.unregisterApp(it)
|
||||
}
|
||||
context.apiDeleteDevice()
|
||||
context.apiDeleteDevice(block)
|
||||
}
|
||||
|
||||
fun createApp(context: Context, appName: String, connectorToken: String, block: () -> Unit) {
|
||||
|
|
Loading…
Reference in New Issue