mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-09-25 13:42:57 +00:00
Move "unsaved changes" check to common hook
This commit is contained in:
@@ -93,7 +93,9 @@ const NewPage = (props)=>{
|
||||
setWarnUnsavedChanges,
|
||||
trySaveRef,
|
||||
unsavedChangesRef,
|
||||
sandbox
|
||||
setUnsavedChanges,
|
||||
sandbox,
|
||||
lastSavedBrew
|
||||
});
|
||||
|
||||
const loadBrew = ()=>{
|
||||
@@ -125,13 +127,6 @@ const NewPage = (props)=>{
|
||||
window.history.replaceState({}, window.location.title, '/new/');
|
||||
};
|
||||
|
||||
useEffect(()=>{
|
||||
const hasChange = !_.isEqual(currentBrew, lastSavedBrew.current);
|
||||
setUnsavedChanges(hasChange);
|
||||
|
||||
if(autoSaveEnabled) trySave(false, hasChange);
|
||||
}, [currentBrew]);
|
||||
|
||||
useEffect(()=>{
|
||||
trySaveRef.current = trySave;
|
||||
unsavedChangesRef.current = unsavedChanges;
|
||||
|
||||
Reference in New Issue
Block a user