0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 16:32:40 +00:00

Linting and move checkLocalStorage inside confirmLocalStorageChange

This commit is contained in:
Trevor Buckner
2025-11-17 23:48:56 -05:00
parent 033893361d
commit 429ad4d63b

View File

@@ -34,25 +34,20 @@ const NewBrew = ()=>{
alert(`This file is invalid: ${!type ? 'Missing file extension' :`.${type} files are not supported`}. Only .txt files exported from the Homebrewery are allowed.`); alert(`This file is invalid: ${!type ? 'Missing file extension' :`.${type} files are not supported`}. Only .txt files exported from the Homebrewery are allowed.`);
console.log(file); console.log(file);
}; };
reader.readAsText(file); reader.readAsText(file);
}; };
const checkLocalStorage = ()=>{ const confirmLocalStorageChange = ()=>{
// Check if changes exist for New editor
const currentText = localStorage.getItem(BREWKEY); const currentText = localStorage.getItem(BREWKEY);
const currentStyle = localStorage.getItem(STYLEKEY); const currentStyle = localStorage.getItem(STYLEKEY);
const currentMeta = localStorage.getItem(METAKEY); const currentMeta = localStorage.getItem(METAKEY);
return (currentText || currentStyle || currentMeta);
};
const confirmLocalStorageChange = ()=>{
// TRUE if no data in any local storage key // TRUE if no data in any local storage key
// TRUE if data in any local storage key AND approval given // TRUE if data in any local storage key AND approval given
// FALSE if data in any local storage key AND approval declined // FALSE if data in any local storage key AND approval declined
return (!checkLocalStorage() || confirm( return (!(currentText || currentStyle || currentMeta) || confirm(
`You have made changes in the new brew space. If you continue, that information will be PERMANENTLY LOST.\nAre you sure you wish to continue?` `You have made changes in the new brew space. If you continue, that information will be PERMANENTLY LOST.\nAre you sure you wish to continue?`
)); ));
}; };
@@ -83,7 +78,7 @@ const NewBrew = ()=>{
newTab={true} newTab={true}
color='purple' color='purple'
icon='fa-solid fa-file'> icon='fa-solid fa-file'>
resume editing resume draft
</Nav.item> </Nav.item>
<Nav.item <Nav.item
className='fromBlank' className='fromBlank'
@@ -93,7 +88,6 @@ const NewBrew = ()=>{
onClick={()=>{ clearLocalStorage(); }}> onClick={()=>{ clearLocalStorage(); }}>
from blank from blank
</Nav.item> </Nav.item>
<Nav.item <Nav.item
className='fromFile' className='fromFile'
color='green' color='green'