Male library "grid layout" setting global
This commit is contained in:
@@ -8,9 +8,9 @@
|
||||
|
||||
import React, { useLayoutEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx';
|
||||
import { IMangaGridProps, MangaGrid } from '@/modules/manga/components/MangaGrid.tsx';
|
||||
import { GridLayout } from '@/modules/core/Core.types.ts';
|
||||
import { useMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts';
|
||||
|
||||
interface LibraryMangaGridProps
|
||||
extends Required<Pick<IMangaGridProps, 'isSelectModeActive' | 'selectedMangaIds' | 'handleSelection' | 'mangas'>>,
|
||||
@@ -29,10 +29,12 @@ export const LibraryMangaGrid: React.FC<LibraryMangaGridProps> = ({
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { options } = useLibraryOptionsContext();
|
||||
const {
|
||||
settings: { gridLayout },
|
||||
} = useMetadataServerSettings();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
document.body.style.overflowY = options.gridLayout === GridLayout.List ? 'auto' : 'scroll';
|
||||
document.body.style.overflowY = gridLayout === GridLayout.List ? 'auto' : 'scroll';
|
||||
return () => {
|
||||
document.body.style.overflowY = 'auto';
|
||||
};
|
||||
@@ -46,7 +48,7 @@ export const LibraryMangaGrid: React.FC<LibraryMangaGridProps> = ({
|
||||
loadMore={loadMoreNoop}
|
||||
message={showFilteredOutMessage ? t('library.error.label.no_matches') : message}
|
||||
messageExtra={showFilteredOutMessage ? undefined : messageExtra}
|
||||
gridLayout={options.gridLayout}
|
||||
gridLayout={gridLayout}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ export const LibraryOptionsPanel = ({
|
||||
);
|
||||
|
||||
const {
|
||||
settings: { showTabSize, showContinueReadingButton, showDownloadBadge, showUnreadBadge },
|
||||
settings: { showTabSize, showContinueReadingButton, showDownloadBadge, showUnreadBadge, gridLayout },
|
||||
} = useMetadataServerSettings();
|
||||
const setSettingValue = createUpdateMetadataServerSettings((e) =>
|
||||
makeToast(t('search.error.label.failed_to_save_settings'), 'error', getErrorMessage(e)),
|
||||
@@ -156,12 +156,11 @@ export const LibraryOptionsPanel = ({
|
||||
));
|
||||
}
|
||||
if (key === 'display') {
|
||||
const { gridLayout } = categoryLibraryOptions;
|
||||
return (
|
||||
<>
|
||||
<FormLabel>{t('global.grid_layout.title')}</FormLabel>
|
||||
<RadioGroup
|
||||
onChange={(e) => updateCategoryLibraryOptions('gridLayout', Number(e.target.value))}
|
||||
onChange={(e) => updateMetadataServerSettings('gridLayout', Number(e.target.value))}
|
||||
value={gridLayout}
|
||||
>
|
||||
<RadioInput
|
||||
|
||||
Reference in New Issue
Block a user