Closed FlorianCassayre closed 3 years ago
Because of this change, nothing prevents the user from making concurrent requests using the history (ie. clicking on the "back" button several times). Therefore we need to handle these cases to avoid race conditions: see 15457b6
.
I used the following widespread pattern for requests:
Imagine that the user previously visited B, A and C in this order. Now the user clicks on "back" twice. The following scenarios can occur:
PR was revised:
SET_QUERY_STATE
was updating the state instead of setting (= replacing) it, I fixed it and removed the newly created actionq
which is meant to appear firstreplaceUrl
since now the replaced url has no changeChanges:
case SET_QUERY_STATE:
return {
...state,
...INITIAL_QUERY_STATE,
- ...action.payload,
+ ...updateQueryState(INITIAL_QUERY_STATE, action.payload, INITIAL_QUERY_STATE_KEYS),
};
INITIAL_QUERY_STATE
is required for the filters to be correctly reset.
Tested on zenodo demo and on ILS. Also tested on CDS videos demo which has disabled support for url handling.
It may not be the best way to do it, but it works. I'm preventing the url from being updated twice: this is a workaround (I hope temporary) because the url is replaced twice, and even though the state is equivalent in both cases the order of the attributes is not.
Open to suggestions.