diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsAction.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsAction.kt index 74700f668f..a2f855c499 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsAction.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsAction.kt @@ -31,6 +31,5 @@ sealed class DiscoverySettingsAction : VectorViewModelAction { data class FinalizeBind3pid(val threePid: ThreePid) : DiscoverySettingsAction() data class SubmitMsisdnToken(val threePid: ThreePid.Msisdn, val code: String) : DiscoverySettingsAction() data class CancelBinding(val threePid: ThreePid) : DiscoverySettingsAction() - object PolicyUrlsExpandedStateToggled : DiscoverySettingsAction() - object ExpandPolicyUrls : DiscoverySettingsAction() + data class SetPoliciesExpandState(val expanded: Boolean) : DiscoverySettingsAction() } diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsController.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsController.kt index 2ed45c127b..56f345c13b 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsController.kt @@ -130,7 +130,7 @@ class DiscoverySettingsController @Inject constructor( } else R.string.settings_discovery_show_identity_server_policies_title title(host.stringProvider.getString(titleRes)) expanded(data.isIdentityPolicyUrlsExpanded) - listener { host.listener?.onPolicyUrlsExpandedStateToggled() } + listener { host.listener?.onPolicyUrlsExpandedStateToggled(!data.isIdentityPolicyUrlsExpanded) } } if (data.isIdentityPolicyUrlsExpanded) { policies.forEach { policy -> @@ -425,7 +425,7 @@ class DiscoverySettingsController @Inject constructor( fun onTapDisconnectIdentityServer() fun onTapUpdateUserConsent(newValue: Boolean) fun onTapRetryToRetrieveBindings() - fun onPolicyUrlsExpandedStateToggled() + fun onPolicyUrlsExpandedStateToggled(newExpandedState: Boolean) fun onPolicyTapped(policy: IdentityServerPolicy) } } diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsFragment.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsFragment.kt index f7f5452d84..6de7c1fba5 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsFragment.kt @@ -82,7 +82,7 @@ class DiscoverySettingsFragment @Inject constructor( }.exhaustive } if (discoveryArgs.expandIdentityPolicies) { - viewModel.handle(DiscoverySettingsAction.ExpandPolicyUrls) + viewModel.handle(DiscoverySettingsAction.SetPoliciesExpandState(expanded = true)) } } @@ -188,7 +188,7 @@ class DiscoverySettingsFragment @Inject constructor( withState(viewModel) { state -> requireContext().showIdentityServerConsentDialog( state.identityServer.invoke()?.serverUrl, - policyLinkCallback = { viewModel.handle(DiscoverySettingsAction.ExpandPolicyUrls) }, + policyLinkCallback = { viewModel.handle(DiscoverySettingsAction.SetPoliciesExpandState(expanded = true)) }, consentCallBack = { viewModel.handle(DiscoverySettingsAction.UpdateUserConsent(true)) } ) } @@ -201,8 +201,8 @@ class DiscoverySettingsFragment @Inject constructor( viewModel.handle(DiscoverySettingsAction.RetrieveBinding) } - override fun onPolicyUrlsExpandedStateToggled() { - viewModel.handle(DiscoverySettingsAction.PolicyUrlsExpandedStateToggled) + override fun onPolicyUrlsExpandedStateToggled(newExpandedState: Boolean) { + viewModel.handle(DiscoverySettingsAction.SetPoliciesExpandState(expanded = newExpandedState)) } override fun onPolicyTapped(policy: IdentityServerPolicy) { diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt index 6d872e5043..8b454607d5 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt @@ -111,18 +111,17 @@ class DiscoverySettingsViewModel @AssistedInject constructor( override fun handle(action: DiscoverySettingsAction) { when (action) { - DiscoverySettingsAction.Refresh -> fetchContent() - DiscoverySettingsAction.RetrieveBinding -> retrieveBinding() - DiscoverySettingsAction.DisconnectIdentityServer -> disconnectIdentityServer() - DiscoverySettingsAction.PolicyUrlsExpandedStateToggled -> toggleExpandedPolicyUrlsState() - DiscoverySettingsAction.ExpandPolicyUrls -> updatePolicyUrlsExpandedState(isExpanded = true) - is DiscoverySettingsAction.ChangeIdentityServer -> changeIdentityServer(action) - is DiscoverySettingsAction.UpdateUserConsent -> handleUpdateUserConsent(action) - is DiscoverySettingsAction.RevokeThreePid -> revokeThreePid(action) - is DiscoverySettingsAction.ShareThreePid -> shareThreePid(action) - is DiscoverySettingsAction.FinalizeBind3pid -> finalizeBind3pid(action, true) - is DiscoverySettingsAction.SubmitMsisdnToken -> submitMsisdnToken(action) - is DiscoverySettingsAction.CancelBinding -> cancelBinding(action) + DiscoverySettingsAction.Refresh -> fetchContent() + DiscoverySettingsAction.RetrieveBinding -> retrieveBinding() + DiscoverySettingsAction.DisconnectIdentityServer -> disconnectIdentityServer() + is DiscoverySettingsAction.SetPoliciesExpandState -> updatePolicyUrlsExpandedState(action.expanded) + is DiscoverySettingsAction.ChangeIdentityServer -> changeIdentityServer(action) + is DiscoverySettingsAction.UpdateUserConsent -> handleUpdateUserConsent(action) + is DiscoverySettingsAction.RevokeThreePid -> revokeThreePid(action) + is DiscoverySettingsAction.ShareThreePid -> shareThreePid(action) + is DiscoverySettingsAction.FinalizeBind3pid -> finalizeBind3pid(action, true) + is DiscoverySettingsAction.SubmitMsisdnToken -> submitMsisdnToken(action) + is DiscoverySettingsAction.CancelBinding -> cancelBinding(action) }.exhaustive } @@ -149,10 +148,6 @@ class DiscoverySettingsViewModel @AssistedInject constructor( } } - private fun toggleExpandedPolicyUrlsState() { - withState { state -> updatePolicyUrlsExpandedState(isExpanded = !state.isIdentityPolicyUrlsExpanded) } - } - private fun updatePolicyUrlsExpandedState(isExpanded: Boolean) { setState { copy(isIdentityPolicyUrlsExpanded = isExpanded) } }