From bdb84ecc1233d92707cfa0844274337ba991e7c5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 21 May 2024 09:25:41 +0200 Subject: [PATCH] Rename members for clarity --- .../impl/advanced/AdvancedSettingsPresenter.kt | 4 ++-- .../impl/advanced/AdvancedSettingsState.kt | 4 ++-- .../impl/advanced/AdvancedSettingsStateProvider.kt | 12 ++++++------ .../impl/advanced/AdvancedSettingsView.kt | 10 +++++----- .../impl/advanced/AdvancedSettingsPresenterTest.kt | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsPresenter.kt index 3582517ef5..dc76298ae5 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsPresenter.kt @@ -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) } ) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsState.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsState.kt index 36e5c5744d..23de2fda13 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsState.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsState.kt @@ -25,8 +25,8 @@ data class AdvancedSettingsState( val isSharePresenceEnabled: Boolean, val theme: Theme, val showChangeThemeDialog: Boolean, - val pushDistributor: AsyncAction, - val pushDistributors: ImmutableList, + val currentPushDistributor: AsyncAction, + val availablePushDistributors: ImmutableList, val showChangePushProviderDialog: Boolean, val eventSink: (AdvancedSettingsEvents) -> Unit ) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsStateProvider.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsStateProvider.kt index 092b940bd4..301dba0258 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsStateProvider.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsStateProvider.kt @@ -29,8 +29,8 @@ open class AdvancedSettingsStateProvider : PreviewParameterProvider = AsyncAction.Success("Firebase"), - pushDistributors: List = listOf("Firebase", "ntfy"), + currentPushDistributor: AsyncAction = AsyncAction.Success("Firebase"), + availablePushDistributors: List = 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 = {} ) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsView.kt index 9d497ee60f..9b82a87bbc 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsView.kt @@ -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) diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsPresenterTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsPresenterTest.kt index 0c2ed36624..7e4175d3bd 100644 --- a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsPresenterTest.kt +++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/advanced/AdvancedSettingsPresenterTest.kt @@ -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) } }