This repository was archived by the owner on Feb 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
fluxc/src/main/java/org/wordpress/android/fluxc Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ enum class ListState(val value: Int) {
21
21
fun isLoadingMore () = this == LOADING_MORE
22
22
23
23
companion object {
24
- val defaultState = ListState .NEEDS_REFRESH
24
+ val defaultState = NEEDS_REFRESH
25
+ val notExpiredStates = setOf (CAN_LOAD_MORE , FETCHED )
25
26
}
26
27
}
Original file line number Diff line number Diff line change @@ -351,14 +351,17 @@ class ListStore @Inject constructor(
351
351
/* *
352
352
* A helper function that returns the [ListState] for the given [ListDescriptor].
353
353
*/
354
- private fun getListState (listDescriptor : ListDescriptor ): ListState {
354
+ fun getListState (listDescriptor : ListDescriptor ): ListState {
355
355
val listModel = listSqlUtils.getList(listDescriptor)
356
- return if (listModel != null && ! isListStateOutdated( listModel)) {
357
- requireNotNull(ListState .values() .firstOrNull { it.value == listModel.stateDbValue }) {
356
+ val currentState = listModel?. let {
357
+ requireNotNull(ListState .entries .firstOrNull { it.value == listModel.stateDbValue }) {
358
358
" The stateDbValue of the ListModel didn't match any of the `ListState`s. This likely happened " +
359
359
" because the ListState values were altered without a DB migration."
360
360
}
361
- } else ListState .defaultState
361
+ }
362
+ val isListStateValid = currentState != null
363
+ && (isListStateOutdated(listModel).not () || (currentState in ListState .notExpiredStates))
364
+ return if (isListStateValid) currentState!! else ListState .defaultState
362
365
}
363
366
364
367
/* *
You can’t perform that action at this time.
0 commit comments