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 & {
29
29
setPrivacy : React . Dispatch < React . SetStateAction < PrivacyType > > ;
30
30
setIsSubscribed : React . Dispatch < React . SetStateAction < IsSubscribedType > > ;
31
31
resetAllFilters : ( ) => void ;
32
+ isEmpty : boolean ;
32
33
} ;
33
34
34
35
const FiltersContext = createContext ( { } as FiltersContextType ) ;
@@ -43,6 +44,15 @@ export const FiltersProvider = ({ children }: { children: ReactNode }) => {
43
44
const [ privacy , setPrivacy ] = useState < PrivacyType > ( 'all' ) ;
44
45
const [ isSubscribed , setIsSubscribed ] = useState ( false ) ;
45
46
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
+
46
56
const resetAllFilters = ( ) => {
47
57
setSearchTerm ( '' ) ;
48
58
setLanguage ( Language . ALL_LANGUAGES ) ;
@@ -66,6 +76,7 @@ export const FiltersProvider = ({ children }: { children: ReactNode }) => {
66
76
isSubscribed,
67
77
setIsSubscribed,
68
78
resetAllFilters,
79
+ isEmpty,
69
80
} ;
70
81
71
82
return (
You can’t perform that action at this time.
0 commit comments