* Introduce "RequestManager"
* Use "RequestManager" - Simple replacements
- Get rid of all "util/client" imports
- replace old requests with new "RequestManager"
- remove "fetcher" from global SWR config
instead of using the SWR hooks by themselves, the "requestManager" is supposed to be used
* Use "RequestManager" - Do requests via SWR hooks
Use SWR hooks at places where it's easily usable
* Prevent trailing slashes in the "baseUrl"
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
/*
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
import React, { useContext, useEffect } from 'react';
|
|
import List from '@mui/material/List';
|
|
import ListItem from '@mui/material/ListItem';
|
|
import ListItemText from '@mui/material/ListItemText';
|
|
import ListItemLink from 'components/util/ListItemLink';
|
|
import NavbarContext from 'components/context/NavbarContext';
|
|
import LoadingPlaceholder from 'components/util/LoadingPlaceholder';
|
|
import { useTranslation } from 'react-i18next';
|
|
import requestManager from 'lib/RequestManager';
|
|
|
|
export default function About() {
|
|
const { t } = useTranslation();
|
|
const { setTitle, setAction } = useContext(NavbarContext);
|
|
|
|
useEffect(() => {
|
|
setTitle(t('settings.about.title'));
|
|
setAction(null);
|
|
}, [t]);
|
|
|
|
const { data: about } = requestManager.useGetAbout();
|
|
|
|
if (about === undefined) {
|
|
return <LoadingPlaceholder />;
|
|
}
|
|
|
|
const version = () => {
|
|
if (about.buildType === 'Stable') return `${about.version}`;
|
|
return `${about.version}-${about.revision}`;
|
|
};
|
|
|
|
const buildTime = () => new Date(about.buildTime * 1000).toUTCString();
|
|
|
|
return (
|
|
<List>
|
|
<ListItem>
|
|
<ListItemText
|
|
primary={t('settings.about.label.server')}
|
|
secondary={`${about.name} ${about.buildType}`}
|
|
/>
|
|
</ListItem>
|
|
<ListItem>
|
|
<ListItemText primary={t('settings.about.label.server_version')} secondary={version()} />
|
|
</ListItem>
|
|
<ListItem>
|
|
<ListItemText primary={t('settings.about.label.build_time')} secondary={buildTime()} />
|
|
</ListItem>
|
|
<ListItemLink directLink to={about.github}>
|
|
<ListItemText primary={t('settings.about.label.github')} secondary={about.github} />
|
|
</ListItemLink>
|
|
<ListItemLink directLink to={about.discord}>
|
|
<ListItemText primary={t('settings.about.label.discord')} secondary={about.discord} />
|
|
</ListItemLink>
|
|
</List>
|
|
);
|
|
}
|