Move "getNextRotationValue" to lib "HelperFunctions"
This commit is contained in:
@@ -11,9 +11,9 @@ import { useMemo } from 'react';
|
||||
import Button from '@mui/material/Button';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
|
||||
import { getNextRotationValue } from '@/base/utils/ValueRotationButton.utils.ts';
|
||||
import { Superscript } from '@/base/components/texts/Superscript.tsx';
|
||||
import type { ValueToDisplayData } from '@/base/Base.types.ts';
|
||||
import { getNextRotationValue } from '@/lib/HelperFunctions.ts';
|
||||
|
||||
export interface ValueRotationButtonBaseProps<Value extends string | number> {
|
||||
tooltip?: string;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* 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 const getNextRotationValue = <Value>(
|
||||
indexOfValue: number,
|
||||
values: Value[],
|
||||
isDefaultable?: boolean,
|
||||
): Value | undefined => {
|
||||
const nextValueIndex = (indexOfValue + 1) % values.length;
|
||||
const wasLastValue = nextValueIndex === 0;
|
||||
|
||||
const isDefaultNextValue = !!isDefaultable && wasLastValue;
|
||||
if (isDefaultNextValue) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return values[(indexOfValue + 1) % values.length];
|
||||
};
|
||||
@@ -12,7 +12,6 @@ import { HOTKEY_SCOPES } from '@/features/hotkeys/Hotkeys.constants.ts';
|
||||
import { ReaderService } from '@/features/reader/services/ReaderService.ts';
|
||||
import type { IReaderSettings } from '@/features/reader/Reader.types.ts';
|
||||
import { ReaderHotkey } from '@/features/reader/Reader.types.ts';
|
||||
import { getNextRotationValue } from '@/base/utils/ValueRotationButton.utils.ts';
|
||||
import {
|
||||
AUTO_SCROLL_SPEED,
|
||||
CONTINUOUS_READING_MODE_TO_SCROLL_DIRECTION,
|
||||
@@ -30,6 +29,7 @@ import {
|
||||
getReaderSettingsStore,
|
||||
useReaderSettingsStore,
|
||||
} from '@/features/reader/stores/ReaderStore.ts';
|
||||
import { getNextRotationValue } from '@/lib/HelperFunctions.ts';
|
||||
|
||||
const useHotkeys = (...args: Parameters<typeof useHotKeysHook>): ReturnType<typeof useHotKeysHook> => {
|
||||
const [keys, callback, options, dependencies] = args;
|
||||
|
||||
@@ -66,3 +66,19 @@ export const extractGraphqlExceptionInfo = (
|
||||
graphqlStackTrace: stackTrace,
|
||||
};
|
||||
};
|
||||
|
||||
export const getNextRotationValue = <Value>(
|
||||
indexOfValue: number,
|
||||
values: Value[],
|
||||
isDefaultable?: boolean,
|
||||
): Value | undefined => {
|
||||
const nextValueIndex = (indexOfValue + 1) % values.length;
|
||||
const wasLastValue = nextValueIndex === 0;
|
||||
|
||||
const isDefaultNextValue = !!isDefaultable && wasLastValue;
|
||||
if (isDefaultNextValue) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return values[(indexOfValue + 1) % values.length];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user