mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-09-20 16:42:58 +00:00
more linting
This commit is contained in:
@@ -24,35 +24,26 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
const sortTypeRef = useRef(sortType);
|
const sortTypeRef = useRef(sortType);
|
||||||
const sortDirRef = useRef(sortDir);
|
const sortDirRef = useRef(sortDir);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>(groupVisibilityRef.current = groupVisibility), [groupVisibility]);
|
||||||
groupVisibilityRef.current = groupVisibility;
|
useEffect(()=>(sortTypeRef.current = sortType), [sortType]);
|
||||||
}, [groupVisibility]);
|
useEffect(()=>(sortDirRef.current = sortDir), [sortDir]);
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
sortTypeRef.current = sortType;
|
|
||||||
}, [sortType]);
|
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
sortDirRef.current = sortDir;
|
|
||||||
}, [sortDir]);
|
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
window.onbeforeunload = saveToLocalStorage;
|
window.onbeforeunload = saveToLocalStorage;
|
||||||
|
|
||||||
if(typeof window !== 'undefined') {
|
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);
|
||||||
|
|
||||||
const namedBrewCollection = brewCollection.reduce((visibility, brewGroup)=>{
|
const namedBrewCollection = brewCollection.reduce((visibility, brewGroup)=>{
|
||||||
visibility[brewGroup.class] = (localStorage.getItem(`${USERPAGE_GROUP_VISIBILITY_PREFIX}_${brewGroup.class}`) ?? 'true') == 'true';
|
visibility[brewGroup.class] = (localStorage.getItem(`${USERPAGE_GROUP_VISIBILITY_PREFIX}_${brewGroup.class}`) ?? 'true') == 'true';
|
||||||
return visibility;
|
return visibility;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
setGroupVisibility(namedBrewCollection);
|
setGroupVisibility(namedBrewCollection);
|
||||||
setSortType(newSortType);
|
setSortType(newSortType);
|
||||||
setSortDir(newSortDir);
|
setSortDir(newSortDir);
|
||||||
}
|
|
||||||
|
|
||||||
return ()=>{
|
return ()=>{
|
||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
@@ -148,9 +139,7 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
}
|
}
|
||||||
urlParams.delete('tag');
|
urlParams.delete('tag');
|
||||||
// Add tags to URL in the order they were clicked
|
// Add tags to URL in the order they were clicked
|
||||||
filterTags.forEach((tag)=>{
|
filterTags.forEach((tag)=>urlParams.append('tag', tag));
|
||||||
urlParams.append('tag', tag);
|
|
||||||
});
|
|
||||||
// Sort tags before updating state
|
// Sort tags before updating state
|
||||||
filterTags.sort((a, b)=>{
|
filterTags.sort((a, b)=>{
|
||||||
return a.indexOf(':') - b.indexOf(':') != 0 ? a.indexOf(':') - b.indexOf(':') : a.toLowerCase().localeCompare(b.toLowerCase());
|
return a.indexOf(':') - b.indexOf(':') != 0 ? a.indexOf(':') - b.indexOf(':') : a.toLowerCase().localeCompare(b.toLowerCase());
|
||||||
@@ -206,7 +195,6 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
{renderSortOption('Updated Date', 'updated')}
|
{renderSortOption('Updated Date', 'updated')}
|
||||||
{renderSortOption('Views', 'views')}
|
{renderSortOption('Views', 'views')}
|
||||||
{/* {renderSortOption('Latest', 'latest')} */}
|
{/* {renderSortOption('Latest', 'latest')} */}
|
||||||
|
|
||||||
{renderFilterOption()}
|
{renderFilterOption()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -218,7 +206,6 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
brews = _.filter(brews, (brew)=>{
|
brews = _.filter(brews, (brew)=>{
|
||||||
// Filter by user entered text
|
// Filter by user entered text
|
||||||
const brewStrings = _.deburr([brew.title, brew.description, brew.tags].join('\n').toLowerCase());
|
const brewStrings = _.deburr([brew.title, brew.description, brew.tags].join('\n').toLowerCase());
|
||||||
|
|
||||||
const filterTextTest = brewStrings.includes(testString);
|
const filterTextTest = brewStrings.includes(testString);
|
||||||
|
|
||||||
// Filter by user selected tags
|
// Filter by user selected tags
|
||||||
@@ -283,7 +270,6 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='listPage sitePage'>
|
<div className='listPage sitePage'>
|
||||||
{/*<style>@layer V3_5ePHB, bundle;</style>*/}
|
|
||||||
<link href='/themes/V3/Blank/style.css' type='text/css' rel='stylesheet' />
|
<link href='/themes/V3/Blank/style.css' type='text/css' rel='stylesheet' />
|
||||||
<link href='/themes/V3/5ePHB/style.css' type='text/css' rel='stylesheet' />
|
<link href='/themes/V3/5ePHB/style.css' type='text/css' rel='stylesheet' />
|
||||||
{navItems}
|
{navItems}
|
||||||
|
|||||||
Reference in New Issue
Block a user