Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid routes to be overwritten when set in the store #314

Merged

Conversation

beawar
Copy link
Contributor

@beawar beawar commented Aug 18, 2023

Sometimes the module are not shown in the primary bar even if they are loaded right. By logging the draft of the addRoute producer, it seems that the order of execution of the addRoute, plus the direct set made by the default views, make the primary views array length change in an unpredictable way. Sometimes happens that the length in the execution n is greater than the length in the execution n+1.

This fix aims to avoid this kind of race condition, by registering all the routes (so even the default ones) through the setters provided by the store. In the setters, the curried produce of immer is used to update the store through a direct modification of the draftState. By doing so, there should not be present anymore the situation where the state is entirely replaced by an older version of the draft, since the draft is always incrementally updated with the push (to add) and the splice (to remove), and never replaced with a direct assignation.

refs: SHELL-152

beawar added 2 commits August 18, 2023 14:19
Sometimes the module are not shown in the primary bar even if they are loaded right.
Logging the draft of the addRoute producer, it seems that the order of execution
of the addRoute, plus the direct set made by the default views, makes the primary views
array lenght change in an unpredictable way. Sometimes happens that the length in the
execution n is greater then the lenght in the exectution n+1.

This fix aims to avoid this kind of race condition, by registering all the routes
(so even the default ones) through the setters provided by the store.
In the setters, the curried produce of immer is used to update the store through a
direct modification of the draftState. By doing so, there should not present anymore
the situation where the state is entirely replaced by an older version of the draft,
since the draft is always incrementally updated with the push (to add) and the splice
(to remove), and nevere replaced with a direct assignation.

refs: SHELL-152
@beawar beawar self-assigned this Aug 18, 2023
@beawar beawar marked this pull request as ready for review August 18, 2023 14:32
@beawar beawar requested review from a team as code owners August 18, 2023 14:32
@beawar beawar requested review from dhavaldodiya, giuliano176 and AlessioCrestani and removed request for a team August 18, 2023 14:32
@beawar
Copy link
Contributor Author

beawar commented Aug 21, 2023

I've created the PR towards release, but it is better to merge it in devel first to follow the usual flow

@beawar beawar changed the base branch from release to devel August 21, 2023 08:18
@beawar beawar merged commit af5f0d8 into devel Aug 23, 2023
@beawar beawar deleted the SHELL-152-sometimes-modules-are-not-shown-inside-primary-bar branch August 23, 2023 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants