Add guard to "enable flaresolverr" setting

This commit is contained in:
schroda
2026-04-03 23:38:39 +02:00
parent 335e9349cd
commit 8a5aaf51f3
3 changed files with 81 additions and 4 deletions

View File

@@ -15,10 +15,11 @@ import Stack from '@mui/material/Stack';
import type { AwaitableComponentProps } from 'awaitable-component'; import type { AwaitableComponentProps } from 'awaitable-component';
import { Link as RouterLink } from 'react-router-dom'; import { Link as RouterLink } from 'react-router-dom';
import { useLingui } from '@lingui/react/macro'; import { useLingui } from '@lingui/react/macro';
import type { ReactNode } from 'react';
type Action = { type Action = {
show?: boolean; show?: boolean;
title?: string; title?: ReactNode;
contain?: boolean; contain?: boolean;
}; };
@@ -38,8 +39,8 @@ export const ConfirmDialog = ({
isVisible, isVisible,
onExitComplete, onExitComplete,
}: AwaitableComponentProps & { }: AwaitableComponentProps & {
title: string; title: ReactNode;
message: string; message: ReactNode;
actions?: Actions; actions?: Actions;
onExtra?: () => void; onExtra?: () => void;
}) => { }) => {

View File

@@ -41,6 +41,7 @@ import { ServerAddressSetting } from '@/features/settings/components/ServerAddre
import { AuthManager } from '@/features/authentication/AuthManager.ts'; import { AuthManager } from '@/features/authentication/AuthManager.ts';
import type { ServerSettings as ServerSettingsType } from '@/features/settings/Settings.types.ts'; import type { ServerSettings as ServerSettingsType } from '@/features/settings/Settings.types.ts';
import { KoreaderSyncSettings } from '@/features/settings/components/koreaderSync/KoreaderSyncSettings.tsx'; import { KoreaderSyncSettings } from '@/features/settings/components/koreaderSync/KoreaderSyncSettings.tsx';
import { Confirmation } from '@/base/AppAwaitableComponent.ts';
const getLogFilesCleanupDisplayValue = (ttl: number): string => { const getLogFilesCleanupDisplayValue = (ttl: number): string => {
if (ttl === 0) { if (ttl === 0) {
@@ -346,7 +347,70 @@ export const ServerSettings = () => {
<Switch <Switch
edge="end" edge="end"
checked={serverSettings.flareSolverrEnabled} checked={serverSettings.flareSolverrEnabled}
onChange={(e) => updateSetting('flareSolverrEnabled', e.target.checked)} onChange={async (e) => {
const enabled = e.target.checked;
if (!enabled) {
updateSetting('flareSolverrEnabled', enabled);
return;
}
try {
await Confirmation.show({
title: t`Flaresolverr setup confirmation`,
message: (
<Trans>
Flaresolverr is a{' '}
<u>
<b>separate</b>
</u>
, Suwayomi{' '}
<u>
<b>unrelated</b>
</u>{' '}
program that needs to be manually{' '}
<u>
<b>installed</b>
</u>{' '}
and{' '}
<u>
<b>run</b>
</u>
.<br />
See{' '}
<Link
href="https://github.com/FlareSolverr/FlareSolverr?tab=readme-ov-file#installation"
target="_blank"
rel="noreferrer"
>
FlareSolverr
</Link>{' '}
for information on how to set it up
<br />
<br />
If it is{' '}
<u>
<b>not</b>
</u>{' '}
properly set up and running, enabling this setting{' '}
<u>
<b>won&apos;t</b>
</u>{' '}
do anything
</Trans>
),
actions: {
confirm: {
title: t`I understand`,
},
},
});
updateSetting('flareSolverrEnabled', enabled);
} catch (_) {
// Ignore
}
}}
/> />
</ListItem> </ListItem>
<TextSetting <TextSetting

View File

@@ -1587,6 +1587,10 @@ msgstr "Fit width"
msgid "FlareSolverr enabled" msgid "FlareSolverr enabled"
msgstr "FlareSolverr enabled" msgstr "FlareSolverr enabled"
#: src/features/settings/screens/ServerSettings.tsx
msgid "Flaresolverr is a <0><1>separate</1></0>, Suwayomi <2><3>unrelated</3></2> program that needs to be manually <4><5>installed</5></4> and <6><7>run</7></6>.<8/>See <9>FlareSolverr</9> for information on how to set it up<10/><11/>If it is <12><13>not</13></12> properly set up and running, enabling this setting <14><15>won't</15></14> do anything"
msgstr "Flaresolverr is a <0><1>separate</1></0>, Suwayomi <2><3>unrelated</3></2> program that needs to be manually <4><5>installed</5></4> and <6><7>run</7></6>.<8/>See <9>FlareSolverr</9> for information on how to set it up<10/><11/>If it is <12><13>not</13></12> properly set up and running, enabling this setting <14><15>won't</15></14> do anything"
#: src/features/settings/screens/ServerSettings.tsx #: src/features/settings/screens/ServerSettings.tsx
msgid "FlareSolverr request timeout" msgid "FlareSolverr request timeout"
msgstr "FlareSolverr request timeout" msgstr "FlareSolverr request timeout"
@@ -1603,6 +1607,10 @@ msgstr "FlareSolverr session name"
msgid "FlareSolverr session TTL" msgid "FlareSolverr session TTL"
msgstr "FlareSolverr session TTL" msgstr "FlareSolverr session TTL"
#: src/features/settings/screens/ServerSettings.tsx
msgid "Flaresolverr setup confirmation"
msgstr "Flaresolverr setup confirmation"
#: src/features/settings/screens/ServerSettings.tsx #: src/features/settings/screens/ServerSettings.tsx
msgid "FlareSolverr will automatically rotate expired sessions based on the TTL provided in minutes" msgid "FlareSolverr will automatically rotate expired sessions based on the TTL provided in minutes"
msgstr "FlareSolverr will automatically rotate expired sessions based on the TTL provided in minutes" msgstr "FlareSolverr will automatically rotate expired sessions based on the TTL provided in minutes"
@@ -1733,6 +1741,10 @@ msgstr "How many chapters should get downloaded while reading."
msgid "How much time FlareSolverr has to handle the request" msgid "How much time FlareSolverr has to handle the request"
msgstr "How much time FlareSolverr has to handle the request" msgstr "How much time FlareSolverr has to handle the request"
#: src/features/settings/screens/ServerSettings.tsx
msgid "I understand"
msgstr "I understand"
#: src/features/app-updates/components/VersionUpdateInfoDialog.tsx #: src/features/app-updates/components/VersionUpdateInfoDialog.tsx
msgid "Ignore" msgid "Ignore"
msgstr "Ignore" msgstr "Ignore"