Closed yeahphil closed 3 years ago
Is there no way to indicate that the request is still in flight? Isn't there a guard to make sure that we don't have two simultaneous requests? So what happens in the following scenario:
Will it just not update until the first request comes back?
Ah yes, we should be able to accurately say if a request is in flight. I was trying to work around the refresh control being visible but not animating if you switch tabs while a request is in flight. I'm not sure what's up with that, but I saw the same behavior. Calling endRefreshing()
then beginRefreshing()
from viewWillAppear doesn't do the right thing and leaves the control in a weird state. So as a quick coverup, I figured, leave the control refreshing but don't set it to be visible. Not really the right answer of course.
We've now got ReachUpdater
managing/limiting requests (via its static isFetchingReaches
property), but only for updateReaches(regionCodes:)
. Maybe the right answer is:
isFetchingReaches
for both updateReaches(regionCodes:)
and updateReaches(reachIds:)
(i.e. all the requests that can update multiple reaches). isFetchingReaches
should reliably answer the question, is a Reach request in flight?endRefreshing()
on viewDidDisappear
beginRefreshing
on viewWillAppear
if a request is in flightI worry maintaining the state of isFetchingReaches
will end up getting messed up, or have some concurrency/race issue and wedge the app. But I suppose we're there now, just inconsistently and with more complex behavior.
Having a central place like ReachUpdater
to keep track of this state sounds good. Maybe we should consider some sort of safety for that boolean though. For instance, maybe put a timeout of 30s or something, so it can recover if it somehow gets wedged?
See https://console.firebase.google.com/u/1/project/american-whitewater-1234/crashlytics/app/ios:org.americanwhitewater.aw/issues/a8f7361272c0a9c9c4b3250363c6ae35?time=last-seven-days&versions=1.4.0%20(2)&sessionEventKey=e805326fff5e46829f79384bc7339b58_1592225718857010802