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) {
2121 fun isLoadingMore () = this == LOADING_MORE
2222
2323 companion object {
24- val defaultState = ListState .NEEDS_REFRESH
24+ val defaultState = NEEDS_REFRESH
25+ val notExpiredStates = setOf (CAN_LOAD_MORE , FETCHED )
2526 }
2627}
Original file line number Diff line number Diff line change @@ -351,14 +351,17 @@ class ListStore @Inject constructor(
351351 /* *
352352 * A helper function that returns the [ListState] for the given [ListDescriptor].
353353 */
354- private fun getListState (listDescriptor : ListDescriptor ): ListState {
354+ fun getListState (listDescriptor : ListDescriptor ): ListState {
355355 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 }) {
358358 " The stateDbValue of the ListModel didn't match any of the `ListState`s. This likely happened " +
359359 " because the ListState values were altered without a DB migration."
360360 }
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
362365 }
363366
364367 /* *
You can’t perform that action at this time.
0 commit comments