mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-09-27 15:32:59 +00:00
Move handleSplitMove to common hook
This commit is contained in:
@@ -62,8 +62,8 @@ const HomePage =(props)=>{
|
||||
const [autoSaveEnabled, setAutoSaveEnabled] = useState(false);
|
||||
const [warnUnsavedChanges, setWarnUnsavedChanges] = useState(true);
|
||||
|
||||
const editorRef = useRef(null);
|
||||
const lastSavedBrew = useRef(_.cloneDeep(props.brew));
|
||||
const editorRef = useRef(null);
|
||||
const lastSavedBrew = useRef(_.cloneDeep(props.brew));
|
||||
const warnUnsavedTimeout = useRef(null);
|
||||
|
||||
const save = ()=>{
|
||||
@@ -79,10 +79,6 @@ const HomePage =(props)=>{
|
||||
});
|
||||
};
|
||||
|
||||
const handleSplitMove = ()=>{
|
||||
editorRef.current.update();
|
||||
};
|
||||
|
||||
const resetWarnUnsavedTimer = ()=>{
|
||||
setTimeout(()=>setWarnUnsavedChanges(false), UNSAVED_WARNING_POPUP_TIMEOUT); // Hide the warning after 4 seconds
|
||||
clearTimeout(warnUnsavedTimeout.current);
|
||||
@@ -145,7 +141,8 @@ const HomePage =(props)=>{
|
||||
</Navbar>;
|
||||
};
|
||||
|
||||
const {
|
||||
const {
|
||||
handleSplitMove,
|
||||
handleBrewChange
|
||||
} = useCommonEditPageFunctions({
|
||||
setError,
|
||||
@@ -166,7 +163,8 @@ const HomePage =(props)=>{
|
||||
unsavedChanges,
|
||||
setUnsavedChanges,
|
||||
sandbox,
|
||||
lastSavedBrew
|
||||
lastSavedBrew,
|
||||
editorRef
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user