[client] Improved update checker

This commit is contained in:
Laura Hausmann 2023-10-04 03:13:20 +02:00
parent a4ccd41a30
commit 27a088a6a1
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 39 additions and 13 deletions

View file

@ -127,11 +127,24 @@ os.api("admin/abuse-user-reports", {
if (defaultStore.state.showAdminUpdates) {
os.api("latest-version").then((res) => {
const cleanRes = parseInt(res?.tag_name.replace(/[^0-9]/g, ""));
const cleanVersion = parseInt(version.replace(/[^0-9]/g, ""));
if (cleanRes > cleanVersion) {
updateAvailable = true;
}
if (!res?.tag_name) {
updateAvailable = false;
return;
}
const tag = res.tag_name as string;
if (tag === `v${version}`) {
updateAvailable = false;
return;
}
const tagDate = tag.includes('-') ? tag.substring(0, tag.indexOf('-')) : tag;
const versionDate = version.includes('-') ? version.substring(0, version.indexOf('-')) : version;
if (tagDate < versionDate) {
updateAvailable = false;
return;
}
updateAvailable = true;
return;
});
}

View file

@ -193,16 +193,29 @@ if ($i?.isAdmin) {
}).then((reports) => {
if (reports?.length > 0) thereIsUnresolvedAbuseReport = true;
});
}
if (defaultStore.state.showAdminUpdates) {
os.api("latest-version").then((res) => {
const cleanRes = parseInt(res?.tag_name.replace(/[^0-9]/g, ""));
const cleanVersion = parseInt(version.replace(/[^0-9]/g, ""));
if (cleanRes > cleanVersion) {
if (defaultStore.state.showAdminUpdates) {
os.api("latest-version").then((res) => {
if (!res?.tag_name) {
updateAvailable = false;
return;
}
const tag = res.tag_name as string;
if (tag === `v${version}`) {
updateAvailable = false;
return;
}
const tagDate = tag.includes('-') ? tag.substring(0, tag.indexOf('-')) : tag;
const versionDate = version.includes('-') ? version.substring(0, version.indexOf('-')) : version;
if (tagDate < versionDate) {
updateAvailable = false;
return;
}
updateAvailable = true;
}
});
return;
});
}
}
function openAccountMenu(ev: MouseEvent) {