diff --git a/src/components/settings/NumberSetting.tsx b/src/components/settings/NumberSetting.tsx
index a7230009..3daddc4e 100644
--- a/src/components/settings/NumberSetting.tsx
+++ b/src/components/settings/NumberSetting.tsx
@@ -28,7 +28,7 @@ import { SxProps, Theme } from '@mui/material/styles';
type BaseProps = {
settingTitle: string;
- settingValue?: string;
+ settingValue: string;
settingIcon?: React.ReactNode;
value: number;
defaultValue?: number;
@@ -117,7 +117,7 @@ export const NumberSetting = ({
{settingIcon ? {settingIcon} : null}
diff --git a/src/components/settings/SelectSetting.tsx b/src/components/settings/SelectSetting.tsx
index 8456e7d0..0750d473 100644
--- a/src/components/settings/SelectSetting.tsx
+++ b/src/components/settings/SelectSetting.tsx
@@ -36,15 +36,13 @@ export const SelectSetting = ({
settingName,
dialogDescription,
value,
- defaultValue,
values,
handleChange,
disabled = false,
}: {
settingName: string;
dialogDescription?: string;
- value?: SettingValue;
- defaultValue: SettingValue;
+ value: SettingValue;
values: SelectSettingValue[];
handleChange: (value: SettingValue) => void;
disabled?: boolean;
@@ -52,7 +50,7 @@ export const SelectSetting = ({
const { t } = useTranslation();
const [isDialogOpen, setIsDialogOpen] = useState(false);
- const [dialogValue, setDialogValue] = useState(value ?? defaultValue);
+ const [dialogValue, setDialogValue] = useState(value);
const valueDisplayText = useMemo(() => values.find(([key]) => key === value)?.[1]?.text, [value]);
const dialogValueDisplayInfo = useMemo(() => values.find(([key]) => key === dialogValue)![1], [dialogValue]);
@@ -67,7 +65,7 @@ export const SelectSetting = ({
const closeDialog = (resetValue: boolean = true) => {
if (resetValue) {
- setDialogValue(value ?? defaultValue);
+ setDialogValue(value);
}
setIsDialogOpen(false);
diff --git a/src/components/settings/TimeSetting.tsx b/src/components/settings/TimeSetting.tsx
index d784afe4..c7e45728 100644
--- a/src/components/settings/TimeSetting.tsx
+++ b/src/components/settings/TimeSetting.tsx
@@ -28,14 +28,14 @@ export const TimeSetting = ({
handleChange,
}: {
settingName: string;
- value?: string;
+ value: string;
defaultValue: string;
handleChange: (path: string) => void;
}) => {
const { t, i18n } = useTranslation();
const [isDialogOpen, setIsDialogOpen] = useState(false);
- const [dialogValue, setDialogValue] = useState(value ?? defaultValue);
+ const [dialogValue, setDialogValue] = useState(value);
const [locale, setLocale] = useState('en');
@@ -58,7 +58,7 @@ export const TimeSetting = ({
setIsDialogOpen(false);
if (resetValue) {
- setDialogValue(value ?? defaultValue);
+ setDialogValue(value);
}
},
[value],
@@ -87,9 +87,7 @@ export const TimeSetting = ({
setIsDialogOpen(true)}>
diff --git a/src/components/settings/downloads/DeleteChaptersWhileReadingSetting.tsx b/src/components/settings/downloads/DeleteChaptersWhileReadingSetting.tsx
index 09decaad..5e28ed98 100644
--- a/src/components/settings/downloads/DeleteChaptersWhileReadingSetting.tsx
+++ b/src/components/settings/downloads/DeleteChaptersWhileReadingSetting.tsx
@@ -42,11 +42,7 @@ const CHAPTERS_TO_DELETE_SELECT_VALUES: SelectSettingValue<(typeof CHAPTERS_TO_D
CHAPTERS_TO_DELETE_TO_TRANSLATION_KEY[chapterToDelete],
]);
-const getNormalizedChapterToDelete = (chapterToDelete?: number | boolean) => {
- if (chapterToDelete === undefined) {
- return undefined;
- }
-
+const getNormalizedChapterToDelete = (chapterToDelete: number | boolean) => {
const isMigrationVersion0 = typeof chapterToDelete === 'boolean';
if (isMigrationVersion0) {
return Number(chapterToDelete);
@@ -59,7 +55,7 @@ export const DeleteChaptersWhileReadingSetting = ({
chapterToDelete,
handleChange,
}: {
- chapterToDelete?: number;
+ chapterToDelete: number;
handleChange: (chapterToDelete: number) => void;
}) => {
const { t } = useTranslation();
@@ -70,7 +66,6 @@ export const DeleteChaptersWhileReadingSetting = ({
diff --git a/src/components/settings/downloads/DownloadAheadSetting.tsx b/src/components/settings/downloads/DownloadAheadSetting.tsx
index 50ea50d2..1b9e31d5 100644
--- a/src/components/settings/downloads/DownloadAheadSetting.tsx
+++ b/src/components/settings/downloads/DownloadAheadSetting.tsx
@@ -56,14 +56,10 @@ export const DownloadAheadSetting = ({
& {
- disabled?: boolean;
-};
+export type TextSettingProps = Omit &
+ Required> & {
+ disabled?: boolean;
+ };
export const TextSetting = (props: TextSettingProps) => {
- const { t } = useTranslation();
-
const [isDialogOpen, setIsDialogOpen] = useState(false);
const { settingName, value, isPassword = false, disabled = false } = props;
@@ -28,7 +26,7 @@ export const TextSetting = (props: TextSettingProps) => {
setIsDialogOpen(true)}>
settingName={t('tracking.track_record.label.score')}
- defaultValue={tracker.scores[0]}
value={currentScore}
values={selectSettingValues}
handleChange={(score) => updateTrackerBind({ scoreString: score })}
diff --git a/src/screens/settings/Backup.tsx b/src/screens/settings/Backup.tsx
index ed110da9..d07e2423 100644
--- a/src/screens/settings/Backup.tsx
+++ b/src/screens/settings/Backup.tsx
@@ -44,11 +44,7 @@ const extractBackupSettings = (settings: ServerSettings): BackupSettingsType =>
backupTTL: settings.backupTTL,
});
-const getBackupCleanupDisplayValue = (ttl?: number) => {
- if (ttl === undefined) {
- return undefined;
- }
-
+const getBackupCleanupDisplayValue = (ttl: number): string => {
if (ttl === 0) {
return translate('global.label.never');
}
@@ -81,8 +77,6 @@ export function Backup() {
} = requestManager.useGetServerSettings({ notifyOnNetworkStatusChange: true });
const [mutateSettings] = requestManager.useUpdateServerSettings();
- const backupSettings = settingsData ? extractBackupSettings(settingsData.settings) : undefined;
-
const { data } = requestManager.useGetBackupRestoreStatus(backupRestoreId ?? '', {
skip: !backupRestoreId,
pollInterval: 1000,
@@ -245,6 +239,8 @@ export function Backup() {
);
}
+ const backupSettings = extractBackupSettings(settingsData!.settings);
+
return (
<>
@@ -278,26 +274,22 @@ export function Backup() {
updateSetting('backupPath', path)}
/>
updateSetting('backupTime', time)}
/>
{
const { data, loading, error, refetch } = requestManager.useGetServerSettings({
notifyOnNetworkStatusChange: true,
});
- const serverSettings = data ? extractBrowseSettings(data.settings) : undefined;
const [mutateSettings] = requestManager.useUpdateServerSettings();
const updateSetting = (
@@ -80,6 +79,8 @@ export const BrowseSettings = () => {
);
}
+ const serverSettings = extractBrowseSettings(data!.settings);
+
return (
@@ -100,11 +101,11 @@ export const BrowseSettings = () => {
{
updateSetting('extensionRepos', repos);
requestManager.clearExtensionCache();
}}
- valueInfos={serverSettings?.extensionRepos.map((extensionRepo) => [extensionRepo]) as [string][]}
+ valueInfos={serverSettings.extensionRepos.map((extensionRepo) => [extensionRepo]) as [string][]}
addItemButtonTitle={t('extension.settings.repositories.custom.dialog.action.button.add')}
placeholder="https://github.com/MY_ACCOUNT/MY_REPO/tree/repo"
validateItem={(repo) =>
@@ -141,7 +142,7 @@ export const BrowseSettings = () => {
updateSetting('localSourcePath', path)}
/>
diff --git a/src/screens/settings/DownloadSettings.tsx b/src/screens/settings/DownloadSettings.tsx
index 8b659a08..e5c28b54 100644
--- a/src/screens/settings/DownloadSettings.tsx
+++ b/src/screens/settings/DownloadSettings.tsx
@@ -188,15 +188,12 @@ export const DownloadSettings = () => {
dialogDescription={t('download.settings.auto_download.download_limit.label.description')}
value={downloadSettings?.autoDownloadNewChaptersLimit ?? 0}
settingValue={
- // eslint-disable-next-line no-nested-ternary
- downloadSettings?.autoDownloadNewChaptersLimit !== undefined
- ? !downloadSettings.autoDownloadNewChaptersLimit
- ? t('global.label.none')
- : t('download.settings.download_ahead.label.value', {
- chapters: downloadSettings.autoDownloadNewChaptersLimit,
- count: downloadSettings.autoDownloadNewChaptersLimit,
- })
- : undefined
+ !downloadSettings.autoDownloadNewChaptersLimit
+ ? t('global.label.none')
+ : t('download.settings.download_ahead.label.value', {
+ chapters: downloadSettings.autoDownloadNewChaptersLimit,
+ count: downloadSettings.autoDownloadNewChaptersLimit,
+ })
}
defaultValue={0}
minValue={0}
diff --git a/src/screens/settings/ServerSettings.tsx b/src/screens/settings/ServerSettings.tsx
index 7fe33fde..2167658c 100644
--- a/src/screens/settings/ServerSettings.tsx
+++ b/src/screens/settings/ServerSettings.tsx
@@ -89,7 +89,6 @@ export const ServerSettings = () => {
const { data, loading, error, refetch } = requestManager.useGetServerSettings({
notifyOnNetworkStatusChange: true,
});
- const serverSettings = data ? extractServerSettings(data.settings) : undefined;
const [mutateSettings] = requestManager.useUpdateServerSettings();
const [serverAddress, setServerAddress] = useLocalStorage('serverBaseURL', window.location.origin);
@@ -121,6 +120,8 @@ export const ServerSettings = () => {
);
}
+ const serverSettings = extractServerSettings(data!.settings);
+
return (
{
updateSetting('ip', ip)}
- value={serverSettings?.ip}
+ value={serverSettings.ip}
placeholder="0.0.0.0"
/>
updateSetting('port', port)}
- value={serverSettings?.port ?? 4567}
+ value={serverSettings.port}
defaultValue={4567}
valueUnit={t('settings.server.address.server.label.port')}
/>
@@ -170,14 +171,13 @@ export const ServerSettings = () => {
updateSetting('socksProxyEnabled', e.target.checked)}
/>
settingName={t('settings.server.socks_proxy.label.version')}
- value={serverSettings?.socksProxyVersion}
- defaultValue={5}
+ value={serverSettings.socksProxyVersion}
values={[
[4, { text: '4' }],
[5, { text: '5' }],
@@ -186,22 +186,22 @@ export const ServerSettings = () => {
/>
updateSetting('socksProxyHost', proxyHost)}
/>
updateSetting('socksProxyPort', proxyPort)}
/>
updateSetting('socksProxyUsername', proxyUsername)}
/>
updateSetting('socksProxyPassword', proxyPassword)}
isPassword
/>
@@ -217,18 +217,18 @@ export const ServerSettings = () => {
updateSetting('basicAuthEnabled', e.target.checked)}
/>
updateSetting('basicAuthUsername', authUsername)}
/>
updateSetting('basicAuthPassword', authPassword)}
/>
@@ -259,25 +259,21 @@ export const ServerSettings = () => {
/>
updateSetting('flareSolverrEnabled', e.target.checked)}
/>
updateSetting('flareSolverrUrl', url)}
/>
{
/>
updateSetting('flareSolverrSessionName', sessionName)}
/>
{
updateSetting('debugLogsEnabled', e.target.checked)}
/>
@@ -331,7 +323,7 @@ export const ServerSettings = () => {
/>
updateSetting('gqlDebugLogsEnabled', e.target.checked)}
/>
@@ -342,7 +334,7 @@ export const ServerSettings = () => {
/>
updateSetting('systemTrayEnabled', e.target.checked)}
/>
diff --git a/src/screens/settings/WebUISettings.tsx b/src/screens/settings/WebUISettings.tsx
index 8a473a32..0c5a61cf 100644
--- a/src/screens/settings/WebUISettings.tsx
+++ b/src/screens/settings/WebUISettings.tsx
@@ -130,11 +130,8 @@ export const WebUISettings = () => {
const { data, loading, error, refetch } = requestManager.useGetServerSettings({
notifyOnNetworkStatusChange: true,
});
- const webUISettings = data ? extractWebUISettings(data.settings) : undefined;
const [mutateSettings] = requestManager.useUpdateServerSettings();
- const isDefaultWebUI = webUISettings?.webUIFlavor === WebUiFlavor.Webui;
-
const updateSetting = (
setting: Setting,
value: WebUISettingsType[Setting],
@@ -160,12 +157,14 @@ export const WebUISettings = () => {
);
}
+ const webUISettings = extractWebUISettings(data!.settings);
+ const isDefaultWebUI = webUISettings.webUIFlavor === WebUiFlavor.Webui;
+
return (
settingName={t('settings.webui.flavor.label.title')}
- value={webUISettings?.webUIFlavor}
- defaultValue={WebUiFlavor.Webui}
+ value={webUISettings.webUIFlavor}
values={FLAVOR_SELECT_VALUES}
handleChange={(flavor) => updateSetting('webUIFlavor', flavor)}
/>
@@ -173,32 +172,33 @@ export const WebUISettings = () => {
updateSetting('initialOpenInBrowserEnabled', e.target.checked)}
/>
settingName={t('settings.webui.interface.label.title')}
- value={webUISettings?.webUIInterface}
- defaultValue={WebUiInterface.Browser}
+ value={webUISettings.webUIInterface}
values={INTERFACE_SELECT_VALUES}
handleChange={(webUIInterface) => updateSetting('webUIInterface', webUIInterface)}
/>
updateSetting('electronPath', path)}
/>
settingName={t('settings.webui.channel.label.title')}
- value={webUISettings?.webUIChannel}
- defaultValue={WebUiChannel.Stable}
+ value={webUISettings.webUIChannel}
values={CHANNEL_SELECT_VALUES}
handleChange={(channel) => updateSetting('webUIChannel', channel)}
disabled={!isDefaultWebUI}
/>
-
+
);
};