mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-19 07:42:42 +00:00
Linting
This commit is contained in:
@@ -9,8 +9,7 @@ import _ from 'lodash';;
|
|||||||
import { makePatches, stringifyPatches } from '@sanity/diff-match-patch';
|
import { makePatches, stringifyPatches } from '@sanity/diff-match-patch';
|
||||||
import { md5 } from 'hash-wasm';
|
import { md5 } from 'hash-wasm';
|
||||||
import { gzipSync, strToU8 } from 'fflate';
|
import { gzipSync, strToU8 } from 'fflate';
|
||||||
|
import { Meta } from 'vitreum/headtags';
|
||||||
const { Meta } = require('vitreum/headtags');
|
|
||||||
|
|
||||||
import Nav from 'naturalcrit/nav/nav.jsx';
|
import Nav from 'naturalcrit/nav/nav.jsx';
|
||||||
import Navbar from '../../navbar/navbar.jsx';
|
import Navbar from '../../navbar/navbar.jsx';
|
||||||
@@ -65,7 +64,6 @@ const EditPage = (props) => {
|
|||||||
|
|
||||||
const editorRef = useRef(null);
|
const editorRef = useRef(null);
|
||||||
const savedBrew = useRef(_.cloneDeep(props.brew));
|
const savedBrew = useRef(_.cloneDeep(props.brew));
|
||||||
const warningTimer = useRef(null);
|
|
||||||
const debounceSave = useCallback(_.debounce((brew, saveToGoogle)=>save(brew, saveToGoogle), SAVE_TIMEOUT), []);
|
const debounceSave = useCallback(_.debounce((brew, saveToGoogle)=>save(brew, saveToGoogle), SAVE_TIMEOUT), []);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
@@ -73,7 +71,7 @@ const EditPage = (props) => {
|
|||||||
|
|
||||||
const autoSavePref = JSON.parse(localStorage.getItem('AUTOSAVE_ON') ?? true);
|
const autoSavePref = JSON.parse(localStorage.getItem('AUTOSAVE_ON') ?? true);
|
||||||
setAutoSaveEnabled(autoSavePref);
|
setAutoSaveEnabled(autoSavePref);
|
||||||
setAutoSaveWarning(!autoSavePref)
|
setAutoSaveWarning(!autoSavePref);
|
||||||
setHTMLErrors(Markdown.validate(currentBrew.text));
|
setHTMLErrors(Markdown.validate(currentBrew.text));
|
||||||
fetchThemeBundle(setError, setThemeBundle, currentBrew.renderer, currentBrew.theme);
|
fetchThemeBundle(setError, setThemeBundle, currentBrew.renderer, currentBrew.theme);
|
||||||
|
|
||||||
@@ -132,7 +130,7 @@ const EditPage = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleStyleChange = (style)=>{
|
const handleStyleChange = (style)=>{
|
||||||
setCurrentBrew(prevBrew => ({ ...prevBrew, style }));
|
setCurrentBrew((prevBrew)=>({ ...prevBrew, style }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSnipChange = (snippet)=>{
|
const handleSnipChange = (snippet)=>{
|
||||||
@@ -146,11 +144,10 @@ const EditPage = (props) => {
|
|||||||
if(field === 'theme' || field === 'renderer')
|
if(field === 'theme' || field === 'renderer')
|
||||||
fetchThemeBundle(setError, setThemeBundle, metadata.renderer, metadata.theme);
|
fetchThemeBundle(setError, setThemeBundle, metadata.renderer, metadata.theme);
|
||||||
|
|
||||||
setCurrentBrew(prev => ({ ...prev, ...metadata }));
|
setCurrentBrew((prev)=>({ ...prev, ...metadata }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateBrew = (newData) =>
|
const updateBrew = (newData)=>setCurrentBrew((prevBrew)=>({
|
||||||
setCurrentBrew((prevBrew) => ({
|
|
||||||
...prevBrew,
|
...prevBrew,
|
||||||
style : newData.style,
|
style : newData.style,
|
||||||
text : newData.text,
|
text : newData.text,
|
||||||
@@ -307,7 +304,7 @@ const EditPage = (props) => {
|
|||||||
|
|
||||||
// #3 - Unsaved changes exist, click to save, show SAVE NOW
|
// #3 - Unsaved changes exist, click to save, show SAVE NOW
|
||||||
if(unsavedChanges)
|
if(unsavedChanges)
|
||||||
return <Nav.item className='save' onClick={() => trySave(true)} color='blue' icon='fas fa-save'>Save Now</Nav.item>
|
return <Nav.item className='save' onClick={()=>trySave(true)} color='blue' icon='fas fa-save'>Save Now</Nav.item>;
|
||||||
|
|
||||||
// #4 - No unsaved changes, autosave is ON, show AUTO-SAVED
|
// #4 - No unsaved changes, autosave is ON, show AUTO-SAVED
|
||||||
if(autoSaveEnabled)
|
if(autoSaveEnabled)
|
||||||
|
|||||||
Reference in New Issue
Block a user