Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 158e154

Browse files
feat: added boolean to know if filters are all empty/unused
1 parent ca71283 commit 158e154

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/renderer/components/FiltersContext/FiltersContext.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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

3435
const 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 (

0 commit comments

Comments
 (0)