Right now the Redux code is more challenging to understand and maintain than it needs to be. We should refactor the Redux code to bring it closer to the official Redux Style Guide.
Priority A/Essential:
Reducers should not call new Date(). Our reducers which do this are violating the basic rule of "Reducers Must Not Have Side Effects"; they are related to the backend heartbeat/disconnected actions, which as of #340 has been moved from the controller section of the store to the app section of the store. Instead, the component which is dispatching the action should generate the date for the action, and the reducer should simply copy that date into the store.
Priority B/Strongly Recommended:
We should structure files as feature folders with single-file logic, rather than having one file for all types, one file for all selectors, etc. Anywhere where we're using combineReducers is a good candidate for moving related functionalities into its own folder. As another example, code related to the connection to the backend (mainly actions and sagas) could be split off.
We should improve the naming of actions to reflect that they are events, rather than setters, and to make them more specific where possible (#340 has added some TODO comments for this).
Where we are dispatching multiple actions consecutively (e.g. when a component dispatches both commitRequest and commitStandbyRequest), we should batch them.
We may want to use Redux Toolkit, which can help catch mutations, organize slices of the store, etc. (but it might be too much work to try to use slices, as that may require a deeper re-architecting of the redux code)
Priority C/Recommended:
Where we can use memoized, granular selectors instead of reading directly from the store, let's do it. This will help us avoid unnecessary redraws of UI components, which adds a noticeable performance overhead on our Raspberry Pi.
Let's use camelCase rather than SCREAMING_SNAKE_CASE for action names.
We could consider writing actions using the Flux standard convention, but maybe we can ignore this recommendation.
Right now the Redux code is more challenging to understand and maintain than it needs to be. We should refactor the Redux code to bring it closer to the official Redux Style Guide.
Priority A/Essential:
new Date()
. Our reducers which do this are violating the basic rule of "Reducers Must Not Have Side Effects"; they are related to the backend heartbeat/disconnected actions, which as of #340 has been moved from the controller section of the store to the app section of the store. Instead, the component which is dispatching the action should generate the date for the action, and the reducer should simply copy that date into the store.Priority B/Strongly Recommended:
combineReducers
is a good candidate for moving related functionalities into its own folder. As another example, code related to the connection to the backend (mainly actions and sagas) could be split off.commitRequest
andcommitStandbyRequest
), we should batch them.Priority C/Recommended: