From 6c175d0b7f098cbb9f05b4614a24565c24e50edb Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Fri, 27 Dec 2024 03:32:30 +0100 Subject: [PATCH] Add "started" library filter --- public/locales/en.json | 1 + src/modules/category/services/CategoryMetadata.ts | 1 + src/modules/library/Library.types.ts | 1 + src/modules/library/components/LibraryOptionsPanel.tsx | 5 +++++ src/modules/library/components/LibraryToolbarMenu.tsx | 1 + src/modules/library/hooks/useGetVisibleLibraryMangas.ts | 9 ++++++++- src/modules/metadata/Metadata.constants.ts | 2 ++ 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/locales/en.json b/public/locales/en.json index 95fd6fd9..e1520359 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -380,6 +380,7 @@ "bookmarked": "Bookmarked", "downloaded": "Downloaded", "duplicate_chapters": "Duplicate chapters", + "started": "Started", "tracked": "Tracked", "unread": "Unread" } diff --git a/src/modules/category/services/CategoryMetadata.ts b/src/modules/category/services/CategoryMetadata.ts index 695d621d..94861324 100644 --- a/src/modules/category/services/CategoryMetadata.ts +++ b/src/modules/category/services/CategoryMetadata.ts @@ -38,6 +38,7 @@ export const DEFAULT_CATEGORY_METADATA: ICategoryMetadata = { hasDownloadedChapters: undefined, hasBookmarkedChapters: undefined, hasUnreadChapters: undefined, + hasReadChapters: undefined, hasDuplicateChapters: undefined, hasTrackerBinding: {}, hasStatus: {} as LibraryOptions['hasStatus'], diff --git a/src/modules/library/Library.types.ts b/src/modules/library/Library.types.ts index ae39fcaf..8159f2e6 100644 --- a/src/modules/library/Library.types.ts +++ b/src/modules/library/Library.types.ts @@ -40,6 +40,7 @@ export interface LibraryOptions { hasDownloadedChapters: NullAndUndefined; hasBookmarkedChapters: NullAndUndefined; hasUnreadChapters: NullAndUndefined; + hasReadChapters: NullAndUndefined; hasDuplicateChapters: NullAndUndefined; hasTrackerBinding: Record>; hasStatus: Record>; diff --git a/src/modules/library/components/LibraryOptionsPanel.tsx b/src/modules/library/components/LibraryOptionsPanel.tsx index f2761e57..86f57012 100644 --- a/src/modules/library/components/LibraryOptionsPanel.tsx +++ b/src/modules/library/components/LibraryOptionsPanel.tsx @@ -88,6 +88,11 @@ export const LibraryOptionsPanel = ({ checked={categoryLibraryOptions.hasUnreadChapters} onChange={(c) => updateCategoryLibraryOptions('hasUnreadChapters', c)} /> + updateCategoryLibraryOptions('hasReadChapters', c)} + /> hasStatus != null) || diff --git a/src/modules/library/hooks/useGetVisibleLibraryMangas.ts b/src/modules/library/hooks/useGetVisibleLibraryMangas.ts index 380a22a8..b1a3d37b 100644 --- a/src/modules/library/hooks/useGetVisibleLibraryMangas.ts +++ b/src/modules/library/hooks/useGetVisibleLibraryMangas.ts @@ -103,6 +103,7 @@ const statusFilter = (statusFilters: LibraryOptions['hasStatus'], manga: TMangaS type TMangaFilterOptions = Pick< LibraryOptions, | 'hasUnreadChapters' + | 'hasReadChapters' | 'hasDownloadedChapters' | 'hasBookmarkedChapters' | 'hasDuplicateChapters' @@ -111,12 +112,14 @@ type TMangaFilterOptions = Pick< >; type TMangaFilter = Pick & TMangaTrackerFilter & - TMangaStatusFilter; + TMangaStatusFilter & + MangaChapterCountInfo; const filterManga = ( manga: TMangaFilter, { hasDownloadedChapters, hasUnreadChapters, + hasReadChapters, hasBookmarkedChapters, hasDuplicateChapters, hasTrackerBinding, @@ -125,6 +128,7 @@ const filterManga = ( ): boolean => triStateFilterNumber(hasDownloadedChapters, manga.downloadCount) && triStateFilterNumber(hasUnreadChapters, manga.unreadCount) && + triStateFilterNumber(hasReadChapters, manga.chapters.totalCount - manga.unreadCount) && triStateFilterNumber(hasBookmarkedChapters, manga.bookmarkCount) && triStateFilterBoolean(hasDuplicateChapters, manga.hasDuplicateChapters) && trackerFilter(hasTrackerBinding, manga) && @@ -210,6 +214,7 @@ export const useGetVisibleLibraryMangas = = { hasDownloadedChapters: undefined, hasBookmarkedChapters: undefined, hasUnreadChapters: undefined, + hasReadChapters: undefined, hasDuplicateChapters: undefined, hasTrackerBinding: undefined, hasStatus: undefined, @@ -91,6 +92,7 @@ export const GLOBAL_METADATA_KEYS: AppMetadataKeys[] = [ 'hasDownloadedChapters', 'hasBookmarkedChapters', 'hasUnreadChapters', + 'hasReadChapters', 'hasDuplicateChapters', 'hasTrackerBinding', 'hasStatus',