-
-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better refreshing state indication for AccountActivity #4353
base: develop
Are you sure you want to change the base?
Conversation
…ountActivity (tuskyapp#4345)" This reverts commit 5343766.
Note: you can also remove
in |
Good catch! |
Now the spinner shows up on the initial load which is very irritating imo. |
The state could be enriched with some additional information differentiating an initial load from a refresh. For example, instead of a boolean, use a sealed class:
|
@@ -76,7 +70,7 @@ class AccountViewModel @Inject constructor( | |||
|
|||
private fun obtainAccount(reload: Boolean = false) { | |||
if (_accountData.value == null || reload) { | |||
isDataLoading = true | |||
_refreshState.value = RefreshState.REFRESHING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_refreshState.value = RefreshState.REFRESHING | |
if (reload) { | |
_refreshState.value = RefreshState.REFRESHING | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice here is the key point, can we revert 3d283bd and use your logic here, it's a simple state.
if (reload) {
_isRefreshing.value = true
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ccountViewModel.kt Co-authored-by: Konrad Pozniak <[email protected]>
…r-fix-for-is-refreshing
This reverts commit 3d283bd
@@ -316,7 +310,7 @@ class AccountViewModel @Inject constructor( | |||
} | |||
|
|||
private fun reload(isReload: Boolean = false) { | |||
if (isDataLoading) { | |||
if (_isRefreshing.value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two loads may still be triggered in parallel during the initial load, because _isRefreshing
is not set to true in that case.
Hence I suggest to keep the loading state in a separate field, or merge loading and refreshing states together using a sealed class.
Alternatively, cancel the load in progress before starting a new one.
Refs #4345 (comment).