inverting if to favour positive ordering

This commit is contained in:
Adam Brown 2021-09-22 15:51:43 +01:00
parent 48d9dfb82d
commit 21479b2b28
1 changed files with 6 additions and 6 deletions

View File

@ -57,7 +57,12 @@ internal class DefaultAddPusherTask @Inject constructor(
}
monarchy.awaitTransaction { realm ->
val echo = PusherEntity.where(realm, pusher.pushKey).findFirst()
if (echo != null) {
if (echo == null) {
pusher.toEntity().also {
it.state = PusherState.REGISTERED
realm.insertOrUpdate(it)
}
} else {
echo.appDisplayName = pusher.appDisplayName
echo.appId = pusher.appId
echo.kind = pusher.kind
@ -66,11 +71,6 @@ internal class DefaultAddPusherTask @Inject constructor(
echo.data?.format = pusher.data?.format
echo.data?.url = pusher.data?.url
echo.state = PusherState.REGISTERED
} else {
pusher.toEntity().also {
it.state = PusherState.REGISTERED
realm.insertOrUpdate(it)
}
}
}
}