coopcycle / coopcycle-app

CoopCycle native app
MIT License
151 stars 33 forks source link

Rider's TaskList not automatically refreshing correctly when coming in foreground #1807

Open Atala opened 1 week ago

Atala commented 1 week ago

It seems that the rider doesn't get the tasklist updated all the time when the app comes form the background to the foreground. ex: arriving at the restaurant. So naofood and eraman are asking their riders every time they arrive at restaurant.

Root cause may be the websocket connection being broken + no hard refresh https://github.com/coopcycle/coopcycle-ops/issues/78

We propose to do a hard refresh of assigned tasks when the app comes into the background (load from api, same as when we change tasks). to gain more robustness.

vladimir-8 commented 1 week ago

I think it's a good addition. If we start using RTK query in the mobile app, it already has it implemented: https://redux-toolkit.js.org/rtk-query/usage/cache-behavior#re-fetching-on-window-focus-with-refetchonfocus

FYI:

We currently update the task list ("hard-refresh") in two cases (1) when a rider clicks on a notification in the Notification center and (2) when they click on a popup. One issue might be is that the popup disappears in a few seconds, so the task list stays outdated (if the websocket connection is also broken). I had been refactoring notifications in auto-accept branch and added a "hard-refresh": https://github.com/coopcycle/coopcycle-app/pull/1736/commits/931f9a2261ef20f527f0591558be19a00802b8f8 if a push notification is received in the foreground (it only works on Android, on iOS push notification is displayed in the notification center even if the app is in the foreground)

If we implemented automatic refresh maybe we can remove "hard refresh" from both the popup and PushNotificationMiddleware

Atala commented 1 week ago

yes good for me :+1:

i think the thing with react query is nice, but may need some refinement to work on mobile