diff --git a/src/base/components/buttons/ValueRotationButton.tsx b/src/base/components/buttons/ValueRotationButton.tsx index 591bd515..641389f7 100644 --- a/src/base/components/buttons/ValueRotationButton.tsx +++ b/src/base/components/buttons/ValueRotationButton.tsx @@ -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 { tooltip?: string; diff --git a/src/base/utils/ValueRotationButton.utils.ts b/src/base/utils/ValueRotationButton.utils.ts deleted file mode 100644 index 490d0d95..00000000 --- a/src/base/utils/ValueRotationButton.utils.ts +++ /dev/null @@ -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 = ( - 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]; -}; diff --git a/src/features/reader/hotkeys/ReaderHotkeys.tsx b/src/features/reader/hotkeys/ReaderHotkeys.tsx index fbdf6324..0e29bce2 100644 --- a/src/features/reader/hotkeys/ReaderHotkeys.tsx +++ b/src/features/reader/hotkeys/ReaderHotkeys.tsx @@ -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): ReturnType => { const [keys, callback, options, dependencies] = args; diff --git a/src/lib/HelperFunctions.ts b/src/lib/HelperFunctions.ts index 536f061d..92a4ec06 100644 --- a/src/lib/HelperFunctions.ts +++ b/src/lib/HelperFunctions.ts @@ -66,3 +66,19 @@ export const extractGraphqlExceptionInfo = ( graphqlStackTrace: stackTrace, }; }; + +export const getNextRotationValue = ( + 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]; +};