From 8cd1afd2c725e015f8480f51eb0a2965585053d2 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 11 Mar 2023 19:12:43 +0100 Subject: [PATCH] Ignore filters only while searching (#256) In case the "ignoreFilters" flag was set to true and the search string was empty/undefined all mangas of the category were visible, ignoring the set filters. --- src/components/library/LibraryMangaGrid.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/library/LibraryMangaGrid.tsx b/src/components/library/LibraryMangaGrid.tsx index f733f0e8..60cda260 100644 --- a/src/components/library/LibraryMangaGrid.tsx +++ b/src/components/library/LibraryMangaGrid.tsx @@ -56,11 +56,14 @@ const filterManga = ( downloaded: NullAndUndefined, ignoreFilters: boolean, ): IMangaCard[] => - mangas.filter( - (manga) => - (queryFilter(query, manga) || queryGenreFilter(query, manga)) && - (ignoreFilters || (downloadedFilter(downloaded, manga) && unreadFilter(unread, manga))), - ); + mangas.filter((manga) => { + const ignoreFiltersWhileSearching = ignoreFilters && query?.length; + const matchesSearch = queryFilter(query, manga) || queryGenreFilter(query, manga); + const matchesFilters = + ignoreFiltersWhileSearching || (downloadedFilter(downloaded, manga) && unreadFilter(unread, manga)); + + return matchesSearch && matchesFilters; + }); const sortByUnread = (a: IMangaCard, b: IMangaCard): number => // eslint-disable-next-line implicit-arrow-linebreak