From eb0ba0b6a8a1f03871b3085dd96ce45440df0448 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Tue, 7 May 2024 01:03:23 +0200 Subject: [PATCH] Improve detection of updated webUI version In case the webUI update status was reset from another device, other devices would not show an info that the webUI got updated --- src/components/util/WebUIUpdateChecker.tsx | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/util/WebUIUpdateChecker.tsx b/src/components/util/WebUIUpdateChecker.tsx index 1257af31..d017ea11 100644 --- a/src/components/util/WebUIUpdateChecker.tsx +++ b/src/components/util/WebUIUpdateChecker.tsx @@ -40,6 +40,9 @@ export const WebUIUpdateChecker = () => { const shouldCheckForUpdate = !isAutoUpdateEnabled && webUIInformAvailableUpdate; + const { data: aboutData } = requestManager.useGetAbout(); + const { aboutWebUI } = aboutData ?? {}; + const { data: webUIUpdateData, refetch: checkForUpdate } = requestManager.useCheckForWebUIUpdate({ notifyOnNetworkStatusChange: true, fetchPolicy: 'cache-only', @@ -63,6 +66,13 @@ export const WebUIUpdateChecker = () => { ? `https://github.com/Suwayomi/Suwayomi-WebUI/releases/tag/${updateStatus.info?.tag}` : `https://github.com/Suwayomi/Suwayomi-WebUI/issues/749`; + const newVersion = aboutWebUI?.tag; + const isSameAsCurrent = !newVersion || webUIVersion === newVersion; + + if (!isSameAsCurrent && !open) { + setOpen(true); + } + useEffect(() => { const isError = webUIUpdateState === UpdateState.Error; if (isError) { @@ -85,6 +95,7 @@ export const WebUIUpdateChecker = () => { if (!updateStatus.info) { return; } + requestManager.graphQLClient.client.cache.writeFragment({ fragment: ABOUT_WEBUI, data: { @@ -102,17 +113,6 @@ export const WebUIUpdateChecker = () => { updateAvailable: false, }, }); - - const newVersion = updateStatus.info.tag; - const isSameAsCurrent = webUIVersion === newVersion; - - setWebUIVersion(newVersion); - - if (isSameAsCurrent) { - return; - } - - setOpen(true); }, [webUIUpdateState]); const isUpdateAvailable = @@ -147,8 +147,7 @@ export const WebUIUpdateChecker = () => { ); } - const handleUpdate = open && webUIUpdateState === UpdateState.Idle; - if (!handleUpdate) { + if (!open) { return null; } @@ -168,6 +167,7 @@ export const WebUIUpdateChecker = () => {