Move library display options to global metadata
- showContinueReadingButton - showDownloadBadge - showUnreadBadge
This commit is contained in:
@@ -25,9 +25,6 @@ import { GridLayout } from '@/modules/core/Core.types.ts';
|
|||||||
|
|
||||||
export const DEFAULT_CATEGORY_METADATA: ICategoryMetadata = {
|
export const DEFAULT_CATEGORY_METADATA: ICategoryMetadata = {
|
||||||
// display options
|
// display options
|
||||||
showContinueReadingButton: false,
|
|
||||||
showDownloadBadge: false,
|
|
||||||
showUnreadBadge: false,
|
|
||||||
gridLayout: GridLayout.Compact,
|
gridLayout: GridLayout.Compact,
|
||||||
|
|
||||||
// sort options
|
// sort options
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ export type MetadataLibrarySettings = {
|
|||||||
ignoreFilters: boolean;
|
ignoreFilters: boolean;
|
||||||
removeMangaFromCategories: boolean;
|
removeMangaFromCategories: boolean;
|
||||||
showTabSize: boolean;
|
showTabSize: boolean;
|
||||||
|
showContinueReadingButton: boolean;
|
||||||
|
showDownloadBadge: boolean;
|
||||||
|
showUnreadBadge: boolean;
|
||||||
};
|
};
|
||||||
export type LibrarySortMode =
|
export type LibrarySortMode =
|
||||||
| 'unreadChapters'
|
| 'unreadChapters'
|
||||||
@@ -27,9 +30,6 @@ export type LibrarySortMode =
|
|||||||
|
|
||||||
export interface LibraryOptions {
|
export interface LibraryOptions {
|
||||||
// display options
|
// display options
|
||||||
showContinueReadingButton: boolean;
|
|
||||||
showDownloadBadge: boolean;
|
|
||||||
showUnreadBadge: boolean;
|
|
||||||
gridLayout: GridLayout;
|
gridLayout: GridLayout;
|
||||||
|
|
||||||
// sort options
|
// sort options
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { createUpdateCategoryMetadata, useGetCategoryMetadata } from '@/modules/
|
|||||||
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
||||||
import {
|
import {
|
||||||
createUpdateMetadataServerSettings,
|
createUpdateMetadataServerSettings,
|
||||||
|
updateMetadataServerSettings,
|
||||||
useMetadataServerSettings,
|
useMetadataServerSettings,
|
||||||
} from '@/modules/settings/services/ServerSettingsMetadata.ts';
|
} from '@/modules/settings/services/ServerSettingsMetadata.ts';
|
||||||
import { TranslationKey } from '@/Base.types.ts';
|
import { TranslationKey } from '@/Base.types.ts';
|
||||||
@@ -67,9 +68,9 @@ export const LibraryOptionsPanel = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
settings: { showTabSize },
|
settings: { showTabSize, showContinueReadingButton, showDownloadBadge, showUnreadBadge },
|
||||||
} = useMetadataServerSettings();
|
} = useMetadataServerSettings();
|
||||||
const setSettingValue = createUpdateMetadataServerSettings<'showTabSize'>((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)),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -155,8 +156,7 @@ export const LibraryOptionsPanel = ({
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (key === 'display') {
|
if (key === 'display') {
|
||||||
const { gridLayout, showContinueReadingButton, showDownloadBadge, showUnreadBadge } =
|
const { gridLayout } = categoryLibraryOptions;
|
||||||
categoryLibraryOptions;
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FormLabel>{t('global.grid_layout.title')}</FormLabel>
|
<FormLabel>{t('global.grid_layout.title')}</FormLabel>
|
||||||
@@ -185,12 +185,12 @@ export const LibraryOptionsPanel = ({
|
|||||||
<CheckboxInput
|
<CheckboxInput
|
||||||
label={t('library.option.display.badge.label.unread_badges')}
|
label={t('library.option.display.badge.label.unread_badges')}
|
||||||
checked={showUnreadBadge}
|
checked={showUnreadBadge}
|
||||||
onChange={() => updateCategoryLibraryOptions('showUnreadBadge', !showUnreadBadge)}
|
onChange={() => updateMetadataServerSettings('showUnreadBadge', !showUnreadBadge)}
|
||||||
/>
|
/>
|
||||||
<CheckboxInput
|
<CheckboxInput
|
||||||
label={t('library.option.display.badge.label.download_badges')}
|
label={t('library.option.display.badge.label.download_badges')}
|
||||||
checked={showDownloadBadge}
|
checked={showDownloadBadge}
|
||||||
onChange={() => updateCategoryLibraryOptions('showDownloadBadge', !showDownloadBadge)}
|
onChange={() => updateMetadataServerSettings('showDownloadBadge', !showDownloadBadge)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormLabel sx={{ mt: 2 }}>{t('library.option.display.tab.title')}</FormLabel>
|
<FormLabel sx={{ mt: 2 }}>{t('library.option.display.tab.title')}</FormLabel>
|
||||||
@@ -205,7 +205,7 @@ export const LibraryOptionsPanel = ({
|
|||||||
label={t('library.option.display.other.label.show_continue_reading_button')}
|
label={t('library.option.display.other.label.show_continue_reading_button')}
|
||||||
checked={showContinueReadingButton}
|
checked={showContinueReadingButton}
|
||||||
onChange={() =>
|
onChange={() =>
|
||||||
updateCategoryLibraryOptions(
|
updateMetadataServerSettings(
|
||||||
'showContinueReadingButton',
|
'showContinueReadingButton',
|
||||||
!showContinueReadingButton,
|
!showContinueReadingButton,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import Button from '@mui/material/Button';
|
|||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import { MangaCardMode } from '@/modules/manga/Manga.types.ts';
|
import { MangaCardMode } from '@/modules/manga/Manga.types.ts';
|
||||||
import { MediaQuery } from '@/modules/core/utils/MediaQuery.tsx';
|
import { MediaQuery } from '@/modules/core/utils/MediaQuery.tsx';
|
||||||
import { useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx';
|
import { useMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts';
|
||||||
|
|
||||||
const BadgeContainer = styled('div')(({ theme }) => ({
|
const BadgeContainer = styled('div')(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -46,8 +46,8 @@ export const MangaBadges = ({
|
|||||||
const isTouchDevice = MediaQuery.useIsTouchDevice();
|
const isTouchDevice = MediaQuery.useIsTouchDevice();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
options: { showUnreadBadge, showDownloadBadge },
|
settings: { showUnreadBadge, showDownloadBadge },
|
||||||
} = useLibraryOptionsContext();
|
} = useMetadataServerSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BadgeContainer>
|
<BadgeContainer>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
import PopupState, { bindMenu } from 'material-ui-popup-state';
|
import PopupState, { bindMenu } from 'material-ui-popup-state';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useLongPress } from 'use-long-press';
|
import { useLongPress } from 'use-long-press';
|
||||||
import { useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx';
|
|
||||||
import { MangaActionMenuItems, SingleModeProps } from '@/modules/manga/components/MangaActionMenuItems.tsx';
|
import { MangaActionMenuItems, SingleModeProps } from '@/modules/manga/components/MangaActionMenuItems.tsx';
|
||||||
import { Menu } from '@/modules/core/components/menu/Menu.tsx';
|
import { Menu } from '@/modules/core/components/menu/Menu.tsx';
|
||||||
import { MigrateDialog } from '@/modules/migration/components/MigrateDialog.tsx';
|
import { MigrateDialog } from '@/modules/migration/components/MigrateDialog.tsx';
|
||||||
@@ -21,6 +20,7 @@ import { ContinueReadingButton } from '@/modules/manga/components/ContinueReadin
|
|||||||
import { MangaBadges } from '@/modules/manga/components/MangaBadges.tsx';
|
import { MangaBadges } from '@/modules/manga/components/MangaBadges.tsx';
|
||||||
import { GridLayout } from '@/modules/core/Core.types.ts';
|
import { GridLayout } from '@/modules/core/Core.types.ts';
|
||||||
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
||||||
|
import { useMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts';
|
||||||
|
|
||||||
const getMangaLinkTo = (
|
const getMangaLinkTo = (
|
||||||
mode: MangaCardMode,
|
mode: MangaCardMode,
|
||||||
@@ -46,8 +46,8 @@ export const MangaCard = (props: MangaCardProps) => {
|
|||||||
const { manga, gridLayout, inLibraryIndicator, selected, handleSelection, mode = 'default' } = props;
|
const { manga, gridLayout, inLibraryIndicator, selected, handleSelection, mode = 'default' } = props;
|
||||||
const { id, firstUnreadChapter, downloadCount, unreadCount } = manga;
|
const { id, firstUnreadChapter, downloadCount, unreadCount } = manga;
|
||||||
const {
|
const {
|
||||||
options: { showContinueReadingButton },
|
settings: { showContinueReadingButton },
|
||||||
} = useLibraryOptionsContext();
|
} = useMetadataServerSettings();
|
||||||
|
|
||||||
const { CategorySelectComponent, updateLibraryState, isInLibrary } = useManageMangaLibraryState(
|
const { CategorySelectComponent, updateLibraryState, isInLibrary } = useManageMangaLibraryState(
|
||||||
manga,
|
manga,
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ export const SERVER_SETTINGS_METADATA_DEFAULT: MetadataServerSettings = {
|
|||||||
ignoreFilters: false,
|
ignoreFilters: false,
|
||||||
removeMangaFromCategories: false,
|
removeMangaFromCategories: false,
|
||||||
showTabSize: false,
|
showTabSize: false,
|
||||||
|
showContinueReadingButton: false,
|
||||||
|
showDownloadBadge: false,
|
||||||
|
showUnreadBadge: false,
|
||||||
|
|
||||||
// client
|
// client
|
||||||
devices: [DEFAULT_DEVICE],
|
devices: [DEFAULT_DEVICE],
|
||||||
|
|||||||
Reference in New Issue
Block a user