mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-02 20:26:47 +01:00
Identity: Cleanup
This commit is contained in:
parent
7822660ce7
commit
d0953b8406
@ -208,8 +208,8 @@ class DiscoverySettingsController @Inject constructor(
|
||||
settingsInformationItem {
|
||||
id("info${pidInfo.threePid.value}")
|
||||
colorProvider(colorProvider)
|
||||
infoMessageColorId(R.color.vector_error_color)
|
||||
infoMessage(pidInfo.isShared.error.message ?: "")
|
||||
textColorId(R.color.vector_error_color)
|
||||
message(pidInfo.isShared.error.message ?: "")
|
||||
}
|
||||
buildContinueCancel(pidInfo.threePid)
|
||||
}
|
||||
@ -219,8 +219,7 @@ class DiscoverySettingsController @Inject constructor(
|
||||
settingsInformationItem {
|
||||
id("info${pidInfo.threePid.value}")
|
||||
colorProvider(colorProvider)
|
||||
infoMessage(stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value))
|
||||
infoMessageColorId(R.color.vector_info_color)
|
||||
message(stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value))
|
||||
}
|
||||
buildContinueCancel(pidInfo.threePid)
|
||||
}
|
||||
@ -228,8 +227,7 @@ class DiscoverySettingsController @Inject constructor(
|
||||
settingsInformationItem {
|
||||
id("info${pidInfo.threePid.value}")
|
||||
colorProvider(colorProvider)
|
||||
infoMessage(stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value))
|
||||
infoMessageColorId(R.color.vector_info_color)
|
||||
message(stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value))
|
||||
}
|
||||
settingsProgressItem {
|
||||
id("progress${pidInfo.threePid.value}")
|
||||
@ -239,8 +237,8 @@ class DiscoverySettingsController @Inject constructor(
|
||||
settingsInformationItem {
|
||||
id("info${pidInfo.threePid.value}")
|
||||
colorProvider(colorProvider)
|
||||
infoMessage(stringProvider.getString(R.string.settings_discovery_confirm_mail_not_clicked, pidInfo.threePid.value))
|
||||
infoMessageColorId(R.color.riotx_destructive_accent)
|
||||
message(stringProvider.getString(R.string.settings_discovery_confirm_mail_not_clicked, pidInfo.threePid.value))
|
||||
textColorId(R.color.riotx_destructive_accent)
|
||||
}
|
||||
buildContinueCancel(pidInfo.threePid)
|
||||
}
|
||||
@ -332,8 +330,8 @@ class DiscoverySettingsController @Inject constructor(
|
||||
settingsInformationItem {
|
||||
id("info${pidInfo.threePid.value}")
|
||||
colorProvider(colorProvider)
|
||||
infoMessageColorId(R.color.vector_error_color)
|
||||
infoMessage(pidInfo.isShared.error.message ?: "")
|
||||
textColorId(R.color.vector_error_color)
|
||||
message(pidInfo.isShared.error.message ?: "")
|
||||
}
|
||||
}
|
||||
when (pidInfo.isShared()) {
|
||||
|
@ -133,7 +133,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
||||
is DiscoverySettingsAction.ChangeIdentityServer -> changeIdentityServer(action)
|
||||
is DiscoverySettingsAction.RevokeThreePid -> revokeThreePid(action)
|
||||
is DiscoverySettingsAction.ShareThreePid -> shareThreePid(action)
|
||||
is DiscoverySettingsAction.FinalizeBind3pid -> finalizeBind3pid(action)
|
||||
is DiscoverySettingsAction.FinalizeBind3pid -> finalizeBind3pid(action, true)
|
||||
is DiscoverySettingsAction.SubmitMsisdnToken -> submitMsisdnToken(action)
|
||||
is DiscoverySettingsAction.CancelBinding -> cancelBinding(action)
|
||||
}.exhaustive
|
||||
@ -278,7 +278,6 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
private fun cancelBinding(action: DiscoverySettingsAction.CancelBinding) {
|
||||
// TODO: remove the callback
|
||||
identityService.cancelBindThreePid(action.threePid, object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
changeThreePidState(action.threePid, Success(SharedState.NOT_SHARED))
|
||||
@ -366,7 +365,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
||||
object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
changeThreePidSubmitState(action.threePid, Uninitialized)
|
||||
finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(action.threePid))
|
||||
finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(action.threePid), true)
|
||||
}
|
||||
|
||||
override fun onFailure(failure: Throwable) {
|
||||
@ -376,7 +375,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun finalizeBind3pid(action: DiscoverySettingsAction.FinalizeBind3pid) = withState { state ->
|
||||
private fun finalizeBind3pid(action: DiscoverySettingsAction.FinalizeBind3pid, fromUser: Boolean) = withState { state ->
|
||||
val threePid = when (action.threePid) {
|
||||
is ThreePid.Email -> {
|
||||
state.emailList()?.find { it.threePid.value == action.threePid.email }?.threePid ?: return@withState
|
||||
@ -395,7 +394,12 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
override fun onFailure(failure: Throwable) {
|
||||
changeThreePidSubmitState(action.threePid, Fail(failure))
|
||||
// If this is not from user (user did not click to "Continue", but this is a refresh when Fragment is resumed), do no display the error
|
||||
if (fromUser) {
|
||||
changeThreePidSubmitState(action.threePid, Fail(failure))
|
||||
} else {
|
||||
changeThreePidSubmitState(action.threePid, Uninitialized)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -404,7 +408,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
||||
private fun refreshPendingEmailBindings() = withState { state ->
|
||||
state.emailList()?.forEach { info ->
|
||||
when (info.isShared()) {
|
||||
SharedState.BINDING_IN_PROGRESS -> finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(info.threePid))
|
||||
SharedState.BINDING_IN_PROGRESS -> finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(info.threePid), false)
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
@ -30,21 +30,18 @@ abstract class SettingsInformationItem : EpoxyModelWithHolder<SettingsInformatio
|
||||
@EpoxyAttribute
|
||||
lateinit var colorProvider: ColorProvider
|
||||
|
||||
// TODO Rename message
|
||||
@EpoxyAttribute
|
||||
lateinit var infoMessage: String
|
||||
lateinit var message: String
|
||||
|
||||
@EpoxyAttribute
|
||||
@ColorRes
|
||||
var infoMessageColorId: Int = R.color.vector_error_color
|
||||
var textColorId: Int = R.color.vector_info_color
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
|
||||
holder.textView.text = infoMessage
|
||||
|
||||
val errorColor = colorProvider.getColor(infoMessageColorId)
|
||||
holder.textView.setTextColor(errorColor)
|
||||
holder.textView.text = message
|
||||
holder.textView.setTextColor(colorProvider.getColor(textColorId))
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user