Skip to content

Commit

Permalink
compare roadmap with prev state
Browse files Browse the repository at this point in the history
  • Loading branch information
ptruong0 committed Jan 31, 2024
1 parent 3c7c8da commit 115d127
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions site/src/pages/RoadmapPage/Planner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ const Planner: FC = () => {
else {
validatePlanner();

// mark changes as unsaved to alert before leaving page
dispatch(setUnsavedChanges(true));
// check current roadmap against last-saved roadmap in local storage
// if they are different, mark changes as unsaved to enable alert on page leave
const roadmap: SavedRoadmap = {
planner: collapsePlanner(data),
transfers: transfers,
};
dispatch(setUnsavedChanges(localStorage.getItem('roadmap') !== JSON.stringify(roadmap)));
}
}, [data, transfers]);

Expand Down Expand Up @@ -146,7 +151,7 @@ const Planner: FC = () => {
// save to local storage as well
localStorage.setItem('roadmap', JSON.stringify(roadmap));

// mark changes as saved to skip alert on page leave
// mark changes as saved to bypass alert on page leave
dispatch(setUnsavedChanges(false));

if (savedAccount) {
Expand Down

0 comments on commit 115d127

Please sign in to comment.