Male library "grid layout" setting global
This commit is contained in:
@@ -21,12 +21,8 @@ import {
|
|||||||
Metadata,
|
Metadata,
|
||||||
MetadataHolder,
|
MetadataHolder,
|
||||||
} from '@/modules/metadata/Metadata.types.ts';
|
} from '@/modules/metadata/Metadata.types.ts';
|
||||||
import { GridLayout } from '@/modules/core/Core.types.ts';
|
|
||||||
|
|
||||||
export const DEFAULT_CATEGORY_METADATA: ICategoryMetadata = {
|
export const DEFAULT_CATEGORY_METADATA: ICategoryMetadata = {
|
||||||
// display options
|
|
||||||
gridLayout: GridLayout.Compact,
|
|
||||||
|
|
||||||
// sort options
|
// sort options
|
||||||
sortDesc: undefined,
|
sortDesc: undefined,
|
||||||
sortBy: undefined,
|
sortBy: undefined,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export type MetadataLibrarySettings = {
|
|||||||
showContinueReadingButton: boolean;
|
showContinueReadingButton: boolean;
|
||||||
showDownloadBadge: boolean;
|
showDownloadBadge: boolean;
|
||||||
showUnreadBadge: boolean;
|
showUnreadBadge: boolean;
|
||||||
|
gridLayout: GridLayout;
|
||||||
};
|
};
|
||||||
export type LibrarySortMode =
|
export type LibrarySortMode =
|
||||||
| 'unreadChapters'
|
| 'unreadChapters'
|
||||||
@@ -29,9 +30,6 @@ export type LibrarySortMode =
|
|||||||
| 'latestUploadedChapter';
|
| 'latestUploadedChapter';
|
||||||
|
|
||||||
export interface LibraryOptions {
|
export interface LibraryOptions {
|
||||||
// display options
|
|
||||||
gridLayout: GridLayout;
|
|
||||||
|
|
||||||
// sort options
|
// sort options
|
||||||
sortBy: NullAndUndefined<LibrarySortMode>;
|
sortBy: NullAndUndefined<LibrarySortMode>;
|
||||||
sortDesc: NullAndUndefined<boolean>;
|
sortDesc: NullAndUndefined<boolean>;
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
import React, { useLayoutEffect } from 'react';
|
import React, { useLayoutEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx';
|
|
||||||
import { IMangaGridProps, MangaGrid } from '@/modules/manga/components/MangaGrid.tsx';
|
import { IMangaGridProps, MangaGrid } from '@/modules/manga/components/MangaGrid.tsx';
|
||||||
import { GridLayout } from '@/modules/core/Core.types.ts';
|
import { GridLayout } from '@/modules/core/Core.types.ts';
|
||||||
|
import { useMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts';
|
||||||
|
|
||||||
interface LibraryMangaGridProps
|
interface LibraryMangaGridProps
|
||||||
extends Required<Pick<IMangaGridProps, 'isSelectModeActive' | 'selectedMangaIds' | 'handleSelection' | 'mangas'>>,
|
extends Required<Pick<IMangaGridProps, 'isSelectModeActive' | 'selectedMangaIds' | 'handleSelection' | 'mangas'>>,
|
||||||
@@ -29,10 +29,12 @@ export const LibraryMangaGrid: React.FC<LibraryMangaGridProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { options } = useLibraryOptionsContext();
|
const {
|
||||||
|
settings: { gridLayout },
|
||||||
|
} = useMetadataServerSettings();
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
document.body.style.overflowY = options.gridLayout === GridLayout.List ? 'auto' : 'scroll';
|
document.body.style.overflowY = gridLayout === GridLayout.List ? 'auto' : 'scroll';
|
||||||
return () => {
|
return () => {
|
||||||
document.body.style.overflowY = 'auto';
|
document.body.style.overflowY = 'auto';
|
||||||
};
|
};
|
||||||
@@ -46,7 +48,7 @@ export const LibraryMangaGrid: React.FC<LibraryMangaGridProps> = ({
|
|||||||
loadMore={loadMoreNoop}
|
loadMore={loadMoreNoop}
|
||||||
message={showFilteredOutMessage ? t('library.error.label.no_matches') : message}
|
message={showFilteredOutMessage ? t('library.error.label.no_matches') : message}
|
||||||
messageExtra={showFilteredOutMessage ? undefined : messageExtra}
|
messageExtra={showFilteredOutMessage ? undefined : messageExtra}
|
||||||
gridLayout={options.gridLayout}
|
gridLayout={gridLayout}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export const LibraryOptionsPanel = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
settings: { showTabSize, showContinueReadingButton, showDownloadBadge, showUnreadBadge },
|
settings: { showTabSize, showContinueReadingButton, showDownloadBadge, showUnreadBadge, gridLayout },
|
||||||
} = useMetadataServerSettings();
|
} = useMetadataServerSettings();
|
||||||
const setSettingValue = createUpdateMetadataServerSettings((e) =>
|
const setSettingValue = createUpdateMetadataServerSettings((e) =>
|
||||||
makeToast(t('search.error.label.failed_to_save_settings'), 'error', getErrorMessage(e)),
|
makeToast(t('search.error.label.failed_to_save_settings'), 'error', getErrorMessage(e)),
|
||||||
@@ -156,12 +156,11 @@ export const LibraryOptionsPanel = ({
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (key === 'display') {
|
if (key === 'display') {
|
||||||
const { gridLayout } = categoryLibraryOptions;
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FormLabel>{t('global.grid_layout.title')}</FormLabel>
|
<FormLabel>{t('global.grid_layout.title')}</FormLabel>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
onChange={(e) => updateCategoryLibraryOptions('gridLayout', Number(e.target.value))}
|
onChange={(e) => updateMetadataServerSettings('gridLayout', Number(e.target.value))}
|
||||||
value={gridLayout}
|
value={gridLayout}
|
||||||
>
|
>
|
||||||
<RadioInput
|
<RadioInput
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
import { DEFAULT_DEVICE } from '@/modules/device/services/Device.ts';
|
import { DEFAULT_DEVICE } from '@/modules/device/services/Device.ts';
|
||||||
import { DEFAULT_SORT_SETTINGS } from '@/modules/migration/Migration.constants.ts';
|
import { DEFAULT_SORT_SETTINGS } from '@/modules/migration/Migration.constants.ts';
|
||||||
import { MetadataServerSettings } from '@/modules/settings/Settings.types.ts';
|
import { MetadataServerSettings } from '@/modules/settings/Settings.types.ts';
|
||||||
|
import { GridLayout } from '@/modules/core/Core.types.ts';
|
||||||
|
|
||||||
export const SERVER_SETTINGS_METADATA_DEFAULT: MetadataServerSettings = {
|
export const SERVER_SETTINGS_METADATA_DEFAULT: MetadataServerSettings = {
|
||||||
// downloads
|
// downloads
|
||||||
@@ -25,6 +26,7 @@ export const SERVER_SETTINGS_METADATA_DEFAULT: MetadataServerSettings = {
|
|||||||
showContinueReadingButton: false,
|
showContinueReadingButton: false,
|
||||||
showDownloadBadge: false,
|
showDownloadBadge: false,
|
||||||
showUnreadBadge: false,
|
showUnreadBadge: false,
|
||||||
|
gridLayout: GridLayout.Compact,
|
||||||
|
|
||||||
// client
|
// client
|
||||||
devices: [DEFAULT_DEVICE],
|
devices: [DEFAULT_DEVICE],
|
||||||
|
|||||||
Reference in New Issue
Block a user