bratislava / paas-mpa

European Union Public License 1.2
1 stars 0 forks source link

Optimistic update for Notification settings #103

Closed radoslavzeman closed 5 months ago

radoslavzeman commented 7 months ago

(On android) When I switch the Switch e.g. from off to on, it firstly turns to on for a brief moment then off again and then finally on, this is probably caused by the fact that the switches are directly bound to the server data.

Use the "Optimistic updates" pattern here and add an intermediate front end state layer, the Switch would directly switch to the desired value, and we would only handle an erroneous response (a mismatch between the backend and frontend data)

Try: https://tanstack.com/query/latest/docs/react/guides/optimistic-updates

radoslavzeman commented 7 months ago

I tried to implement optimistic update following react query docs, but it still seems to not work on android. https://github.com/bratislava/paas-mpa/pull/122