Set the value of currentDistributorName by reading again the value from the service.
This commit is contained in:
parent
8bb3b94132
commit
25c20f1734
3 changed files with 9 additions and 2 deletions
|
|
@ -121,7 +121,6 @@ class NotificationSettingsPresenter @Inject constructor(
|
||||||
)
|
)
|
||||||
.fold(
|
.fold(
|
||||||
{
|
{
|
||||||
currentDistributorName = AsyncAction.Success(distributor.name)
|
|
||||||
refreshPushProvider++
|
refreshPushProvider++
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ class NotificationSettingsPresenterTests {
|
||||||
val withNewProvider = awaitItem()
|
val withNewProvider = awaitItem()
|
||||||
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
||||||
assertThat(withNewProvider.currentPushDistributor).isEqualTo(AsyncAction.Loading)
|
assertThat(withNewProvider.currentPushDistributor).isEqualTo(AsyncAction.Loading)
|
||||||
|
skipItems(1)
|
||||||
val lastItem = awaitItem()
|
val lastItem = awaitItem()
|
||||||
assertThat(lastItem.currentPushDistributor).isEqualTo(AsyncAction.Success("aDistributorName1"))
|
assertThat(lastItem.currentPushDistributor).isEqualTo(AsyncAction.Success("aDistributorName1"))
|
||||||
cancelAndIgnoreRemainingEvents()
|
cancelAndIgnoreRemainingEvents()
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,26 @@ class FakePushService(
|
||||||
},
|
},
|
||||||
) : PushService {
|
) : PushService {
|
||||||
override suspend fun getCurrentPushProvider(): PushProvider? {
|
override suspend fun getCurrentPushProvider(): PushProvider? {
|
||||||
return availablePushProviders.firstOrNull()
|
return registeredPushProvider ?: availablePushProviders.firstOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAvailablePushProviders(): List<PushProvider> {
|
override fun getAvailablePushProviders(): List<PushProvider> {
|
||||||
return availablePushProviders
|
return availablePushProviders
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var registeredPushProvider: PushProvider? = null
|
||||||
|
|
||||||
override suspend fun registerWith(
|
override suspend fun registerWith(
|
||||||
matrixClient: MatrixClient,
|
matrixClient: MatrixClient,
|
||||||
pushProvider: PushProvider,
|
pushProvider: PushProvider,
|
||||||
distributor: Distributor,
|
distributor: Distributor,
|
||||||
): Result<Unit> = simulateLongTask {
|
): Result<Unit> = simulateLongTask {
|
||||||
return registerWithLambda(matrixClient, pushProvider, distributor)
|
return registerWithLambda(matrixClient, pushProvider, distributor)
|
||||||
|
.also {
|
||||||
|
if (it.isSuccess) {
|
||||||
|
registeredPushProvider = pushProvider
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun testPush(): Boolean = simulateLongTask {
|
override suspend fun testPush(): Boolean = simulateLongTask {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue