This repository was archived by the owner on May 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/renderer/components/FiltersContext Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ type FiltersContextType = FilterTypes & {
2929 setPrivacy : React . Dispatch < React . SetStateAction < PrivacyType > > ;
3030 setIsSubscribed : React . Dispatch < React . SetStateAction < IsSubscribedType > > ;
3131 resetAllFilters : ( ) => void ;
32+ isEmpty : boolean ;
3233} ;
3334
3435const FiltersContext = createContext ( { } as FiltersContextType ) ;
@@ -43,6 +44,15 @@ export const FiltersProvider = ({ children }: { children: ReactNode }) => {
4344 const [ privacy , setPrivacy ] = useState < PrivacyType > ( 'all' ) ;
4445 const [ isSubscribed , setIsSubscribed ] = useState ( false ) ;
4546
47+ // check if all the filters are empty
48+ const isEmpty =
49+ ! searchTerm &&
50+ language === Language . ALL_LANGUAGES &&
51+ ! library &&
52+ ! tags &&
53+ privacy === 'all' &&
54+ isSubscribed === false ;
55+
4656 const resetAllFilters = ( ) => {
4757 setSearchTerm ( '' ) ;
4858 setLanguage ( Language . ALL_LANGUAGES ) ;
@@ -66,6 +76,7 @@ export const FiltersProvider = ({ children }: { children: ReactNode }) => {
6676 isSubscribed,
6777 setIsSubscribed,
6878 resetAllFilters,
79+ isEmpty,
6980 } ;
7081
7182 return (
You can’t perform that action at this time.
0 commit comments