fix: resolve stale state in pull-to-refresh and tie spinner to actual data load (#1042)#1144
fix: resolve stale state in pull-to-refresh and tie spinner to actual data load (#1042)#1144vedant7007 wants to merge 1 commit into
Conversation
|
Thank you @, for creating the PR and contributing to our UltimateHealth project 💗. |
|
Hi maintainers, Regarding the 3 failing checks — none are related to this PR's changes:
PR #1122 has the same 3 failures for the same reasons. Typecheck, lint, and Expo Doctor all pass on this PR. Happy to make any changes to the actual code if needed! |
Closes #1042
pull-to-refresh was broken when the user scrolled past page 1. two bugs:
bug 1 — stale page closure: setPage(1) is async but page === 1 was read synchronously on the same tick. if user was on page 3, the condition failed and refetch() never ran.
bug 2 — premature spinner: setRefreshing(false) fired synchronously so the spinner disappeared instantly while data was still loading in the background.
what i fixed:
stale page (approach: remove guard, always refetch):
premature spinner (approach: useEffect on isFetching):
bonus fixes:
1 file changed. typecheck passes.
for labels i think gssoc:approved + level:intermediate + type:bug + quality:clean fits here. happy to make changes if needed!