From 91e1f01de598ff5977a9dc2947f06f601fb7b496 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 5 Oct 2024 19:33:09 +0200 Subject: [PATCH] Move library files into new folder --- src/App.tsx | 9 ++-- src/components/source/GridLayouts.tsx | 2 +- src/components/source/SourceGridLayout.tsx | 2 +- src/lib/metadata/categoryMetadata.ts | 4 +- src/modules/core/Core.types.ts | 13 +++++ src/modules/core/contexts/AppContext.tsx | 2 +- src/modules/library/Library.types.ts | 46 ++++++++++++++++++ .../library/components}/LibraryMangaGrid.tsx | 4 +- .../components}/LibraryOptionsPanel.tsx | 4 +- .../components}/LibraryToolbarMenu.tsx | 4 +- .../contexts}/LibraryOptionsContext.tsx | 2 +- .../contexts}/LibraryOptionsProvider.tsx | 4 +- .../hooks}/useGetVisibleLibraryMangas.ts | 2 +- src/{ => modules/library}/screens/Library.tsx | 8 ++-- .../library/screens}/LibraryDuplicates.tsx | 2 +- .../library/screens}/LibrarySettings.tsx | 2 +- src/modules/manga/MangaCard.types.tsx | 2 +- src/modules/manga/components/MangaBadges.tsx | 2 +- src/modules/manga/components/MangaGrid.tsx | 2 +- .../manga/components/cards/MangaCard.tsx | 2 +- .../manga/components/cards/MangaGridCard.tsx | 2 +- src/screens/Migrate.tsx | 2 +- src/screens/SourceMangas.tsx | 2 +- src/typings.ts | 47 +------------------ 24 files changed, 95 insertions(+), 76 deletions(-) create mode 100644 src/modules/core/Core.types.ts create mode 100644 src/modules/library/Library.types.ts rename src/{components/library => modules/library/components}/LibraryMangaGrid.tsx (92%) rename src/{components/library => modules/library/components}/LibraryOptionsPanel.tsx (98%) rename src/{components/library => modules/library/components}/LibraryToolbarMenu.tsx (89%) rename src/{components/context => modules/library/contexts}/LibraryOptionsContext.tsx (92%) rename src/{components/library => modules/library/contexts}/LibraryOptionsProvider.tsx (85%) rename src/{components/library => modules/library/hooks}/useGetVisibleLibraryMangas.ts (99%) rename src/{ => modules/library}/screens/Library.tsx (96%) rename src/{screens/settings => modules/library/screens}/LibraryDuplicates.tsx (99%) rename src/{screens/settings => modules/library/screens}/LibrarySettings.tsx (99%) diff --git a/src/App.tsx b/src/App.tsx index 7e29d73e..79e13028 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -24,7 +24,7 @@ import { useNavBarContext } from '@/components/context/NavbarContext.tsx'; const { Browse } = loadable(() => import('@/screens/Browse'), lazyLoadFallback); const { DownloadQueue } = loadable(() => import('@/screens/DownloadQueue'), lazyLoadFallback); -const { Library } = loadable(() => import('@/screens/Library'), lazyLoadFallback); +const { Library } = loadable(() => import('@/modules/library/screens/Library.tsx'), lazyLoadFallback); const { Manga } = loadable(() => import('@/modules/manga/screens/Manga.tsx'), lazyLoadFallback); const { Reader } = loadable(() => import('@/screens/Reader'), lazyLoadFallback); const { SearchAll } = loadable(() => import('@/screens/SearchAll'), lazyLoadFallback); @@ -36,7 +36,7 @@ const { DefaultReaderSettings } = loadable(() => import('@/screens/settings/Defa const { SourceConfigure } = loadable(() => import('@/screens/SourceConfigure'), lazyLoadFallback); const { SourceMangas } = loadable(() => import('@/screens/SourceMangas'), lazyLoadFallback); const { Updates } = loadable(() => import('@/screens/Updates'), lazyLoadFallback); -const { LibrarySettings } = loadable(() => import('@/screens/settings/LibrarySettings'), lazyLoadFallback); +const { LibrarySettings } = loadable(() => import('@/modules/library/screens/LibrarySettings.tsx'), lazyLoadFallback); const { DownloadSettings } = loadable(() => import('@/screens/settings/DownloadSettings.tsx'), lazyLoadFallback); const { ServerSettings } = loadable(() => import('@/screens/settings/ServerSettings.tsx'), lazyLoadFallback); const { BrowseSettings } = loadable(() => import('@/screens/settings/BrowseSettings.tsx'), lazyLoadFallback); @@ -45,7 +45,10 @@ const { Migrate } = loadable(() => import('@/screens/Migrate.tsx'), lazyLoadFall const { DeviceSetting } = loadable(() => import('@/components/settings/DeviceSetting.tsx'), lazyLoadFallback); const { TrackingSettings } = loadable(() => import('@/screens/settings/TrackingSettings.tsx'), lazyLoadFallback); const { TrackerOAuthLogin } = loadable(() => import('@/screens/TrackerOAuthLogin.tsx'), lazyLoadFallback); -const { LibraryDuplicates } = loadable(() => import('@/screens/settings/LibraryDuplicates.tsx'), lazyLoadFallback); +const { LibraryDuplicates } = loadable( + () => import('@/modules/library/screens/LibraryDuplicates.tsx'), + lazyLoadFallback, +); const { Appearance } = loadable(() => import('@/screens/settings/appearance/Appearance.tsx'), lazyLoadFallback); if (process.env.NODE_ENV !== 'production') { diff --git a/src/components/source/GridLayouts.tsx b/src/components/source/GridLayouts.tsx index f521fed5..86132b4d 100644 --- a/src/components/source/GridLayouts.tsx +++ b/src/components/source/GridLayouts.tsx @@ -15,7 +15,7 @@ import Tooltip from '@mui/material/Tooltip'; import React from 'react'; import ViewModuleIcon from '@mui/icons-material/ViewModule'; import { useTranslation } from 'react-i18next'; -import { GridLayout } from '@/components/context/LibraryOptionsContext'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; // TODO: clean up this to use a FormControl, and remove dependency on name o radio button export function GridLayouts({ diff --git a/src/components/source/SourceGridLayout.tsx b/src/components/source/SourceGridLayout.tsx index 181b087a..fe1e094e 100644 --- a/src/components/source/SourceGridLayout.tsx +++ b/src/components/source/SourceGridLayout.tsx @@ -6,7 +6,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { GridLayout } from '@/components/context/LibraryOptionsContext'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { GridLayouts } from '@/components/source/GridLayouts.tsx'; import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx'; diff --git a/src/lib/metadata/categoryMetadata.ts b/src/lib/metadata/categoryMetadata.ts index 20a7a6ee..1f4b9a43 100644 --- a/src/lib/metadata/categoryMetadata.ts +++ b/src/lib/metadata/categoryMetadata.ts @@ -12,14 +12,14 @@ import { CategoryMetadataKeys, GqlMetaHolder, ICategoryMetadata, - LibraryOptions, Metadata, } from '@/typings.ts'; import { jsonSaveParse } from '@/lib/HelperFunctions.ts'; import { convertFromGqlMeta, getMetadataFrom, requestUpdateCategoryMetadata } from '@/lib/metadata/metadata.ts'; import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts'; import { CategoryIdInfo } from '@/lib/data/Categories.ts'; -import { GridLayout } from '@/components/context/LibraryOptionsContext.tsx'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; +import { LibraryOptions } from '@/modules/library/Library.types.ts'; export const getDefaultCategoryMetadata = (): ICategoryMetadata => ({ // display options diff --git a/src/modules/core/Core.types.ts b/src/modules/core/Core.types.ts new file mode 100644 index 00000000..b3d4b792 --- /dev/null +++ b/src/modules/core/Core.types.ts @@ -0,0 +1,13 @@ +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +export enum GridLayout { + Compact = 0, + Comfortable = 1, + List = 2, +} diff --git a/src/modules/core/contexts/AppContext.tsx b/src/modules/core/contexts/AppContext.tsx index d9f8691a..bd71e153 100644 --- a/src/modules/core/contexts/AppContext.tsx +++ b/src/modules/core/contexts/AppContext.tsx @@ -21,7 +21,7 @@ import { createAndSetTheme } from '@/theme.tsx'; import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx'; import { ThemeMode, ThemeModeContext } from '@/components/context/ThemeModeContext.tsx'; import { NavBarContextProvider } from '@/components/navbar/NavBarContextProvider.tsx'; -import { LibraryOptionsContextProvider } from '@/components/library/LibraryOptionsProvider.tsx'; +import { LibraryOptionsContextProvider } from '@/modules/library/contexts/LibraryOptionsProvider.tsx'; import { ActiveDevice, DEFAULT_DEVICE, setActiveDevice } from '@/util/device.ts'; import { MediaQuery } from '@/lib/ui/MediaQuery.tsx'; import { AppThemes, getTheme } from '@/lib/ui/AppThemes.ts'; diff --git a/src/modules/library/Library.types.ts b/src/modules/library/Library.types.ts new file mode 100644 index 00000000..68bed005 --- /dev/null +++ b/src/modules/library/Library.types.ts @@ -0,0 +1,46 @@ +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +import { NullAndUndefined } from '@/Base.types.ts'; +import { MangaStatus, TrackerType } from '@/lib/graphql/generated/graphql.ts'; +import { GridLayout } from '@/modules/core/Core.types.ts'; + +export type MetadataLibrarySettings = { + showAddToLibraryCategorySelectDialog: boolean; + ignoreFilters: boolean; + removeMangaFromCategories: boolean; + showTabSize: boolean; +}; +export type LibrarySortMode = + | 'unreadChapters' + | 'totalChapters' + | 'alphabetically' + | 'dateAdded' + | 'lastRead' + | 'latestFetchedChapter' + | 'latestUploadedChapter'; + +export interface LibraryOptions { + // display options + showContinueReadingButton: boolean; + showDownloadBadge: boolean; + showUnreadBadge: boolean; + gridLayout: GridLayout; + + // sort options + sortBy: NullAndUndefined; + sortDesc: NullAndUndefined; + + // filter options + hasDownloadedChapters: NullAndUndefined; + hasBookmarkedChapters: NullAndUndefined; + hasUnreadChapters: NullAndUndefined; + hasDuplicateChapters: NullAndUndefined; + hasTrackerBinding: Record>; + hasStatus: Record>; +} diff --git a/src/components/library/LibraryMangaGrid.tsx b/src/modules/library/components/LibraryMangaGrid.tsx similarity index 92% rename from src/components/library/LibraryMangaGrid.tsx rename to src/modules/library/components/LibraryMangaGrid.tsx index 0d842074..3bf64fe6 100644 --- a/src/components/library/LibraryMangaGrid.tsx +++ b/src/modules/library/components/LibraryMangaGrid.tsx @@ -8,8 +8,8 @@ import React, { useLayoutEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { GridLayout, useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext'; -import { IMangaGridProps, MangaGrid } from '@/modules/manga/components/MangaGrid'; +import { GridLayout, useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; +import { IMangaGridProps, MangaGrid } from '@/modules/manga/components/MangaGrid.tsx'; interface LibraryMangaGridProps extends Required>, diff --git a/src/components/library/LibraryOptionsPanel.tsx b/src/modules/library/components/LibraryOptionsPanel.tsx similarity index 98% rename from src/components/library/LibraryOptionsPanel.tsx rename to src/modules/library/components/LibraryOptionsPanel.tsx index 7b669759..b432677a 100644 --- a/src/components/library/LibraryOptionsPanel.tsx +++ b/src/modules/library/components/LibraryOptionsPanel.tsx @@ -10,12 +10,11 @@ import FormLabel from '@mui/material/FormLabel'; import RadioGroup from '@mui/material/RadioGroup'; import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -import { LibrarySortMode } from '@/typings'; import { CheckboxInput } from '@/modules/core/components/inputs/CheckboxInput.tsx'; import { RadioInput } from '@/modules/core/components/inputs/RadioInput.tsx'; import { SortRadioInput } from '@/modules/core/components/inputs/SortRadioInput.tsx'; import { ThreeStateCheckboxInput } from '@/modules/core/components/inputs/ThreeStateCheckboxInput.tsx'; -import { GridLayout } from '@/components/context/LibraryOptionsContext'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { OptionsTabs } from '@/modules/core/components/OptionsTabs.tsx'; import { requestManager } from '@/lib/requests/requests/RequestManager.ts'; import { Trackers } from '@/lib/data/Trackers.ts'; @@ -30,6 +29,7 @@ import { useMetadataServerSettings, } from '@/lib/metadata/metadataServerSettings.ts'; import { TranslationKey } from '@/Base.types.ts'; +import { LibrarySortMode } from '@/modules/library/Library.types.ts'; const TITLES: { [key in 'filter' | 'sort' | 'display']: TranslationKey } = { filter: 'global.label.filter', diff --git a/src/components/library/LibraryToolbarMenu.tsx b/src/modules/library/components/LibraryToolbarMenu.tsx similarity index 89% rename from src/components/library/LibraryToolbarMenu.tsx rename to src/modules/library/components/LibraryToolbarMenu.tsx index 5fb56743..86cb3efa 100644 --- a/src/components/library/LibraryToolbarMenu.tsx +++ b/src/modules/library/components/LibraryToolbarMenu.tsx @@ -11,8 +11,8 @@ import IconButton from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; import { ComponentProps, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { LibraryOptionsPanel } from '@/components/library/LibraryOptionsPanel'; -import { useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext.tsx'; +import { LibraryOptionsPanel } from '@/modules/library/components/LibraryOptionsPanel.tsx'; +import { useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; export const LibraryToolbarMenu = ({ category, diff --git a/src/components/context/LibraryOptionsContext.tsx b/src/modules/library/contexts/LibraryOptionsContext.tsx similarity index 92% rename from src/components/context/LibraryOptionsContext.tsx rename to src/modules/library/contexts/LibraryOptionsContext.tsx index e7999971..9c1f6353 100644 --- a/src/components/context/LibraryOptionsContext.tsx +++ b/src/modules/library/contexts/LibraryOptionsContext.tsx @@ -7,8 +7,8 @@ */ import React, { useContext } from 'react'; -import { LibraryOptions } from '@/typings'; import { getDefaultCategoryMetadata } from '@/lib/metadata/categoryMetadata.ts'; +import { LibraryOptions } from '@/modules/library/Library.types.ts'; type ContextType = { options: LibraryOptions; diff --git a/src/components/library/LibraryOptionsProvider.tsx b/src/modules/library/contexts/LibraryOptionsProvider.tsx similarity index 85% rename from src/components/library/LibraryOptionsProvider.tsx rename to src/modules/library/contexts/LibraryOptionsProvider.tsx index 57b9193e..3960b224 100644 --- a/src/components/library/LibraryOptionsProvider.tsx +++ b/src/modules/library/contexts/LibraryOptionsProvider.tsx @@ -7,10 +7,10 @@ */ import React, { useMemo } from 'react'; -import { LibraryOptions } from '@/typings'; import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx'; -import { LibraryOptionsContext } from '@/components/context/LibraryOptionsContext'; +import { LibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { getDefaultCategoryMetadata } from '@/lib/metadata/categoryMetadata.ts'; +import { LibraryOptions } from '@/modules/library/Library.types.ts'; interface IProps { children: React.ReactNode; diff --git a/src/components/library/useGetVisibleLibraryMangas.ts b/src/modules/library/hooks/useGetVisibleLibraryMangas.ts similarity index 99% rename from src/components/library/useGetVisibleLibraryMangas.ts rename to src/modules/library/hooks/useGetVisibleLibraryMangas.ts index 8134cdd5..440d36a4 100644 --- a/src/components/library/useGetVisibleLibraryMangas.ts +++ b/src/modules/library/hooks/useGetVisibleLibraryMangas.ts @@ -8,7 +8,6 @@ import { StringParam, useQueryParam } from 'use-query-params'; import { useMemo } from 'react'; -import { LibraryOptions, LibrarySortMode } from '@/typings.ts'; import { useMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts'; import { ChapterType, MangaType, SourceType, TrackRecordType } from '@/lib/graphql/generated/graphql.ts'; import { MangaChapterCountInfo, MangaIdInfo } from '@/modules/manga/services/Mangas.ts'; @@ -16,6 +15,7 @@ import { enhancedCleanup } from '@/lib/data/Strings.ts'; import { CategoryMetadataInfo } from '@/lib/data/Categories.ts'; import { getCategoryMetadata } from '@/lib/metadata/categoryMetadata.ts'; import { NullAndUndefined } from '@/Base.types.ts'; +import { LibraryOptions, LibrarySortMode } from '@/modules/library/Library.types.ts'; const triStateFilter = ( triState: NullAndUndefined, diff --git a/src/screens/Library.tsx b/src/modules/library/screens/Library.tsx similarity index 96% rename from src/screens/Library.tsx rename to src/modules/library/screens/Library.tsx index 60294326..07232a2d 100644 --- a/src/screens/Library.tsx +++ b/src/modules/library/screens/Library.tsx @@ -16,14 +16,14 @@ import { requestManager } from '@/lib/requests/requests/RequestManager.ts'; import { EmptyViewAbsoluteCentered } from '@/modules/core/components/placeholder/EmptyViewAbsoluteCentered.tsx'; import { LoadingPlaceholder } from '@/modules/core/components/placeholder/LoadingPlaceholder.tsx'; import { TabPanel } from '@/modules/core/components/tabs/TabPanel.tsx'; -import { LibraryToolbarMenu } from '@/components/library/LibraryToolbarMenu'; -import { LibraryMangaGrid } from '@/components/library/LibraryMangaGrid'; +import { LibraryToolbarMenu } from '@/modules/library/components/LibraryToolbarMenu.tsx'; +import { LibraryMangaGrid } from '@/modules/library/components/LibraryMangaGrid.tsx'; import { AppbarSearch } from '@/modules/core/components/AppbarSearch.tsx'; import { UpdateChecker } from '@/modules/core/components/UpdateChecker.tsx'; import { NavBarContext } from '@/components/context/NavbarContext.tsx'; import { useSelectableCollection } from '@/modules/collection/hooks/useSelectableCollection.ts'; import { SelectableCollectionSelectMode } from '@/modules/collection/components/SelectableCollectionSelectMode.tsx'; -import { useGetVisibleLibraryMangas } from '@/components/library/useGetVisibleLibraryMangas.ts'; +import { useGetVisibleLibraryMangas } from '@/modules/library/hooks/useGetVisibleLibraryMangas.ts'; import { SelectionFAB } from '@/modules/collection/components/SelectionFAB.tsx'; import { MangaActionMenuItems } from '@/modules/manga/components/MangaActionMenuItems.tsx'; import { TabsMenu } from '@/modules/core/components/tabs/TabsMenu.tsx'; @@ -38,7 +38,7 @@ import { import { GET_CATEGORIES_LIBRARY } from '@/lib/graphql/queries/CategoryQuery.ts'; import { Mangas } from '@/modules/manga/services/Mangas.ts'; import { MANGA_CHAPTER_STAT_FIELDS } from '@/lib/graphql/fragments/MangaFragments.ts'; -import { useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext.tsx'; +import { useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { useMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts'; import { getCategoryMetadata } from '@/lib/metadata/categoryMetadata.ts'; diff --git a/src/screens/settings/LibraryDuplicates.tsx b/src/modules/library/screens/LibraryDuplicates.tsx similarity index 99% rename from src/screens/settings/LibraryDuplicates.tsx rename to src/modules/library/screens/LibraryDuplicates.tsx index 9d036833..76e13a28 100644 --- a/src/screens/settings/LibraryDuplicates.tsx +++ b/src/modules/library/screens/LibraryDuplicates.tsx @@ -17,7 +17,7 @@ import Box from '@mui/material/Box'; import { requestManager } from '@/lib/requests/requests/RequestManager.ts'; import { NavBarContext } from '@/components/context/NavbarContext.tsx'; import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx'; -import { GridLayout } from '@/components/context/LibraryOptionsContext.tsx'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { GridLayouts } from '@/components/source/GridLayouts.tsx'; import { CheckboxInput } from '@/modules/core/components/inputs/CheckboxInput.tsx'; import { LoadingPlaceholder } from '@/modules/core/components/placeholder/LoadingPlaceholder.tsx'; diff --git a/src/screens/settings/LibrarySettings.tsx b/src/modules/library/screens/LibrarySettings.tsx similarity index 99% rename from src/screens/settings/LibrarySettings.tsx rename to src/modules/library/screens/LibrarySettings.tsx index 2d5a6cda..99e0a1cd 100644 --- a/src/screens/settings/LibrarySettings.tsx +++ b/src/modules/library/screens/LibrarySettings.tsx @@ -17,7 +17,6 @@ import ListSubheader from '@mui/material/ListSubheader'; import { t as translate } from 'i18next'; import { NavBarContext } from '@/components/context/NavbarContext.tsx'; import { GlobalUpdateSettings } from '@/components/settings/globalUpdate/GlobalUpdateSettings.tsx'; -import { MetadataLibrarySettings } from '@/typings.ts'; import { makeToast } from '@/lib/ui/Toast.ts'; import { createUpdateMetadataServerSettings, @@ -37,6 +36,7 @@ import { } from '@/lib/graphql/generated/graphql.ts'; import { GET_CATEGORIES_SETTINGS } from '@/lib/graphql/queries/CategoryQuery.ts'; import { GET_MANGAS_BASE } from '@/lib/graphql/queries/MangaQuery.ts'; +import { MetadataLibrarySettings } from '@/modules/library/Library.types.ts'; const removeNonLibraryMangasFromCategories = async (): Promise => { try { diff --git a/src/modules/manga/MangaCard.types.tsx b/src/modules/manga/MangaCard.types.tsx index 67b4d119..ebda24bb 100644 --- a/src/modules/manga/MangaCard.types.tsx +++ b/src/modules/manga/MangaCard.types.tsx @@ -8,7 +8,7 @@ import { LongPressPointerHandlers, LongPressResult } from 'use-long-press/lib/use-long-press.types'; import { PopupState } from 'material-ui-popup-state/hooks'; -import { GridLayout } from '@/components/context/LibraryOptionsContext.tsx'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { SelectableCollectionReturnType } from '@/modules/collection/hooks/useSelectableCollection.ts'; import { useManageMangaLibraryState } from '@/modules/manga/hooks/useManageMangaLibraryState.tsx'; import { MangaThumbnailInfo } from '@/modules/manga/services/Mangas.ts'; diff --git a/src/modules/manga/components/MangaBadges.tsx b/src/modules/manga/components/MangaBadges.tsx index 17669ffc..2556f072 100644 --- a/src/modules/manga/components/MangaBadges.tsx +++ b/src/modules/manga/components/MangaBadges.tsx @@ -12,7 +12,7 @@ import Button from '@mui/material/Button'; import Typography from '@mui/material/Typography'; import { MangaCardMode } from '@/modules/manga/MangaCard.types.tsx'; import { MediaQuery } from '@/lib/ui/MediaQuery.tsx'; -import { useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext.tsx'; +import { useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; const BadgeContainer = styled('div')(({ theme }) => ({ display: 'flex', diff --git a/src/modules/manga/components/MangaGrid.tsx b/src/modules/manga/components/MangaGrid.tsx index 35d4731f..7e9aa31e 100644 --- a/src/modules/manga/components/MangaGrid.tsx +++ b/src/modules/manga/components/MangaGrid.tsx @@ -24,7 +24,7 @@ import { useTranslation } from 'react-i18next'; import { EmptyViewAbsoluteCentered } from '@/modules/core/components/placeholder/EmptyViewAbsoluteCentered.tsx'; import { LoadingPlaceholder } from '@/modules/core/components/placeholder/LoadingPlaceholder.tsx'; import { MangaCard } from '@/modules/manga/components/cards/MangaCard.tsx'; -import { GridLayout } from '@/components/context/LibraryOptionsContext'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { useLocalStorage, useSessionStorage } from '@/modules/core/hooks/useStorage.tsx'; import { SelectableCollectionReturnType } from '@/modules/collection/hooks/useSelectableCollection.ts'; import { DEFAULT_FULL_FAB_HEIGHT } from '@/modules/core/components/buttons/StyledFab.tsx'; diff --git a/src/modules/manga/components/cards/MangaCard.tsx b/src/modules/manga/components/cards/MangaCard.tsx index 76fa77ed..d80d33eb 100644 --- a/src/modules/manga/components/cards/MangaCard.tsx +++ b/src/modules/manga/components/cards/MangaCard.tsx @@ -9,7 +9,7 @@ import PopupState, { bindMenu } from 'material-ui-popup-state'; import { useMemo, useState } from 'react'; import { useLongPress } from 'use-long-press'; -import { GridLayout, useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext'; +import { GridLayout, useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { MangaActionMenuItems, SingleModeProps } from '@/modules/manga/components/MangaActionMenuItems.tsx'; import { Menu } from '@/modules/core/components/menu/Menu.tsx'; import { MigrateDialog } from '@/components/MigrateDialog.tsx'; diff --git a/src/modules/manga/components/cards/MangaGridCard.tsx b/src/modules/manga/components/cards/MangaGridCard.tsx index 99c2d1d8..b3df2e55 100644 --- a/src/modules/manga/components/cards/MangaGridCard.tsx +++ b/src/modules/manga/components/cards/MangaGridCard.tsx @@ -17,7 +17,7 @@ import { styled } from '@mui/material/styles'; import { useRef } from 'react'; import { SpinnerImage } from '@/modules/core/components/SpinnerImage.tsx'; import { MangaOptionButton } from '@/modules/manga/components/MangaOptionButton.tsx'; -import { GridLayout } from '@/components/context/LibraryOptionsContext.tsx'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { Mangas } from '@/modules/manga/services/Mangas.ts'; import { SpecificMangaCardProps } from '@/modules/manga/MangaCard.types.tsx'; import { TypographyMaxLines } from '@/modules/core/components/TypographyMaxLines.tsx'; diff --git a/src/screens/Migrate.tsx b/src/screens/Migrate.tsx index b06caddd..9bd62a06 100644 --- a/src/screens/Migrate.tsx +++ b/src/screens/Migrate.tsx @@ -16,7 +16,7 @@ import { LoadingPlaceholder } from '@/modules/core/components/placeholder/Loadin import { EmptyViewAbsoluteCentered } from '@/modules/core/components/placeholder/EmptyViewAbsoluteCentered.tsx'; import { GridLayouts } from '@/components/source/GridLayouts.tsx'; import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx'; -import { GridLayout } from '@/components/context/LibraryOptionsContext.tsx'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts'; import { GetSourceMigratableQuery, GetSourceMigratableQueryVariables } from '@/lib/graphql/generated/graphql.ts'; import { GET_SOURCE_MIGRATABLE } from '@/lib/graphql/queries/SourceQuery.ts'; diff --git a/src/screens/SourceMangas.tsx b/src/screens/SourceMangas.tsx index 387b7056..9d2fe058 100644 --- a/src/screens/SourceMangas.tsx +++ b/src/screens/SourceMangas.tsx @@ -26,7 +26,7 @@ import { AbortableApolloUseMutationPaginatedResponse, SPECIAL_ED_SOURCES, } from '@/lib/requests/requests/RequestManager.ts'; -import { GridLayout } from '@/components/context/LibraryOptionsContext'; +import { GridLayout } from '@/modules/library/contexts/LibraryOptionsContext.tsx'; import { SourceGridLayout } from '@/components/source/SourceGridLayout'; import { AppbarSearch } from '@/modules/core/components/AppbarSearch.tsx'; import { SourceOptions } from '@/components/source/SourceOptions'; diff --git a/src/typings.ts b/src/typings.ts index 20dd5448..66587ea7 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -14,15 +14,14 @@ import { GetSourceBrowseQuery, GetSourceSettingsQuery, MangaReaderFieldsFragment, - MangaStatus, MetaType, SourcePreferenceChangeInput, - TrackerType, } from '@/lib/graphql/generated/graphql.ts'; import { AppTheme } from '@/lib/ui/AppThemes.ts'; import { SortSettings } from '@/screens/Migration.types.ts'; -import { NullAndUndefined, TranslationKey } from '@/Base.types.ts'; +import { TranslationKey } from '@/Base.types.ts'; import { MangaMetadataKeys } from '@/modules/manga/MangaCard.types.tsx'; +import { LibraryOptions, MetadataLibrarySettings } from '@/modules/library/Library.types.ts'; export interface IPos { type: 'selectState' | 'textState' | 'checkBoxState' | 'triState' | 'sortState'; @@ -120,13 +119,6 @@ export type MetadataDownloadSettings = { downloadAheadLimit: number; }; -export type MetadataLibrarySettings = { - showAddToLibraryCategorySelectDialog: boolean; - ignoreFilters: boolean; - removeMangaFromCategories: boolean; - showTabSize: boolean; -}; - export type MetadataClientSettings = { devices: string[]; }; @@ -226,39 +218,4 @@ export interface NavbarItem { show: 'mobile' | 'desktop' | 'both'; } -export type LibrarySortMode = - | 'unreadChapters' - | 'totalChapters' - | 'alphabetically' - | 'dateAdded' - | 'lastRead' - | 'latestFetchedChapter' - | 'latestUploadedChapter'; - -enum GridLayout { - Compact = 0, - Comfortable = 1, - List = 2, -} - -export interface LibraryOptions { - // display options - showContinueReadingButton: boolean; - showDownloadBadge: boolean; - showUnreadBadge: boolean; - gridLayout: GridLayout; - - // sort options - sortBy: NullAndUndefined; - sortDesc: NullAndUndefined; - - // filter options - hasDownloadedChapters: NullAndUndefined; - hasBookmarkedChapters: NullAndUndefined; - hasUnreadChapters: NullAndUndefined; - hasDuplicateChapters: NullAndUndefined; - hasTrackerBinding: Record>; - hasStatus: Record>; -} - export type ServerSettings = GetServerSettingsQuery['settings'];