Fix bug, was not looking at the current PushProvider.

This commit is contained in:
Benoit Marty
2024-05-07 14:32:50 +02:00
committed by Benoit Marty
parent 730f05d915
commit 12f7c9982b

View File

@@ -61,10 +61,11 @@ class DefaultPushService @Inject constructor(
): Result<Unit> {
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)