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
This commit is contained in:
@@ -40,6 +40,9 @@ export const WebUIUpdateChecker = () => {
|
|||||||
|
|
||||||
const shouldCheckForUpdate = !isAutoUpdateEnabled && webUIInformAvailableUpdate;
|
const shouldCheckForUpdate = !isAutoUpdateEnabled && webUIInformAvailableUpdate;
|
||||||
|
|
||||||
|
const { data: aboutData } = requestManager.useGetAbout();
|
||||||
|
const { aboutWebUI } = aboutData ?? {};
|
||||||
|
|
||||||
const { data: webUIUpdateData, refetch: checkForUpdate } = requestManager.useCheckForWebUIUpdate({
|
const { data: webUIUpdateData, refetch: checkForUpdate } = requestManager.useCheckForWebUIUpdate({
|
||||||
notifyOnNetworkStatusChange: true,
|
notifyOnNetworkStatusChange: true,
|
||||||
fetchPolicy: 'cache-only',
|
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/releases/tag/${updateStatus.info?.tag}`
|
||||||
: `https://github.com/Suwayomi/Suwayomi-WebUI/issues/749`;
|
: `https://github.com/Suwayomi/Suwayomi-WebUI/issues/749`;
|
||||||
|
|
||||||
|
const newVersion = aboutWebUI?.tag;
|
||||||
|
const isSameAsCurrent = !newVersion || webUIVersion === newVersion;
|
||||||
|
|
||||||
|
if (!isSameAsCurrent && !open) {
|
||||||
|
setOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isError = webUIUpdateState === UpdateState.Error;
|
const isError = webUIUpdateState === UpdateState.Error;
|
||||||
if (isError) {
|
if (isError) {
|
||||||
@@ -85,6 +95,7 @@ export const WebUIUpdateChecker = () => {
|
|||||||
if (!updateStatus.info) {
|
if (!updateStatus.info) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
requestManager.graphQLClient.client.cache.writeFragment({
|
requestManager.graphQLClient.client.cache.writeFragment({
|
||||||
fragment: ABOUT_WEBUI,
|
fragment: ABOUT_WEBUI,
|
||||||
data: {
|
data: {
|
||||||
@@ -102,17 +113,6 @@ export const WebUIUpdateChecker = () => {
|
|||||||
updateAvailable: false,
|
updateAvailable: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const newVersion = updateStatus.info.tag;
|
|
||||||
const isSameAsCurrent = webUIVersion === newVersion;
|
|
||||||
|
|
||||||
setWebUIVersion(newVersion);
|
|
||||||
|
|
||||||
if (isSameAsCurrent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setOpen(true);
|
|
||||||
}, [webUIUpdateState]);
|
}, [webUIUpdateState]);
|
||||||
|
|
||||||
const isUpdateAvailable =
|
const isUpdateAvailable =
|
||||||
@@ -147,8 +147,7 @@ export const WebUIUpdateChecker = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleUpdate = open && webUIUpdateState === UpdateState.Idle;
|
if (!open) {
|
||||||
if (!handleUpdate) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +167,7 @@ export const WebUIUpdateChecker = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setWebUIVersion(newVersion);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user