mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-22 16:36:58 +00:00
Move "unsaved changes" check to common hook
This commit is contained in:
1 parent
b116730925
commit
b9ae2cd16c
4 files changed
+22
-25
No files matched your search
@@ -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