mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 20:29:10 +03:00
Identity: correctly handle terms update
This commit is contained in:
parent
b659cb60a2
commit
af3fc22e2d
4 changed files with 8 additions and 8 deletions
2
.idea/dictionaries/bmarty.xml
generated
2
.idea/dictionaries/bmarty.xml
generated
|
@ -18,7 +18,9 @@
|
|||
<w>linkify</w>
|
||||
<w>megolm</w>
|
||||
<w>msisdn</w>
|
||||
<w>msisdns</w>
|
||||
<w>pbkdf</w>
|
||||
<w>pids</w>
|
||||
<w>pkcs</w>
|
||||
<w>riotx</w>
|
||||
<w>signin</w>
|
||||
|
|
|
@ -65,7 +65,7 @@ class DiscoverySettingsController @Inject constructor(
|
|||
is Success -> {
|
||||
buildIdentityServerSection(data)
|
||||
val hasIdentityServer = data.identityServer().isNullOrBlank().not()
|
||||
if (hasIdentityServer) {
|
||||
if (hasIdentityServer && !data.termsNotSigned) {
|
||||
buildEmailsSection(data.emailList)
|
||||
buildMsisdnSection(data.phoneNumbersList)
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class DiscoverySettingsController @Inject constructor(
|
|||
val identityServer = data.identityServer() ?: stringProvider.getString(R.string.none)
|
||||
|
||||
settingsSectionTitleItem {
|
||||
id("idsTitle")
|
||||
id("idServerTitle")
|
||||
titleResId(R.string.identity_server)
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ class DiscoverySettingsController @Inject constructor(
|
|||
if (data.termsNotSigned) {
|
||||
helperText(stringProvider.getString(R.string.settings_agree_to_terms, identityServer))
|
||||
showCompoundDrawable(true)
|
||||
itemClickListener(View.OnClickListener { listener?.onSelectIdentityServer() })
|
||||
itemClickListener(View.OnClickListener { listener?.openIdentityServerTerms() })
|
||||
} else {
|
||||
showCompoundDrawable(false)
|
||||
if (data.identityServer() != null) {
|
||||
|
@ -357,7 +357,7 @@ class DiscoverySettingsController @Inject constructor(
|
|||
}
|
||||
|
||||
interface Listener {
|
||||
fun onSelectIdentityServer()
|
||||
fun openIdentityServerTerms()
|
||||
fun onTapRevoke(threePid: ThreePid)
|
||||
fun onTapShare(threePid: ThreePid)
|
||||
fun checkEmailVerification(threePid: ThreePid.Email)
|
||||
|
|
|
@ -103,9 +103,8 @@ class DiscoverySettingsFragment @Inject constructor(
|
|||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
||||
override fun onSelectIdentityServer() = withState(viewModel) { state ->
|
||||
override fun openIdentityServerTerms() = withState(viewModel) { state ->
|
||||
if (state.termsNotSigned) {
|
||||
// TODO Use ViewEvents?
|
||||
navigator.openTerms(
|
||||
this,
|
||||
TermsService.ServiceType.IdentityService,
|
||||
|
|
|
@ -52,7 +52,7 @@ data class DiscoverySettingsState(
|
|||
val identityServer: Async<String?> = Uninitialized,
|
||||
val emailList: Async<List<PidInfo>> = Uninitialized,
|
||||
val phoneNumbersList: Async<List<PidInfo>> = Uninitialized,
|
||||
// TODO Use ViewEvents?
|
||||
// Can be true if terms are updated
|
||||
val termsNotSigned: Boolean = false
|
||||
) : MvRxState
|
||||
|
||||
|
@ -329,7 +329,6 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
|||
override fun onFailure(failure: Throwable) {
|
||||
if (failure is IdentityServiceError.TermsNotSignedException) {
|
||||
setState {
|
||||
// TODO Use ViewEvent ?
|
||||
copy(termsNotSigned = true)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue