Identity: improve terms not signed case

This commit is contained in:
Benoit Marty 2020-05-11 00:49:39 +02:00
parent af3fc22e2d
commit ce42d2fb8a
3 changed files with 21 additions and 13 deletions

View File

@ -86,13 +86,22 @@ class DiscoverySettingsController @Inject constructor(
title(identityServer)
}
settingsInfoItem {
id("idServerFooter")
if (data.termsNotSigned) {
if (data.identityServer() != null && data.termsNotSigned) {
settingsInfoItem {
id("idServerFooter")
helperText(stringProvider.getString(R.string.settings_agree_to_terms, identityServer))
showCompoundDrawable(true)
itemClickListener(View.OnClickListener { listener?.openIdentityServerTerms() })
} else {
}
settingsButtonItem {
id("seeTerms")
colorProvider(colorProvider)
buttonTitle(stringProvider.getString(R.string.open_terms_of, identityServer))
buttonClickListener { listener?.openIdentityServerTerms() }
}
} else {
settingsInfoItem {
id("idServerFooter")
showCompoundDrawable(false)
if (data.identityServer() != null) {
helperText(stringProvider.getString(R.string.settings_discovery_identity_server_info, identityServer))

View File

@ -321,24 +321,22 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
setState {
copy(
emailList = Success(data.filter { it.key is ThreePid.Email }.toPidInfoList()),
phoneNumbersList = Success(data.filter { it.key is ThreePid.Msisdn }.toPidInfoList())
phoneNumbersList = Success(data.filter { it.key is ThreePid.Msisdn }.toPidInfoList()),
termsNotSigned = false
)
}
}
override fun onFailure(failure: Throwable) {
if (failure is IdentityServiceError.TermsNotSignedException) {
setState {
copy(termsNotSigned = true)
}
if (failure !is IdentityServiceError.TermsNotSignedException) {
_viewEvents.post(DiscoverySettingsViewEvents.Failure(failure))
}
_viewEvents.post(DiscoverySettingsViewEvents.Failure(failure))
setState {
copy(
emailList = Success(emails.map { PidInfo(it, Fail(failure)) }),
phoneNumbersList = Success(msisdns.map { PidInfo(it, Fail(failure)) })
phoneNumbersList = Success(msisdns.map { PidInfo(it, Fail(failure)) }),
termsNotSigned = failure is IdentityServiceError.TermsNotSignedException
)
}
}

View File

@ -2402,4 +2402,5 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
<string name="choose_locale_other_locales_title">Other available languages</string>
<string name="choose_locale_loading_locales">Loading available languages…</string>
</resources>
<string name="open_terms_of">Open terms of %s</string>
</resources>