Inform about server version updates
This commit is contained in:
@@ -443,13 +443,14 @@
|
|||||||
"info": "Server version {{version}} ({{channel}}) available for download",
|
"info": "Server version {{version}} ({{channel}}) available for download",
|
||||||
"up_to_date": "This is the latest version",
|
"up_to_date": "This is the latest version",
|
||||||
"update_failure": "Update failed",
|
"update_failure": "Update failed",
|
||||||
|
"update_success": "{{name}} was updated to version {{version}} ({{channel}})",
|
||||||
"updating": "{{progress}}% | Updating…"
|
"updating": "{{progress}}% | Updating…"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"inform": {
|
"inform": {
|
||||||
"label": {
|
"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)",
|
"github": "$t(global.label.github) $t(settings.webui.title.webui)",
|
||||||
"info": "$t(settings.webui.title.webui) version {{version}} ({{channel}}) available for download",
|
"info": "$t(settings.webui.title.webui) version {{version}} ({{channel}}) available for download",
|
||||||
"update_failure": "Could not update $t(settings.webui.title.webui)",
|
"update_failure": "Could not update $t(settings.webui.title.webui)",
|
||||||
"update_success": "Updated $t(settings.webui.title.webui) to version {{version}}.",
|
|
||||||
"updated": "Updated version",
|
"updated": "Updated version",
|
||||||
"version": "$t(settings.webui.title.webui) version"
|
"version": "$t(settings.webui.title.webui) version"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,17 +7,28 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { useTranslation } from 'react-i18next';
|
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 { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { getVersion } from '@/screens/settings/About.tsx';
|
import { getVersion } from '@/screens/settings/About.tsx';
|
||||||
import { useUpdateChecker } from '@/util/useUpdateChecker.tsx';
|
import { useUpdateChecker } from '@/util/useUpdateChecker.tsx';
|
||||||
import { VersionUpdateInfoDialog } from '@/components/util/VersionUpdateInfoDialog.tsx';
|
import { VersionUpdateInfoDialog } from '@/components/util/VersionUpdateInfoDialog.tsx';
|
||||||
import { useMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts';
|
import { useMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts';
|
||||||
|
import { useLocalStorage } from '@/util/useStorage.tsx';
|
||||||
|
|
||||||
const disabledUpdateCheck = () => Promise.resolve();
|
const disabledUpdateCheck = () => Promise.resolve();
|
||||||
|
|
||||||
export const ServerUpdateChecker = () => {
|
export const ServerUpdateChecker = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [serverVersion, setServerVersion] = useLocalStorage<string>('serverVersion');
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
settings: { serverInformAvailableUpdate },
|
settings: { serverInformAvailableUpdate },
|
||||||
} = useMetadataServerSettings();
|
} = useMetadataServerSettings();
|
||||||
@@ -47,6 +58,16 @@ export const ServerUpdateChecker = () => {
|
|||||||
selectedServerChannelInfo?.tag,
|
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) {
|
if (!serverInformAvailableUpdate) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -59,10 +80,7 @@ export const ServerUpdateChecker = () => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isServerUpdateAvailable) {
|
if (isServerUpdateAvailable) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isAboutPage = window.location.pathname === '/settings/about';
|
const isAboutPage = window.location.pathname === '/settings/about';
|
||||||
if (isAboutPage) {
|
if (isAboutPage) {
|
||||||
return null;
|
return null;
|
||||||
@@ -83,4 +101,40 @@ export const ServerUpdateChecker = () => {
|
|||||||
updateCheckerProps={['server', checkForUpdate, selectedServerChannelInfo?.tag]}
|
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>
|
<DialogTitle>{t('settings.about.webui.label.updated')}</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogContentText>
|
<DialogContentText>
|
||||||
{t('settings.about.webui.label.update_success', {
|
{t('global.update.label.update_success', {
|
||||||
version: webUIVersion,
|
name: t('settings.webui.title.webui'),
|
||||||
|
version: newVersion,
|
||||||
|
channel: aboutWebUI?.channel,
|
||||||
})}
|
})}
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user