nusmods
nusmods copied to clipboard
Undoing removing module is not properly persisted
To reproduce:
- Remove a module from the timetable
- Undo the removal
- The module will show up again, as expected. Now refresh the browser
- The module will be gone
This is because of poor interaction between redux-persist, the library we're using to persist the Redux state, and our undo solution. Specifically, Redux Persist is operating on the sub-reducers, while the undo reducer is operating on the root state, so the undo is applied after the state has been persisted. https://github.com/nusmodifications/nusmods/blob/master/www/src/js/reducers/index.js#L68
The best way to fix this I think is to move the undo reducer to the sub-reducer, instead of it wrapping the root state. If you have another better solution I'm also happy to hear it.
This is a relatively major issue, so it would be good to get this fixed as soon as possible.
@taneliang again