diff --git a/public/locales/en.json b/public/locales/en.json index bcf20948..250364dd 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -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" } diff --git a/src/components/util/ServerUpdateChecker.tsx b/src/components/util/ServerUpdateChecker.tsx index 979ef15c..89a11d1b 100644 --- a/src/components/util/ServerUpdateChecker.tsx +++ b/src/components/util/ServerUpdateChecker.tsx @@ -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('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,28 +80,61 @@ export const ServerUpdateChecker = () => { return null; } - if (!isServerUpdateAvailable) { - return null; + if (isServerUpdateAvailable) { + const isAboutPage = window.location.pathname === '/settings/about'; + if (isAboutPage) { + return null; + } + + if (!updateChecker.handleUpdate) { + return null; + } + + return ( + + ); } - const isAboutPage = window.location.pathname === '/settings/about'; - if (isAboutPage) { - return null; - } - - if (!updateChecker.handleUpdate) { + if (!open) { return null; } return ( - + + {t('settings.about.webui.label.updated')} + + + {t('global.update.label.update_success', { + name: t('settings.server.title.server'), + version, + channel: aboutServer?.buildType, + })} + + + + {changelogUrl && ( + + )} + + + ); }; diff --git a/src/components/util/WebUIUpdateChecker.tsx b/src/components/util/WebUIUpdateChecker.tsx index d017ea11..8a0b2512 100644 --- a/src/components/util/WebUIUpdateChecker.tsx +++ b/src/components/util/WebUIUpdateChecker.tsx @@ -156,8 +156,10 @@ export const WebUIUpdateChecker = () => { {t('settings.about.webui.label.updated')} - {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, })}