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