@@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
import { MangaStatus } from '@/lib/graphql/generated/graphql.ts';
|
import { MangaStatus } from '@/lib/graphql/generated/graphql.ts';
|
||||||
import { TranslationKey } from '@/Base.types.ts';
|
import { TranslationKey } from '@/Base.types.ts';
|
||||||
import { MangaAction } from '@/modules/manga/Manga.types.ts';
|
import { MangaAction, MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
||||||
|
|
||||||
|
export const FALLBACK_MANGA: MangaIdInfo = { id: -1 };
|
||||||
|
|
||||||
|
export const GLOBAL_READER_SETTINGS_MANGA: MangaIdInfo = { id: -2 };
|
||||||
|
|
||||||
export const MANGA_COVER_ASPECT_RATIO = '1 / 1.5';
|
export const MANGA_COVER_ASPECT_RATIO = '1 / 1.5';
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import {
|
|||||||
READING_MODE_VALUES,
|
READING_MODE_VALUES,
|
||||||
} from '@/modules/reader/constants/ReaderSettings.constants.tsx';
|
} from '@/modules/reader/constants/ReaderSettings.constants.tsx';
|
||||||
import { useReaderStateMangaContext } from '@/modules/reader/contexts/state/ReaderStateMangaContext.tsx';
|
import { useReaderStateMangaContext } from '@/modules/reader/contexts/state/ReaderStateMangaContext.tsx';
|
||||||
import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
|
||||||
import { HotkeyScope } from '@/modules/hotkeys/Hotkeys.types.ts';
|
import { HotkeyScope } from '@/modules/hotkeys/Hotkeys.types.ts';
|
||||||
import { ReaderControls } from '@/modules/reader/services/ReaderControls.ts';
|
import { ReaderControls } from '@/modules/reader/services/ReaderControls.ts';
|
||||||
import { ScrollDirection, ScrollOffset } from '@/modules/core/Core.types.ts';
|
import { ScrollDirection, ScrollOffset } from '@/modules/core/Core.types.ts';
|
||||||
import { getOptionForDirection } from '@/modules/theme/services/ThemeCreator.ts';
|
import { getOptionForDirection } from '@/modules/theme/services/ThemeCreator.ts';
|
||||||
|
import { FALLBACK_MANGA } from '@/modules/manga/Manga.constants.ts';
|
||||||
|
|
||||||
const useHotkeys = (...args: Parameters<typeof useHotKeysHook>): ReturnType<typeof useHotKeysHook> => {
|
const useHotkeys = (...args: Parameters<typeof useHotKeysHook>): ReturnType<typeof useHotKeysHook> => {
|
||||||
const [keys, callback, options, dependencies] = args;
|
const [keys, callback, options, dependencies] = args;
|
||||||
@@ -57,8 +57,6 @@ const updateSettingCycleThrough = <Setting extends keyof IReaderSettings>(
|
|||||||
updateSetting(setting, nextValue);
|
updateSetting(setting, nextValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_MANGA: MangaIdInfo = { id: -1 };
|
|
||||||
|
|
||||||
const CONTINUOUS_READING_MODE_TO_SCROLL_DIRECTION: Record<ReadingMode, ScrollDirection> = {
|
const CONTINUOUS_READING_MODE_TO_SCROLL_DIRECTION: Record<ReadingMode, ScrollDirection> = {
|
||||||
[ReadingMode.SINGLE_PAGE]: ScrollDirection.Y,
|
[ReadingMode.SINGLE_PAGE]: ScrollDirection.Y,
|
||||||
[ReadingMode.DOUBLE_PAGE]: ScrollDirection.Y,
|
[ReadingMode.DOUBLE_PAGE]: ScrollDirection.Y,
|
||||||
@@ -83,8 +81,8 @@ export const ReaderHotkeys = ({
|
|||||||
const openChapter = ReaderControls.useOpenChapter();
|
const openChapter = ReaderControls.useOpenChapter();
|
||||||
const openPage = ReaderControls.useOpenPage();
|
const openPage = ReaderControls.useOpenPage();
|
||||||
|
|
||||||
const updateSetting = ReaderService.useCreateUpdateSetting(manga ?? DEFAULT_MANGA);
|
const updateSetting = ReaderService.useCreateUpdateSetting(manga ?? FALLBACK_MANGA);
|
||||||
const deleteSetting = ReaderService.useCreateDeleteSetting(manga ?? DEFAULT_MANGA);
|
const deleteSetting = ReaderService.useCreateDeleteSetting(manga ?? FALLBACK_MANGA);
|
||||||
|
|
||||||
useHotkeys(hotkeys[ReaderHotkey.PREVIOUS_PAGE], () => openPage('previous'), [openPage]);
|
useHotkeys(hotkeys[ReaderHotkey.PREVIOUS_PAGE], () => openPage('previous'), [openPage]);
|
||||||
useHotkeys(hotkeys[ReaderHotkey.NEXT_PAGE], () => openPage('next'), [openPage]);
|
useHotkeys(hotkeys[ReaderHotkey.NEXT_PAGE], () => openPage('next'), [openPage]);
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ import { userReaderStatePagesContext } from '@/modules/reader/contexts/state/Rea
|
|||||||
import { useReaderStateChaptersContext } from '@/modules/reader/contexts/state/ReaderStateChaptersContext.tsx';
|
import { useReaderStateChaptersContext } from '@/modules/reader/contexts/state/ReaderStateChaptersContext.tsx';
|
||||||
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
||||||
import { LoadingPlaceholder } from '@/modules/core/components/placeholder/LoadingPlaceholder.tsx';
|
import { LoadingPlaceholder } from '@/modules/core/components/placeholder/LoadingPlaceholder.tsx';
|
||||||
import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
|
||||||
import { NavbarContextType } from '@/modules/navigation-bar/NavigationBar.types.ts';
|
import { NavbarContextType } from '@/modules/navigation-bar/NavigationBar.types.ts';
|
||||||
import { IReaderSettings, ReaderStateChapters, TReaderStateMangaContext } from '@/modules/reader/types/Reader.types.ts';
|
import { IReaderSettings, ReaderStateChapters, TReaderStateMangaContext } from '@/modules/reader/types/Reader.types.ts';
|
||||||
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
|
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
|
||||||
|
import { FALLBACK_MANGA } from '@/modules/manga/Manga.constants.ts';
|
||||||
|
|
||||||
const useGetPreviousNavBarStaticValue = (isVisible: boolean, isStaticNav: boolean) => {
|
const useGetPreviousNavBarStaticValue = (isVisible: boolean, isStaticNav: boolean) => {
|
||||||
const wasNavBarStaticRef = useRef(isStaticNav);
|
const wasNavBarStaticRef = useRef(isStaticNav);
|
||||||
@@ -54,7 +54,6 @@ const useGetPreviousNavBarStaticValue = (isVisible: boolean, isStaticNav: boolea
|
|||||||
return wasNavBarStaticRef.current;
|
return wasNavBarStaticRef.current;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_MANGA: MangaIdInfo = { id: -1 };
|
|
||||||
const BaseReaderNavBarDesktop = ({
|
const BaseReaderNavBarDesktop = ({
|
||||||
isVisible,
|
isVisible,
|
||||||
openSettings,
|
openSettings,
|
||||||
@@ -77,7 +76,7 @@ const BaseReaderNavBarDesktop = ({
|
|||||||
|
|
||||||
const getOptionForDirection = useGetOptionForDirection();
|
const getOptionForDirection = useGetOptionForDirection();
|
||||||
|
|
||||||
const updateReaderSettings = ReaderService.useCreateUpdateSetting(manga ?? DEFAULT_MANGA);
|
const updateReaderSettings = ReaderService.useCreateUpdateSetting(manga ?? FALLBACK_MANGA);
|
||||||
|
|
||||||
const [navBarElement, setNavBarElement] = useState<HTMLDivElement | null>();
|
const [navBarElement, setNavBarElement] = useState<HTMLDivElement | null>();
|
||||||
useResizeObserver(
|
useResizeObserver(
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ import { ReaderNavBarDesktopReadingDirection } from '@/modules/reader/components
|
|||||||
import { IReaderSettingsWithDefaultFlag, TReaderStateMangaContext } from '@/modules/reader/types/Reader.types.ts';
|
import { IReaderSettingsWithDefaultFlag, TReaderStateMangaContext } from '@/modules/reader/types/Reader.types.ts';
|
||||||
import { ReaderNavBarDesktopProps } from '@/modules/reader/types/ReaderOverlay.types.ts';
|
import { ReaderNavBarDesktopProps } from '@/modules/reader/types/ReaderOverlay.types.ts';
|
||||||
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
||||||
import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
|
||||||
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
|
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
|
||||||
import { useReaderStateMangaContext } from '@/modules/reader/contexts/state/ReaderStateMangaContext.tsx';
|
import { useReaderStateMangaContext } from '@/modules/reader/contexts/state/ReaderStateMangaContext.tsx';
|
||||||
|
import { FALLBACK_MANGA } from '@/modules/manga/Manga.constants.ts';
|
||||||
|
|
||||||
const DEFAULT_MANGA: MangaIdInfo = { id: -1 };
|
|
||||||
const BaseReaderNavBarDesktopQuickSettings = ({
|
const BaseReaderNavBarDesktopQuickSettings = ({
|
||||||
manga,
|
manga,
|
||||||
readingMode,
|
readingMode,
|
||||||
@@ -38,8 +37,8 @@ const BaseReaderNavBarDesktopQuickSettings = ({
|
|||||||
>) => {
|
>) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const updateSetting = ReaderService.useCreateUpdateSetting(manga ?? DEFAULT_MANGA);
|
const updateSetting = ReaderService.useCreateUpdateSetting(manga ?? FALLBACK_MANGA);
|
||||||
const deleteSetting = ReaderService.useCreateDeleteSetting(manga ?? DEFAULT_MANGA);
|
const deleteSetting = ReaderService.useCreateDeleteSetting(manga ?? FALLBACK_MANGA);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack sx={{ gap: 1 }}>
|
<Stack sx={{ gap: 1 }}>
|
||||||
|
|||||||
@@ -12,19 +12,18 @@ import { ReaderSettingReadingMode } from '@/modules/reader/components/settings/l
|
|||||||
import { ReaderSettingReadingDirection } from '@/modules/reader/components/settings/layout/ReaderSettingReadingDirection.tsx';
|
import { ReaderSettingReadingDirection } from '@/modules/reader/components/settings/layout/ReaderSettingReadingDirection.tsx';
|
||||||
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
||||||
import { useReaderStateMangaContext } from '@/modules/reader/contexts/state/ReaderStateMangaContext.tsx';
|
import { useReaderStateMangaContext } from '@/modules/reader/contexts/state/ReaderStateMangaContext.tsx';
|
||||||
import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
|
|
||||||
import { DefaultSettingFootnote } from '@/modules/reader/components/settings/DefaultSettingFootnote.tsx';
|
import { DefaultSettingFootnote } from '@/modules/reader/components/settings/DefaultSettingFootnote.tsx';
|
||||||
import { IReaderSettingsWithDefaultFlag, TReaderStateMangaContext } from '@/modules/reader/types/Reader.types.ts';
|
import { IReaderSettingsWithDefaultFlag, TReaderStateMangaContext } from '@/modules/reader/types/Reader.types.ts';
|
||||||
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
|
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
|
||||||
|
import { FALLBACK_MANGA } from '@/modules/manga/Manga.constants.ts';
|
||||||
|
|
||||||
const DEFAULT_MANGA: MangaIdInfo = { id: -1 };
|
|
||||||
const BaseReaderBottomBarMobileQuickSettings = ({
|
const BaseReaderBottomBarMobileQuickSettings = ({
|
||||||
manga,
|
manga,
|
||||||
readingMode,
|
readingMode,
|
||||||
readingDirection,
|
readingDirection,
|
||||||
}: Pick<TReaderStateMangaContext, 'manga'> &
|
}: Pick<TReaderStateMangaContext, 'manga'> &
|
||||||
Pick<IReaderSettingsWithDefaultFlag, 'readingMode' | 'readingDirection'>) => {
|
Pick<IReaderSettingsWithDefaultFlag, 'readingMode' | 'readingDirection'>) => {
|
||||||
const deleteSetting = ReaderService.useCreateDeleteSetting(manga ?? DEFAULT_MANGA);
|
const deleteSetting = ReaderService.useCreateDeleteSetting(manga ?? FALLBACK_MANGA);
|
||||||
|
|
||||||
if (!manga) {
|
if (!manga) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { IReaderSettings, ReadingMode } from '@/modules/reader/types/Reader.type
|
|||||||
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
import { ReaderService } from '@/modules/reader/services/ReaderService.ts';
|
||||||
import { ReaderSettingsTabs } from '@/modules/reader/components/settings/ReaderSettingsTabs.tsx';
|
import { ReaderSettingsTabs } from '@/modules/reader/components/settings/ReaderSettingsTabs.tsx';
|
||||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||||
|
import { GLOBAL_READER_SETTINGS_MANGA } from '@/modules/manga/Manga.constants.ts';
|
||||||
|
|
||||||
export const GlobalReaderSettings = () => {
|
export const GlobalReaderSettings = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -45,7 +46,7 @@ export const GlobalReaderSettings = () => {
|
|||||||
commit?: boolean,
|
commit?: boolean,
|
||||||
profile?: ReadingMode,
|
profile?: ReadingMode,
|
||||||
) => {
|
) => {
|
||||||
ReaderService.updateSetting({ id: -1 }, key, value, commit, true, profile);
|
ReaderService.updateSetting(GLOBAL_READER_SETTINGS_MANGA, key, value, commit, true, profile);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
@@ -69,7 +70,7 @@ export const GlobalReaderSettings = () => {
|
|||||||
areDefaultSettings
|
areDefaultSettings
|
||||||
settings={settings}
|
settings={settings}
|
||||||
updateSetting={(setting, value, commit, _, profile) => updateSetting(setting, value, commit, profile)}
|
updateSetting={(setting, value, commit, _, profile) => updateSetting(setting, value, commit, profile)}
|
||||||
deleteSetting={(setting) => ReaderService.deleteSetting({ id: -1 }, setting, true)}
|
deleteSetting={(setting) => ReaderService.deleteSetting(GLOBAL_READER_SETTINGS_MANGA, setting, true)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import { TReaderOverlayContext } from '@/modules/reader/types/ReaderOverlay.type
|
|||||||
import { ReaderStatePages } from '@/modules/reader/types/ReaderProgressBar.types.ts';
|
import { ReaderStatePages } from '@/modules/reader/types/ReaderProgressBar.types.ts';
|
||||||
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
|
import { withPropsFrom } from '@/modules/core/hoc/withPropsFrom.tsx';
|
||||||
import { useReaderStateChaptersContext } from '@/modules/reader/contexts/state/ReaderStateChaptersContext.tsx';
|
import { useReaderStateChaptersContext } from '@/modules/reader/contexts/state/ReaderStateChaptersContext.tsx';
|
||||||
|
import { FALLBACK_MANGA } from '@/modules/manga/Manga.constants.ts';
|
||||||
|
|
||||||
const BaseReader = ({
|
const BaseReader = ({
|
||||||
setTitle,
|
setTitle,
|
||||||
@@ -225,7 +226,7 @@ const BaseReader = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const settingsWithDefaultProfileFallback = getReaderSettingsFor(
|
const settingsWithDefaultProfileFallback = getReaderSettingsFor(
|
||||||
mangaResponse.data?.manga ?? { id: -1 },
|
mangaResponse.data?.manga ?? FALLBACK_MANGA,
|
||||||
defaultSettings,
|
defaultSettings,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts'
|
|||||||
import { Queue } from '@/lib/Queue.ts';
|
import { Queue } from '@/lib/Queue.ts';
|
||||||
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
||||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||||
|
import { FALLBACK_MANGA } from '@/modules/manga/Manga.constants.ts';
|
||||||
|
|
||||||
const DIRECTION_TO_INVERTED: Record<Direction, Direction> = {
|
const DIRECTION_TO_INVERTED: Record<Direction, Direction> = {
|
||||||
ltr: 'rtl',
|
ltr: 'rtl',
|
||||||
@@ -241,7 +242,7 @@ export class ReaderService {
|
|||||||
isGlobal: boolean = false,
|
isGlobal: boolean = false,
|
||||||
profile?: ReadingMode,
|
profile?: ReadingMode,
|
||||||
): void {
|
): void {
|
||||||
if (!manga || manga.id === -1) {
|
if (!manga || manga.id === FALLBACK_MANGA.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const key = getMetadataKey(setting, profile !== undefined ? [profile?.toString()] : undefined);
|
const key = getMetadataKey(setting, profile !== undefined ? [profile?.toString()] : undefined);
|
||||||
@@ -305,7 +306,7 @@ export class ReaderService {
|
|||||||
isGlobal: boolean = false,
|
isGlobal: boolean = false,
|
||||||
profile?: string,
|
profile?: string,
|
||||||
): void {
|
): void {
|
||||||
if (!manga || manga.id === -1) {
|
if (!manga || manga.id === FALLBACK_MANGA.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user