0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-17 16:42:41 +00:00

Update Autosave key

This commit is contained in:
G.Ambatte
2025-09-10 20:00:53 +12:00
parent fd370c777d
commit 5504c1b96b

View File

@@ -38,6 +38,8 @@ const SAVE_TIMEOUT = 10000;
const UNSAVED_WARNING_TIMEOUT = 900000; //Warn user afer 15 minutes of unsaved changes const UNSAVED_WARNING_TIMEOUT = 900000; //Warn user afer 15 minutes of unsaved changes
const UNSAVED_WARNING_POPUP_TIMEOUT = 4000; //Show the warning for 4 seconds const UNSAVED_WARNING_POPUP_TIMEOUT = 4000; //Show the warning for 4 seconds
const AUTOSAVE_KEY = 'HB_editor_autoSaveOn';
const EditPage = (props)=>{ const EditPage = (props)=>{
props = { props = {
brew : DEFAULT_BREW_LOAD, brew : DEFAULT_BREW_LOAD,
@@ -70,7 +72,7 @@ const EditPage = (props)=>{
useEffect(()=>{ useEffect(()=>{
setUrl(window.location.href); setUrl(window.location.href);
const autoSavePref = JSON.parse(localStorage.getItem('AUTOSAVE_ON') ?? true); const autoSavePref = JSON.parse(localStorage.getItem(AUTOSAVE_KEY) ?? true);
setAutoSaveEnabled(autoSavePref); setAutoSaveEnabled(autoSavePref);
setAutoSaveWarning(!autoSavePref); setAutoSaveWarning(!autoSavePref);
setHTMLErrors(Markdown.validate(currentBrew.text)); setHTMLErrors(Markdown.validate(currentBrew.text));
@@ -317,7 +319,7 @@ const EditPage = (props)=>{
const toggleAutoSave = ()=>{ const toggleAutoSave = ()=>{
if(warningTimer.current) clearTimeout(warningTimer.current); if(warningTimer.current) clearTimeout(warningTimer.current);
localStorage.setItem('AUTOSAVE_ON', JSON.stringify(!autoSaveEnabled)); localStorage.setItem(AUTOSAVE_KEY, JSON.stringify(!autoSaveEnabled));
setAutoSaveWarning(autoSaveWarning); setAutoSaveWarning(autoSaveWarning);
setAutoSaveEnabled(!autoSaveEnabled); setAutoSaveEnabled(!autoSaveEnabled);
}; };