From dbfa5e1fd530223e203f61d2e91de87f550cfd59 Mon Sep 17 00:00:00 2001 From: S1m Date: Mon, 12 Jul 2021 18:14:46 +0200 Subject: [PATCH] test on new endpoint --- .../app/core/pushers/VectorMessagingReceiver.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt index f400cded9d..0949b2f657 100755 --- a/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/VectorMessagingReceiver.kt @@ -156,12 +156,16 @@ val upHandler = object: MessagingReceiverHandler { override fun onNewEndpoint(context: Context?, endpoint: String, instance: String) { initVar(context!!) Timber.i("onNewEndpoint: adding $endpoint") - UPHelper.storeUpEndpoint(context, endpoint) if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) { val gateway = UPHelper.customOrDefaultGateway(context, endpoint) - UPHelper.storePushGateway(context, gateway) - UPHelper.storeUpEndpoint(context, endpoint) - pusherManager.registerPusher(context, endpoint, gateway) + if (UPHelper.getUpEndpoint(context) != endpoint || + UPHelper.getPushGateway(context) != gateway) { + UPHelper.storePushGateway(context, gateway) + UPHelper.storeUpEndpoint(context, endpoint) + pusherManager.registerPusher(context, endpoint, gateway) + } else { + Timber.i("onNewEndpoint: skipped") + } } val mode = BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_DISABLED vectorPreferences.setFdroidSyncBackgroundMode(mode)