2021-03-26 04:17:02 +04:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
2021-02-20 01:23:52 +03:30
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2021-02-20 01:23:52 +03:30
|
|
|
|
2025-01-21 20:34:17 +01:00
|
|
|
import { useLayoutEffect } from 'react';
|
2023-01-06 17:34:16 +01:00
|
|
|
import AutoStoriesIcon from '@mui/icons-material/AutoStories';
|
2021-09-09 17:51:22 +04:30
|
|
|
import List from '@mui/material/List';
|
|
|
|
|
import BackupIcon from '@mui/icons-material/Backup';
|
|
|
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
|
|
import ListItemText from '@mui/material/ListItemText';
|
2024-04-14 15:50:12 +02:00
|
|
|
import ListItemButton from '@mui/material/ListItemButton';
|
2023-03-23 13:59:32 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-04-22 13:03:51 +02:00
|
|
|
import CollectionsOutlinedBookmarkIcon from '@mui/icons-material/CollectionsBookmarkOutlined';
|
2023-11-04 14:40:43 +01:00
|
|
|
import GetAppOutlinedIcon from '@mui/icons-material/GetAppOutlined';
|
2023-11-18 19:55:44 +01:00
|
|
|
import DnsIcon from '@mui/icons-material/Dns';
|
2023-11-20 22:14:24 +01:00
|
|
|
import WebIcon from '@mui/icons-material/Web';
|
2023-12-09 14:16:52 +01:00
|
|
|
import DeleteForeverIcon from '@mui/icons-material/DeleteForever';
|
2024-01-15 23:48:11 +01:00
|
|
|
import ExploreOutlinedIcon from '@mui/icons-material/ExploreOutlined';
|
2024-03-06 23:07:48 +01:00
|
|
|
import DevicesIcon from '@mui/icons-material/Devices';
|
2024-02-16 19:55:54 +01:00
|
|
|
import SyncIcon from '@mui/icons-material/Sync';
|
2024-09-04 23:44:32 +02:00
|
|
|
import PaletteIcon from '@mui/icons-material/Palette';
|
2025-03-22 01:16:38 +01:00
|
|
|
import HistoryIcon from '@mui/icons-material/History';
|
2025-05-03 12:14:05 +02:00
|
|
|
import { ListItemLink } from '@/modules/core/components/lists/ListItemLink.tsx';
|
2024-10-06 01:27:51 +02:00
|
|
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
2024-10-05 23:22:42 +02:00
|
|
|
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
2024-12-11 20:10:59 +01:00
|
|
|
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
2024-12-20 17:24:40 +01:00
|
|
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
2025-01-21 20:34:17 +01:00
|
|
|
import { useNavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx';
|
2021-02-20 01:23:52 +03:30
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
export function Settings() {
|
2024-09-05 00:27:35 +02:00
|
|
|
const { t } = useTranslation();
|
2023-03-23 13:59:32 +01:00
|
|
|
|
2025-01-21 20:34:17 +01:00
|
|
|
const { setTitle, setAction } = useNavBarContext();
|
2024-09-26 15:33:22 +02:00
|
|
|
useLayoutEffect(() => {
|
2023-03-23 13:59:32 +01:00
|
|
|
setTitle(t('settings.title'));
|
2023-03-11 18:05:58 +01:00
|
|
|
setAction(null);
|
2024-01-26 20:50:51 +01:00
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
setTitle('');
|
|
|
|
|
setAction(null);
|
|
|
|
|
};
|
2023-03-28 23:14:03 +02:00
|
|
|
}, [t]);
|
2021-03-09 16:44:09 +03:30
|
|
|
|
2023-12-09 14:16:52 +01:00
|
|
|
const [triggerClearServerCache, { loading: isClearingServerCache }] = requestManager.useClearServerCache();
|
|
|
|
|
|
|
|
|
|
const clearServerCache = async () => {
|
|
|
|
|
try {
|
|
|
|
|
await triggerClearServerCache();
|
|
|
|
|
makeToast(t('settings.clear_cache.label.success'), 'success');
|
|
|
|
|
} catch (e) {
|
2024-12-20 17:24:40 +01:00
|
|
|
makeToast(t('settings.clear_cache.label.failure'), 'error', getErrorMessage(e));
|
2023-12-09 14:16:52 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-20 01:23:52 +03:30
|
|
|
return (
|
2023-11-18 19:55:44 +01:00
|
|
|
<List sx={{ padding: 0 }}>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.appearance.path}>
|
2024-09-04 23:44:32 +02:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<PaletteIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.appearance.title')} />
|
|
|
|
|
</ListItemLink>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.reader.path}>
|
2023-11-18 19:55:44 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<AutoStoriesIcon />
|
|
|
|
|
</ListItemIcon>
|
2025-03-17 12:05:22 +01:00
|
|
|
<ListItemText primary={t('reader.settings.title.reader')} />
|
2023-11-18 19:55:44 +01:00
|
|
|
</ListItemLink>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.library.path}>
|
2023-11-18 19:55:44 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<CollectionsOutlinedBookmarkIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('library.title')} />
|
|
|
|
|
</ListItemLink>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.download.path}>
|
2023-11-18 19:55:44 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<GetAppOutlinedIcon />
|
|
|
|
|
</ListItemIcon>
|
2025-03-17 00:45:50 +01:00
|
|
|
<ListItemText primary={t('download.title.download')} />
|
2023-11-18 19:55:44 +01:00
|
|
|
</ListItemLink>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.tracking.path}>
|
2024-02-16 19:55:54 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<SyncIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('tracking.title')} />
|
|
|
|
|
</ListItemLink>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.backup.path}>
|
2023-11-18 19:55:44 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<BackupIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.backup.title')} />
|
|
|
|
|
</ListItemLink>
|
2024-09-05 00:25:45 +02:00
|
|
|
|
2023-12-09 14:16:52 +01:00
|
|
|
<ListItemButton disabled={isClearingServerCache} onClick={clearServerCache}>
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<DeleteForeverIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText
|
|
|
|
|
primary={t('settings.clear_cache.label.title')}
|
|
|
|
|
secondary={t('settings.clear_cache.label.description')}
|
|
|
|
|
/>
|
|
|
|
|
</ListItemButton>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.browse.path}>
|
2024-01-15 23:48:11 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<ExploreOutlinedIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('global.label.browse')} />
|
|
|
|
|
</ListItemLink>
|
2025-03-22 01:16:38 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.history.path}>
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<HistoryIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('history.title')} />
|
|
|
|
|
</ListItemLink>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.device.path}>
|
2024-03-06 23:07:48 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<DevicesIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.device.title.device')} />
|
|
|
|
|
</ListItemLink>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.webui.path}>
|
2023-11-20 22:14:24 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<WebIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.webui.title.webui')} />
|
|
|
|
|
</ListItemLink>
|
2024-12-11 20:10:59 +01:00
|
|
|
<ListItemLink to={AppRoutes.settings.childRoutes.server.path}>
|
2023-11-18 19:55:44 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<DnsIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.server.title.server')} />
|
|
|
|
|
</ListItemLink>
|
|
|
|
|
</List>
|
2021-02-20 01:23:52 +03:30
|
|
|
);
|
|
|
|
|
}
|