Skip to content

Commit 29d3dd1

Browse files
committed
hopefully finally fix update issues
1 parent 2abd7d9 commit 29d3dd1

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

src/utils/helpers.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,35 @@ export const fetchServers = async (cached: boolean = true): Promise<void> => {
110110
};
111111

112112
export const fetchUpdateInfo = async () => {
113+
const { version } = useAppState.getState();
114+
113115
const nativeVer = await getVersion();
114116
const hostOS = await type();
115117
const response = await getUpdateInfo();
116118
if (response.data) {
119+
const versionInfo = response.data.versions[version];
120+
121+
if (versionInfo) {
122+
response.data.download = versionInfo.download;
123+
response.data.ompPluginChecksum = versionInfo.ompPluginChecksum;
124+
response.data.ompPluginDownload = versionInfo.ompPluginDownload;
125+
}
126+
117127
useAppState.getState().setUpdateInfo(response.data);
118128
useAppState.getState().setNativeAppVersionValue(nativeVer);
119129
useAppState.getState().setHostOSValue(hostOS);
120130
}
121131

122132
setTimeout(async () => {
123-
const {
124-
updateInfo,
125-
version,
126-
skipUpdate,
127-
skippedUpdateVersion,
128-
setUpdateInfo,
129-
} = useAppState.getState();
133+
const { updateInfo, skipUpdate, skippedUpdateVersion } =
134+
useAppState.getState();
130135
const { showMessageBox, hideMessageBox } = useMessageBox.getState();
131136

132137
if (updateInfo) {
133138
if (
134139
updateInfo.version != version &&
135140
skippedUpdateVersion != updateInfo.version
136141
) {
137-
const versionInfo = updateInfo.versions[updateInfo.version];
138-
if (versionInfo) {
139-
updateInfo.download = versionInfo.download;
140-
updateInfo.ompPluginChecksum = versionInfo.ompPluginChecksum;
141-
updateInfo.ompPluginDownload = versionInfo.ompPluginDownload;
142-
}
143-
144142
showMessageBox({
145143
title: t("update_modal_update_available_title"),
146144
description: t("update_modal_update_available_description", {
@@ -173,13 +171,7 @@ export const fetchUpdateInfo = async () => {
173171
],
174172
});
175173
} else {
176-
const versionInfo = updateInfo.versions[updateInfo.version];
177-
if (versionInfo) {
178-
updateInfo.download = versionInfo.download;
179-
updateInfo.ompPluginChecksum = versionInfo.ompPluginChecksum;
180-
updateInfo.ompPluginDownload = versionInfo.ompPluginDownload;
181-
}
182-
setUpdateInfo(updateInfo);
174+
Log.info("No new update available");
183175
}
184176
}
185177
}, 1000);

0 commit comments

Comments
 (0)