Inform about server version updates
This commit is contained in:
@@ -443,13 +443,14 @@
|
||||
"info": "Server version {{version}} ({{channel}}) available for download",
|
||||
"up_to_date": "This is the latest version",
|
||||
"update_failure": "Update failed",
|
||||
"update_success": "{{name}} was updated to version {{version}} ({{channel}})",
|
||||
"updating": "{{progress}}% | Updating…"
|
||||
},
|
||||
"settings": {
|
||||
"inform": {
|
||||
"label": {
|
||||
"title": "Inform about available update",
|
||||
"description": "Shows a dialog in case a new version is available"
|
||||
"description": "Shows a dialog in case a new version is available",
|
||||
"title": "Inform about available update"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -793,7 +794,6 @@
|
||||
"github": "$t(global.label.github) $t(settings.webui.title.webui)",
|
||||
"info": "$t(settings.webui.title.webui) version {{version}} ({{channel}}) available for download",
|
||||
"update_failure": "Could not update $t(settings.webui.title.webui)",
|
||||
"update_success": "Updated $t(settings.webui.title.webui) to version {{version}}.",
|
||||
"updated": "Updated version",
|
||||
"version": "$t(settings.webui.title.webui) version"
|
||||
}
|
||||
|
||||
@@ -7,17 +7,28 @@
|
||||
*/
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useState } from 'react';
|
||||
import Dialog from '@mui/material/Dialog';
|
||||
import DialogTitle from '@mui/material/DialogTitle';
|
||||
import DialogContent from '@mui/material/DialogContent';
|
||||
import DialogContentText from '@mui/material/DialogContentText';
|
||||
import DialogActions from '@mui/material/DialogActions';
|
||||
import Button from '@mui/material/Button';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { getVersion } from '@/screens/settings/About.tsx';
|
||||
import { useUpdateChecker } from '@/util/useUpdateChecker.tsx';
|
||||
import { VersionUpdateInfoDialog } from '@/components/util/VersionUpdateInfoDialog.tsx';
|
||||
import { useMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts';
|
||||
import { useLocalStorage } from '@/util/useStorage.tsx';
|
||||
|
||||
const disabledUpdateCheck = () => Promise.resolve();
|
||||
|
||||
export const ServerUpdateChecker = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [serverVersion, setServerVersion] = useLocalStorage<string>('serverVersion');
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const {
|
||||
settings: { serverInformAvailableUpdate },
|
||||
} = useMetadataServerSettings();
|
||||
@@ -47,6 +58,16 @@ export const ServerUpdateChecker = () => {
|
||||
selectedServerChannelInfo?.tag,
|
||||
);
|
||||
|
||||
const changelogUrl =
|
||||
aboutServer?.buildType.toLowerCase() === 'stable'
|
||||
? `https://github.com/Suwayomi/Suwayomi-Server/releases/tag/${aboutServer.version}`
|
||||
: undefined;
|
||||
|
||||
const isSameAsCurrent = !version || serverVersion === version;
|
||||
if (!isSameAsCurrent && !open) {
|
||||
setOpen(true);
|
||||
}
|
||||
|
||||
if (!serverInformAvailableUpdate) {
|
||||
return null;
|
||||
}
|
||||
@@ -59,10 +80,7 @@ export const ServerUpdateChecker = () => {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isServerUpdateAvailable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isServerUpdateAvailable) {
|
||||
const isAboutPage = window.location.pathname === '/settings/about';
|
||||
if (isAboutPage) {
|
||||
return null;
|
||||
@@ -83,4 +101,40 @@ export const ServerUpdateChecker = () => {
|
||||
updateCheckerProps={['server', checkForUpdate, selectedServerChannelInfo?.tag]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open}>
|
||||
<DialogTitle>{t('settings.about.webui.label.updated')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>
|
||||
{t('global.update.label.update_success', {
|
||||
name: t('settings.server.title.server'),
|
||||
version,
|
||||
channel: aboutServer?.buildType,
|
||||
})}
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
{changelogUrl && (
|
||||
<Button href={changelogUrl} target="_blank" rel="noreferrer">
|
||||
{t('global.button.changelog')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
onClick={() => {
|
||||
setServerVersion(version);
|
||||
setOpen(false);
|
||||
}}
|
||||
variant="contained"
|
||||
>
|
||||
{t('global.button.ok')}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -156,8 +156,10 @@ export const WebUIUpdateChecker = () => {
|
||||
<DialogTitle>{t('settings.about.webui.label.updated')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>
|
||||
{t('settings.about.webui.label.update_success', {
|
||||
version: webUIVersion,
|
||||
{t('global.update.label.update_success', {
|
||||
name: t('settings.webui.title.webui'),
|
||||
version: newVersion,
|
||||
channel: aboutWebUI?.channel,
|
||||
})}
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
|
||||
Reference in New Issue
Block a user