Set the value of currentDistributorName by reading again the value from the service.

This commit is contained in:
Benoit Marty 2024-05-28 13:55:29 +02:00
parent bd46321c2a
commit 3349df5a24
3 changed files with 9 additions and 2 deletions

View file

@ -121,7 +121,6 @@ class NotificationSettingsPresenter @Inject constructor(
)
.fold(
{
currentDistributorName = AsyncAction.Success(distributor.name)
refreshPushProvider++
},
{

View file

@ -262,6 +262,7 @@ class NotificationSettingsPresenterTests {
val withNewProvider = awaitItem()
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
assertThat(withNewProvider.currentPushDistributor).isEqualTo(AsyncAction.Loading)
skipItems(1)
val lastItem = awaitItem()
assertThat(lastItem.currentPushDistributor).isEqualTo(AsyncAction.Success("aDistributorName1"))
cancelAndIgnoreRemainingEvents()

View file

@ -30,19 +30,26 @@ class FakePushService(
},
) : PushService {
override suspend fun getCurrentPushProvider(): PushProvider? {
return availablePushProviders.firstOrNull()
return registeredPushProvider ?: availablePushProviders.firstOrNull()
}
override fun getAvailablePushProviders(): List<PushProvider> {
return availablePushProviders
}
private var registeredPushProvider: PushProvider? = null
override suspend fun registerWith(
matrixClient: MatrixClient,
pushProvider: PushProvider,
distributor: Distributor,
): Result<Unit> = simulateLongTask {
return registerWithLambda(matrixClient, pushProvider, distributor)
.also {
if (it.isSuccess) {
registeredPushProvider = pushProvider
}
}
}
override suspend fun testPush(): Boolean = simulateLongTask {