mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
using single action for the updating the policy expanded toggling/state setting
This commit is contained in:
parent
496a531072
commit
cccda9b699
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user