Rename members for clarity
This commit is contained in:
committed by
Benoit Marty
parent
3bc7a57f53
commit
bdb84ecc12
@@ -140,8 +140,8 @@ class AdvancedSettingsPresenter @Inject constructor(
|
||||
isSharePresenceEnabled = isSharePresenceEnabled,
|
||||
theme = theme,
|
||||
showChangeThemeDialog = showChangeThemeDialog,
|
||||
pushDistributor = currentDistributorName,
|
||||
pushDistributors = distributorNames.toImmutableList(),
|
||||
currentPushDistributor = currentDistributorName,
|
||||
availablePushDistributors = distributorNames.toImmutableList(),
|
||||
showChangePushProviderDialog = showChangePushProviderDialog,
|
||||
eventSink = { handleEvents(it) }
|
||||
)
|
||||
|
||||
@@ -25,8 +25,8 @@ data class AdvancedSettingsState(
|
||||
val isSharePresenceEnabled: Boolean,
|
||||
val theme: Theme,
|
||||
val showChangeThemeDialog: Boolean,
|
||||
val pushDistributor: AsyncAction<String>,
|
||||
val pushDistributors: ImmutableList<String>,
|
||||
val currentPushDistributor: AsyncAction<String>,
|
||||
val availablePushDistributors: ImmutableList<String>,
|
||||
val showChangePushProviderDialog: Boolean,
|
||||
val eventSink: (AdvancedSettingsEvents) -> Unit
|
||||
)
|
||||
|
||||
@@ -29,8 +29,8 @@ open class AdvancedSettingsStateProvider : PreviewParameterProvider<AdvancedSett
|
||||
aAdvancedSettingsState(showChangeThemeDialog = true),
|
||||
aAdvancedSettingsState(isSendPublicReadReceiptsEnabled = true),
|
||||
aAdvancedSettingsState(showChangePushProviderDialog = true),
|
||||
aAdvancedSettingsState(pushDistributor = AsyncAction.Loading),
|
||||
aAdvancedSettingsState(pushDistributor = AsyncAction.Failure(Exception("Failed to change distributor"))),
|
||||
aAdvancedSettingsState(currentPushDistributor = AsyncAction.Loading),
|
||||
aAdvancedSettingsState(currentPushDistributor = AsyncAction.Failure(Exception("Failed to change distributor"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -38,16 +38,16 @@ fun aAdvancedSettingsState(
|
||||
isDeveloperModeEnabled: Boolean = false,
|
||||
isSendPublicReadReceiptsEnabled: Boolean = false,
|
||||
showChangeThemeDialog: Boolean = false,
|
||||
pushDistributor: AsyncAction<String> = AsyncAction.Success("Firebase"),
|
||||
pushDistributors: List<String> = listOf("Firebase", "ntfy"),
|
||||
currentPushDistributor: AsyncAction<String> = AsyncAction.Success("Firebase"),
|
||||
availablePushDistributors: List<String> = listOf("Firebase", "ntfy"),
|
||||
showChangePushProviderDialog: Boolean = false,
|
||||
) = AdvancedSettingsState(
|
||||
isDeveloperModeEnabled = isDeveloperModeEnabled,
|
||||
isSharePresenceEnabled = isSendPublicReadReceiptsEnabled,
|
||||
theme = Theme.System,
|
||||
showChangeThemeDialog = showChangeThemeDialog,
|
||||
pushDistributor = pushDistributor,
|
||||
pushDistributors = pushDistributors.toImmutableList(),
|
||||
currentPushDistributor = currentPushDistributor,
|
||||
availablePushDistributors = availablePushDistributors.toImmutableList(),
|
||||
showChangePushProviderDialog = showChangePushProviderDialog,
|
||||
eventSink = {}
|
||||
)
|
||||
|
||||
@@ -90,7 +90,7 @@ fun AdvancedSettingsView(
|
||||
headlineContent = {
|
||||
Text(text = stringResource(id = R.string.screen_advanced_settings_push_provider_android))
|
||||
},
|
||||
trailingContent = when (state.pushDistributor) {
|
||||
trailingContent = when (state.currentPushDistributor) {
|
||||
AsyncAction.Uninitialized,
|
||||
AsyncAction.Confirming,
|
||||
AsyncAction.Loading -> ListItemContent.Custom {
|
||||
@@ -105,11 +105,11 @@ fun AdvancedSettingsView(
|
||||
stringResource(id = CommonStrings.common_error)
|
||||
)
|
||||
is AsyncAction.Success -> ListItemContent.Text(
|
||||
state.pushDistributor.dataOrNull() ?: ""
|
||||
state.currentPushDistributor.dataOrNull() ?: ""
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
if (state.pushDistributor.isReady()) {
|
||||
if (state.currentPushDistributor.isReady()) {
|
||||
state.eventSink(AdvancedSettingsEvents.ChangePushProvider)
|
||||
}
|
||||
}
|
||||
@@ -134,10 +134,10 @@ fun AdvancedSettingsView(
|
||||
if (state.showChangePushProviderDialog) {
|
||||
SingleSelectionDialog(
|
||||
title = stringResource(id = R.string.screen_advanced_settings_choose_distributor_dialog_title_android),
|
||||
options = state.pushDistributors.map {
|
||||
options = state.availablePushDistributors.map {
|
||||
ListOption(title = it)
|
||||
}.toImmutableList(),
|
||||
initialSelection = state.pushDistributors.indexOf(state.pushDistributor.dataOrNull()),
|
||||
initialSelection = state.availablePushDistributors.indexOf(state.currentPushDistributor.dataOrNull()),
|
||||
onOptionSelected = { index ->
|
||||
state.eventSink(
|
||||
AdvancedSettingsEvents.SetPushProvider(index)
|
||||
|
||||
@@ -117,8 +117,8 @@ class AdvancedSettingsPresenterTest {
|
||||
presenter.present()
|
||||
}.test {
|
||||
val initialState = awaitLastSequentialItem()
|
||||
assertThat(initialState.pushDistributor).isEqualTo(AsyncAction.Success("aDistributorName0"))
|
||||
assertThat(initialState.pushDistributors).containsExactly("aDistributorName0", "aDistributorName1")
|
||||
assertThat(initialState.currentPushDistributor).isEqualTo(AsyncAction.Success("aDistributorName0"))
|
||||
assertThat(initialState.availablePushDistributors).containsExactly("aDistributorName0", "aDistributorName1")
|
||||
initialState.eventSink.invoke(AdvancedSettingsEvents.ChangePushProvider)
|
||||
val withDialog = awaitItem()
|
||||
assertThat(withDialog.showChangePushProviderDialog).isTrue()
|
||||
@@ -131,9 +131,9 @@ class AdvancedSettingsPresenterTest {
|
||||
withDialog.eventSink(AdvancedSettingsEvents.SetPushProvider(1))
|
||||
val withNewProvider = awaitItem()
|
||||
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
||||
assertThat(withNewProvider.pushDistributor).isEqualTo(AsyncAction.Loading)
|
||||
assertThat(withNewProvider.currentPushDistributor).isEqualTo(AsyncAction.Loading)
|
||||
val lastItem = awaitItem()
|
||||
assertThat(lastItem.pushDistributor).isEqualTo(AsyncAction.Success("aDistributorName1"))
|
||||
assertThat(lastItem.currentPushDistributor).isEqualTo(AsyncAction.Success("aDistributorName1"))
|
||||
cancelAndIgnoreRemainingEvents()
|
||||
}
|
||||
}
|
||||
@@ -157,9 +157,9 @@ class AdvancedSettingsPresenterTest {
|
||||
withDialog.eventSink(AdvancedSettingsEvents.SetPushProvider(1))
|
||||
val withNewProvider = awaitItem()
|
||||
assertThat(withNewProvider.showChangePushProviderDialog).isFalse()
|
||||
assertThat(withNewProvider.pushDistributor).isEqualTo(AsyncAction.Loading)
|
||||
assertThat(withNewProvider.currentPushDistributor).isEqualTo(AsyncAction.Loading)
|
||||
val lastItem = awaitItem()
|
||||
assertThat(lastItem.pushDistributor).isInstanceOf(AsyncAction.Failure::class.java)
|
||||
assertThat(lastItem.currentPushDistributor).isInstanceOf(AsyncAction.Failure::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user