mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-09-20 14:32:57 +00:00
reducing lines
This commit is contained in:
@@ -24,14 +24,22 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
const sortTypeRef = useRef(sortType);
|
const sortTypeRef = useRef(sortType);
|
||||||
const sortDirRef = useRef(sortDir);
|
const sortDirRef = useRef(sortDir);
|
||||||
|
|
||||||
useEffect(()=>(groupVisibilityRef.current = groupVisibility), [groupVisibility]);
|
useEffect(()=>{
|
||||||
useEffect(()=>(sortTypeRef.current = sortType), [sortType]);
|
groupVisibilityRef.current = groupVisibility;
|
||||||
useEffect(()=>(sortDirRef.current = sortDir), [sortDir]);
|
}, [groupVisibility]);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
sortTypeRef.current = sortType;
|
||||||
|
}, [sortType]);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
sortDirRef.current = sortDir;
|
||||||
|
}, [sortDir]);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
window.onbeforeunload = saveToLocalStorage;
|
window.onbeforeunload = saveToLocalStorage;
|
||||||
|
|
||||||
if(typeof window === 'undefined') return;
|
if(typeof window === 'undefined') return;
|
||||||
|
|
||||||
const newSortType = sortType ?? (localStorage.getItem(USERPAGE_SORT_TYPE) || DEFAULT_SORT_TYPE);
|
const newSortType = sortType ?? (localStorage.getItem(USERPAGE_SORT_TYPE) || DEFAULT_SORT_TYPE);
|
||||||
const newSortDir = sortDir ?? (localStorage.getItem(USERPAGE_SORT_DIR) || DEFAULT_SORT_DIR);
|
const newSortDir = sortDir ?? (localStorage.getItem(USERPAGE_SORT_DIR) || DEFAULT_SORT_DIR);
|
||||||
updateUrl(filterString, newSortType, newSortDir);
|
updateUrl(filterString, newSortType, newSortDir);
|
||||||
@@ -61,18 +69,16 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
const renderBrews = (brews)=>{
|
const renderBrews = (brews)=>{
|
||||||
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
||||||
|
|
||||||
return _.map(brews, (brew, idx)=>{
|
return _.map(brews, (brew, idx)=>(
|
||||||
return (
|
<BrewItem
|
||||||
<BrewItem
|
brew={brew}
|
||||||
brew={brew}
|
key={idx}
|
||||||
key={idx}
|
reportError={reportError}
|
||||||
reportError={reportError}
|
updateListFilter={(tag)=>{
|
||||||
updateListFilter={(tag)=>{
|
updateUrl(filterString, sortType, sortDir, tag);
|
||||||
updateUrl(filterString, sortType, sortDir, tag);
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
));
|
||||||
);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const sortBrewOrder = (brew)=>{
|
const sortBrewOrder = (brew)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user