mirror of
https://github.com/element-hq/element-android
synced 2024-11-29 05:58:50 +03:00
Better solution
This commit is contained in:
parent
faef2fba9a
commit
2d7bface27
2 changed files with 7 additions and 13 deletions
|
@ -147,21 +147,13 @@ abstract class AbstractLoginFragment2<VB : ViewBinding> : VectorBaseFragment<VB>
|
|||
}
|
||||
}
|
||||
|
||||
final override fun invalidate() {
|
||||
withState(loginViewModel) { state ->
|
||||
final override fun invalidate() = withState(loginViewModel) { state ->
|
||||
// True when email is sent with success to the homeserver
|
||||
isResetPasswordStarted = state.resetPasswordEmail.isNullOrBlank().not()
|
||||
|
||||
updateWithState(state)
|
||||
}
|
||||
|
||||
invalidateMore()
|
||||
}
|
||||
|
||||
protected open fun invalidateMore() {
|
||||
// No op by default
|
||||
}
|
||||
|
||||
open fun updateWithState(state: LoginViewState2) {
|
||||
// No op by default
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ class AccountCreatedFragment @Inject constructor(
|
|||
setupClickListener()
|
||||
setupSubmitButton()
|
||||
observeViewEvents()
|
||||
|
||||
viewModel.subscribe { invalidateState(it) }
|
||||
}
|
||||
|
||||
private fun observeViewEvents() {
|
||||
|
@ -121,7 +123,7 @@ class AccountCreatedFragment @Inject constructor(
|
|||
loginViewModel.handle(LoginAction2.Finish)
|
||||
}
|
||||
|
||||
override fun invalidateMore() = withState(viewModel) { state ->
|
||||
private fun invalidateState(state: AccountCreatedViewState) {
|
||||
// Ugly hack...
|
||||
(activity as? LoginActivity2)?.setIsLoading(state.isLoading)
|
||||
|
||||
|
|
Loading…
Reference in a new issue