From 12f7c9982b04debe05bf6f295704fadfba5fafcd Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 7 May 2024 14:32:50 +0200 Subject: [PATCH] Fix bug, was not looking at the current PushProvider. --- .../android/libraries/push/impl/DefaultPushService.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/DefaultPushService.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/DefaultPushService.kt index c504802610..4396337883 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/DefaultPushService.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/DefaultPushService.kt @@ -61,10 +61,11 @@ class DefaultPushService @Inject constructor( ): Result { val userPushStore = userPushStoreFactory.getOrCreate(matrixClient.sessionId) val currentPushProviderName = userPushStore.getPushProviderName() - val currentDistributorValue = pushProvider.getCurrentDistributor(matrixClient)?.value + val currentPushProvider = pushProviders.find { it.name == currentPushProviderName } + val currentDistributorValue = currentPushProvider?.getCurrentDistributor(matrixClient)?.value if (currentPushProviderName != pushProvider.name || currentDistributorValue != distributor.value) { // Unregister previous one if any - pushProviders.find { it.name == currentPushProviderName }?.unregister(matrixClient) + currentPushProvider?.unregister(matrixClient) ?.onFailure { Timber.w(it, "Failed to unregister previous push provider") return Result.failure(it)