From 21479b2b28745e23f8983e1fb493e68629a2a106 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 22 Sep 2021 15:51:43 +0100 Subject: [PATCH] inverting if to favour positive ordering --- .../sdk/internal/session/pushers/AddPusherTask.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherTask.kt index 2929e09a1f..a24202957c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherTask.kt @@ -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) - } } } }