Move library files into new folder

This commit is contained in:
schroda
2024-10-05 19:33:09 +02:00
parent abc40de47b
commit 91e1f01de5
24 changed files with 95 additions and 76 deletions

View File

@@ -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') {

View File

@@ -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({

View File

@@ -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';

View File

@@ -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

View File

@@ -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,
}

View File

@@ -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';

View File

@@ -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<LibrarySortMode>;
sortDesc: NullAndUndefined<boolean>;
// filter options
hasDownloadedChapters: NullAndUndefined<boolean>;
hasBookmarkedChapters: NullAndUndefined<boolean>;
hasUnreadChapters: NullAndUndefined<boolean>;
hasDuplicateChapters: NullAndUndefined<boolean>;
hasTrackerBinding: Record<TrackerType['id'], NullAndUndefined<boolean>>;
hasStatus: Record<MangaStatus, NullAndUndefined<boolean>>;
}

View File

@@ -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<Pick<IMangaGridProps, 'isSelectModeActive' | 'selectedMangaIds' | 'handleSelection' | 'mangas'>>,

View File

@@ -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',

View File

@@ -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,

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<boolean>,

View File

@@ -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';

View File

@@ -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';

View File

@@ -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<void> => {
try {

View File

@@ -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';

View File

@@ -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',

View File

@@ -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';

View File

@@ -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';

View File

@@ -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';

View File

@@ -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';

View File

@@ -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';

View File

@@ -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<LibrarySortMode>;
sortDesc: NullAndUndefined<boolean>;
// filter options
hasDownloadedChapters: NullAndUndefined<boolean>;
hasBookmarkedChapters: NullAndUndefined<boolean>;
hasUnreadChapters: NullAndUndefined<boolean>;
hasDuplicateChapters: NullAndUndefined<boolean>;
hasTrackerBinding: Record<TrackerType['id'], NullAndUndefined<boolean>>;
hasStatus: Record<MangaStatus, NullAndUndefined<boolean>>;
}
export type ServerSettings = GetServerSettingsQuery['settings'];