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
|
|
|
|
2024-09-26 15:33:22 +02:00
|
|
|
import { useContext, 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 ListAltIcon from '@mui/icons-material/ListAlt';
|
|
|
|
|
import BackupIcon from '@mui/icons-material/Backup';
|
|
|
|
|
import InfoIcon from '@mui/icons-material/Info';
|
|
|
|
|
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';
|
2024-10-05 16:09:34 +02:00
|
|
|
import { ListItemLink } from '@/modules/core/components/ListItemLink.tsx';
|
2024-10-05 22:17:23 +02:00
|
|
|
import { NavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx';
|
2024-10-05 16:09:34 +02:00
|
|
|
import { requestManager } from '@/lib/requests/requests/RequestManager.ts';
|
|
|
|
|
import { makeToast } from '@/lib/ui/Toast.ts';
|
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
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
const { setTitle, setAction } = useContext(NavBarContext);
|
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) {
|
|
|
|
|
makeToast(t('settings.clear_cache.label.failure'), 'error');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-20 01:23:52 +03:30
|
|
|
return (
|
2023-11-18 19:55:44 +01:00
|
|
|
<List sx={{ padding: 0 }}>
|
2024-09-04 23:44:32 +02:00
|
|
|
<ListItemLink to="/settings/appearance">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<PaletteIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.appearance.title')} />
|
|
|
|
|
</ListItemLink>
|
2023-11-18 19:55:44 +01:00
|
|
|
<ListItemLink to="/settings/categories">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<ListAltIcon />
|
|
|
|
|
</ListItemIcon>
|
2024-01-26 20:50:51 +01:00
|
|
|
<ListItemText primary={t('category.title.category_other')} />
|
2023-11-18 19:55:44 +01:00
|
|
|
</ListItemLink>
|
|
|
|
|
<ListItemLink to="/settings/defaultReaderSettings">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<AutoStoriesIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('reader.settings.title.default_reader_settings')} />
|
|
|
|
|
</ListItemLink>
|
|
|
|
|
<ListItemLink to="/settings/librarySettings">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<CollectionsOutlinedBookmarkIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('library.title')} />
|
|
|
|
|
</ListItemLink>
|
|
|
|
|
<ListItemLink to="/settings/downloadSettings">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<GetAppOutlinedIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('download.title')} />
|
|
|
|
|
</ListItemLink>
|
2024-02-16 19:55:54 +01:00
|
|
|
<ListItemLink to="/settings/trackingSettings">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<SyncIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('tracking.title')} />
|
|
|
|
|
</ListItemLink>
|
2023-11-18 19:55:44 +01:00
|
|
|
<ListItemLink to="/settings/backup">
|
|
|
|
|
<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-02-16 19:53:00 +01:00
|
|
|
<ListItemLink to="/settings/browseSettings">
|
2024-01-15 23:48:11 +01:00
|
|
|
<ListItemIcon>
|
|
|
|
|
<ExploreOutlinedIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('global.label.browse')} />
|
|
|
|
|
</ListItemLink>
|
2024-03-06 23:07:48 +01:00
|
|
|
<ListItemLink to="/settings/device">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<DevicesIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.device.title.device')} />
|
|
|
|
|
</ListItemLink>
|
2023-11-20 22:14:24 +01:00
|
|
|
<ListItemLink to="/settings/webUI">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<WebIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.webui.title.webui')} />
|
|
|
|
|
</ListItemLink>
|
2023-11-18 19:55:44 +01:00
|
|
|
<ListItemLink to="/settings/server">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<DnsIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.server.title.server')} />
|
|
|
|
|
</ListItemLink>
|
|
|
|
|
<ListItemLink to="/settings/about">
|
|
|
|
|
<ListItemIcon>
|
|
|
|
|
<InfoIcon />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText primary={t('settings.about.title')} />
|
|
|
|
|
</ListItemLink>
|
|
|
|
|
</List>
|
2021-02-20 01:23:52 +03:30
|
|
|
);
|
|
|
|
|
}
|