Remove redundant extract helper functions for server settings
Simplifies settings usage by directly accessing the `settings` object instead of relying on intermediary extraction functions. Improves code readability and reduces unnecessary abstraction. Ensures consistency across all settings components for a cleaner and more efficient implementation.
This commit is contained in:
@@ -42,13 +42,6 @@ import { BrowseTab } from '@/features/browse/Browse.types.ts';
|
||||
|
||||
type BackupSettingsType = Pick<ServerSettings, 'backupPath' | 'backupTime' | 'backupInterval' | 'backupTTL'>;
|
||||
|
||||
const extractBackupSettings = (settings: ServerSettings): BackupSettingsType => ({
|
||||
backupPath: settings.backupPath,
|
||||
backupTime: settings.backupTime,
|
||||
backupInterval: settings.backupInterval,
|
||||
backupTTL: settings.backupTTL,
|
||||
});
|
||||
|
||||
const getBackupCleanupDisplayValue = (ttl: number): string => {
|
||||
if (ttl === 0) {
|
||||
return translate('global.label.never');
|
||||
@@ -224,7 +217,7 @@ export function Backup() {
|
||||
);
|
||||
}
|
||||
|
||||
const backupSettings = extractBackupSettings(settingsData!.settings);
|
||||
const backupSettings = settingsData!.settings;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -30,12 +30,6 @@ import { useAppTitle } from '@/features/navigation-bar/hooks/useAppTitle.ts';
|
||||
|
||||
type ExtensionsSettings = Pick<GqlServerSettings, 'maxSourcesInParallel' | 'localSourcePath' | 'extensionRepos'>;
|
||||
|
||||
const extractBrowseSettings = (settings: GqlServerSettings): ExtensionsSettings => ({
|
||||
maxSourcesInParallel: settings.maxSourcesInParallel,
|
||||
localSourcePath: settings.localSourcePath,
|
||||
extensionRepos: settings.extensionRepos,
|
||||
});
|
||||
|
||||
export const BrowseSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -76,7 +70,7 @@ export const BrowseSettings = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const serverSettings = extractBrowseSettings(data!.settings);
|
||||
const serverSettings = data!.settings;
|
||||
|
||||
return (
|
||||
<List sx={{ pt: 0 }}>
|
||||
|
||||
@@ -45,16 +45,6 @@ type DownloadSettingsType = Pick<
|
||||
| 'downloadConversions'
|
||||
>;
|
||||
|
||||
const extractDownloadSettings = (settings: ServerSettings): DownloadSettingsType => ({
|
||||
downloadAsCbz: settings.downloadAsCbz,
|
||||
downloadsPath: settings.downloadsPath,
|
||||
autoDownloadNewChapters: settings.autoDownloadNewChapters,
|
||||
autoDownloadNewChaptersLimit: settings.autoDownloadNewChaptersLimit,
|
||||
excludeEntryWithUnreadChapters: settings.excludeEntryWithUnreadChapters,
|
||||
autoDownloadIgnoreReUploads: settings.autoDownloadIgnoreReUploads,
|
||||
downloadConversions: settings.downloadConversions,
|
||||
});
|
||||
|
||||
export const DownloadSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -103,7 +93,7 @@ export const DownloadSettings = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const downloadSettings = extractDownloadSettings(serverSettings.data!.settings);
|
||||
const downloadSettings = serverSettings.data!.settings;
|
||||
|
||||
const updateSetting = <Setting extends keyof DownloadSettingsType>(
|
||||
setting: Setting,
|
||||
|
||||
@@ -16,7 +16,6 @@ import { MetadataUpdateSettings } from '@/features/app-updates/AppUpdateChecker.
|
||||
import { MetadataThemeSettings } from '@/features/theme/AppTheme.types.ts';
|
||||
import { GetServerSettingsQuery } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { MetadataHistorySettings } from '@/features/history/History.types.ts';
|
||||
import { ServerSettings as GqlServerSettings } from '@/features/settings/Settings.types.ts';
|
||||
|
||||
export type MetadataServerSettingKeys = keyof MetadataServerSettings;
|
||||
|
||||
@@ -37,52 +36,6 @@ export interface ISearchSettings {
|
||||
}
|
||||
|
||||
export type ServerSettings = Omit<GetServerSettingsQuery['settings'], '__typename'>;
|
||||
export type ServerSettingsType = Pick<
|
||||
GqlServerSettings,
|
||||
| 'ip'
|
||||
| 'port'
|
||||
| 'socksProxyEnabled'
|
||||
| 'socksProxyVersion'
|
||||
| 'socksProxyHost'
|
||||
| 'socksProxyPort'
|
||||
| 'socksProxyUsername'
|
||||
| 'socksProxyPassword'
|
||||
| 'debugLogsEnabled'
|
||||
| 'systemTrayEnabled'
|
||||
| 'maxLogFiles'
|
||||
| 'maxLogFileSize'
|
||||
| 'maxLogFolderSize'
|
||||
| 'authMode'
|
||||
| 'authUsername'
|
||||
| 'authPassword'
|
||||
| 'jwtAudience'
|
||||
| 'jwtTokenExpiry'
|
||||
| 'jwtRefreshExpiry'
|
||||
| 'flareSolverrEnabled'
|
||||
| 'flareSolverrTimeout'
|
||||
| 'flareSolverrUrl'
|
||||
| 'flareSolverrSessionName'
|
||||
| 'flareSolverrSessionTtl'
|
||||
| 'flareSolverrAsResponseFallback'
|
||||
| 'opdsUseBinaryFileSizes'
|
||||
| 'opdsItemsPerPage'
|
||||
| 'opdsEnablePageReadProgress'
|
||||
| 'opdsMarkAsReadOnDownload'
|
||||
| 'opdsShowOnlyUnreadChapters'
|
||||
| 'opdsShowOnlyDownloadedChapters'
|
||||
| 'opdsChapterSortOrder'
|
||||
| 'koreaderSyncServerUrl'
|
||||
| 'koreaderSyncUsername'
|
||||
| 'koreaderSyncUserkey'
|
||||
| 'koreaderSyncDeviceId'
|
||||
| 'koreaderSyncChecksumMethod'
|
||||
| 'koreaderSyncStrategy'
|
||||
| 'koreaderSyncPercentageTolerance'
|
||||
| 'databaseType'
|
||||
| 'databaseUrl'
|
||||
| 'databaseUsername'
|
||||
| 'databasePassword'
|
||||
>;
|
||||
|
||||
export type WebUISettingsType = Pick<
|
||||
ServerSettings,
|
||||
|
||||
@@ -47,16 +47,10 @@ const getSkipMangasText = (settings: GlobalUpdateSkipEntriesSettings) => {
|
||||
return skipSettings.join(', ');
|
||||
};
|
||||
|
||||
const extractSkipEntriesSettings = (serverSettings: ServerSettings): GlobalUpdateSkipEntriesSettings => ({
|
||||
excludeCompleted: serverSettings.excludeCompleted,
|
||||
excludeNotStarted: serverSettings.excludeNotStarted,
|
||||
excludeUnreadChapters: serverSettings.excludeUnreadChapters,
|
||||
});
|
||||
|
||||
export const GlobalUpdateSettingsEntries = ({ serverSettings }: { serverSettings: ServerSettings }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const globalUpdateSettings = extractSkipEntriesSettings(serverSettings);
|
||||
const globalUpdateSettings = serverSettings;
|
||||
const [mutateSettings] = requestManager.useUpdateServerSettings();
|
||||
|
||||
const [dialogSettings, setDialogSettings] = useState<GlobalUpdateSkipEntriesSettings>(
|
||||
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
} from '@/features/settings/services/ServerSettingsMetadata.ts';
|
||||
import { makeToast } from '@/base/utils/Toast.ts';
|
||||
import { MetadataUpdateSettings } from '@/features/app-updates/AppUpdateChecker.types.ts';
|
||||
import { ServerSettings as GqlServerSettings, ServerSettingsType } from '@/features/settings/Settings.types.ts';
|
||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||
import { useAppTitle } from '@/features/navigation-bar/hooks/useAppTitle.ts';
|
||||
import {
|
||||
@@ -47,52 +46,7 @@ import {
|
||||
} from '@/features/settings/Settings.constants.ts';
|
||||
import { ServerAddressSetting } from '@/features/settings/components/ServerAddressSetting.tsx';
|
||||
import { AuthManager } from '@/features/authentication/AuthManager.ts';
|
||||
|
||||
const extractServerSettings = (settings: GqlServerSettings): ServerSettingsType => ({
|
||||
ip: settings.ip,
|
||||
port: settings.port,
|
||||
socksProxyEnabled: settings.socksProxyEnabled,
|
||||
socksProxyVersion: settings.socksProxyVersion,
|
||||
socksProxyHost: settings.socksProxyHost,
|
||||
socksProxyPort: settings.socksProxyPort,
|
||||
socksProxyUsername: settings.socksProxyUsername,
|
||||
socksProxyPassword: settings.socksProxyPassword,
|
||||
debugLogsEnabled: settings.debugLogsEnabled,
|
||||
systemTrayEnabled: settings.systemTrayEnabled,
|
||||
maxLogFiles: settings.maxLogFiles,
|
||||
maxLogFileSize: settings.maxLogFileSize,
|
||||
maxLogFolderSize: settings.maxLogFolderSize,
|
||||
authMode: settings.authMode,
|
||||
authUsername: settings.authUsername,
|
||||
authPassword: settings.authPassword,
|
||||
jwtAudience: settings.jwtAudience,
|
||||
jwtTokenExpiry: settings.jwtTokenExpiry,
|
||||
jwtRefreshExpiry: settings.jwtRefreshExpiry,
|
||||
flareSolverrEnabled: settings.flareSolverrEnabled,
|
||||
flareSolverrTimeout: settings.flareSolverrTimeout,
|
||||
flareSolverrUrl: settings.flareSolverrUrl,
|
||||
flareSolverrSessionName: settings.flareSolverrSessionName,
|
||||
flareSolverrSessionTtl: settings.flareSolverrSessionTtl,
|
||||
flareSolverrAsResponseFallback: settings.flareSolverrAsResponseFallback,
|
||||
opdsUseBinaryFileSizes: settings.opdsUseBinaryFileSizes,
|
||||
opdsItemsPerPage: settings.opdsItemsPerPage,
|
||||
opdsEnablePageReadProgress: settings.opdsEnablePageReadProgress,
|
||||
opdsMarkAsReadOnDownload: settings.opdsMarkAsReadOnDownload,
|
||||
opdsShowOnlyUnreadChapters: settings.opdsShowOnlyUnreadChapters,
|
||||
opdsShowOnlyDownloadedChapters: settings.opdsShowOnlyDownloadedChapters,
|
||||
opdsChapterSortOrder: settings.opdsChapterSortOrder,
|
||||
koreaderSyncServerUrl: settings.koreaderSyncServerUrl,
|
||||
koreaderSyncUsername: settings.koreaderSyncUsername,
|
||||
koreaderSyncUserkey: settings.koreaderSyncUserkey,
|
||||
koreaderSyncDeviceId: settings.koreaderSyncDeviceId,
|
||||
koreaderSyncChecksumMethod: settings.koreaderSyncChecksumMethod,
|
||||
koreaderSyncStrategy: settings.koreaderSyncStrategy,
|
||||
koreaderSyncPercentageTolerance: settings.koreaderSyncPercentageTolerance,
|
||||
databaseType: settings.databaseType,
|
||||
databaseUrl: settings.databaseUrl,
|
||||
databaseUsername: settings.databaseUsername,
|
||||
databasePassword: settings.databasePassword,
|
||||
});
|
||||
import { ServerSettings as ServerSettingsType } from '@/features/settings/Settings.types.ts';
|
||||
|
||||
const getLogFilesCleanupDisplayValue = (ttl: number): string => {
|
||||
if (ttl === 0) {
|
||||
@@ -202,7 +156,7 @@ export const ServerSettings = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const serverSettings = extractServerSettings(data!.settings);
|
||||
const serverSettings = data!.settings;
|
||||
const authModeDisabled = !serverSettings.authUsername?.trim() || !serverSettings.authPassword?.trim();
|
||||
const isH2Database = serverSettings.databaseType === DatabaseType.H2;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from '@/features/settings/services/ServerSettingsMetadata.ts';
|
||||
import { makeToast } from '@/base/utils/Toast.ts';
|
||||
import { MetadataUpdateSettings } from '@/features/app-updates/AppUpdateChecker.types.ts';
|
||||
import { ServerSettings, WebUISettingsType } from '@/features/settings/Settings.types.ts';
|
||||
import { WebUISettingsType } from '@/features/settings/Settings.types.ts';
|
||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||
import { useAppTitle } from '@/features/navigation-bar/hooks/useAppTitle.ts';
|
||||
import {
|
||||
@@ -34,15 +34,6 @@ import {
|
||||
WEB_UI_INTERFACE_SELECT_VALUES,
|
||||
} from '@/features/settings/Settings.constants.ts';
|
||||
|
||||
const extractWebUISettings = (settings: ServerSettings): WebUISettingsType => ({
|
||||
webUIFlavor: settings.webUIFlavor,
|
||||
initialOpenInBrowserEnabled: settings.initialOpenInBrowserEnabled,
|
||||
webUIInterface: settings.webUIInterface,
|
||||
electronPath: settings.electronPath,
|
||||
webUIChannel: settings.webUIChannel,
|
||||
webUIUpdateCheckInterval: settings.webUIUpdateCheckInterval,
|
||||
});
|
||||
|
||||
export const WebUISettings = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -108,7 +99,7 @@ export const WebUISettings = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const webUISettings = extractWebUISettings(data!.settings);
|
||||
const webUISettings = data!.settings;
|
||||
const isCustomWebUI = webUISettings.webUIFlavor === WebUiFlavor.Custom;
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user