fix(admin): fix version update prompt. Fixes #4097

This commit is contained in:
Gabe Kangas
2025-01-08 15:39:25 -08:00
parent 591da94daf
commit b52bbc7f53
3 changed files with 140 additions and 280 deletions

View File

@@ -180,28 +180,9 @@ export async function getGithubRelease() {
return fetchExternalData(GITHUB_RELEASE_URL);
}
// Stolen from https://gist.github.com/prenagha/98bbb03e27163bc2f5e4
const VPAT = /^\d+(\.\d+){0,2}$/;
function upToDate(local, remote) {
if (!local || !remote || local.length === 0 || remote.length === 0) return false;
if (local === remote) return true;
if (VPAT.test(local) && VPAT.test(remote)) {
const lparts = local.split('.');
while (lparts.length < 3) lparts.push('0');
const rparts = remote.split('.');
while (rparts.length < 3) rparts.push('0');
// eslint-disable-next-line no-plusplus
for (let i = 0; i < 3; i++) {
const l = parseInt(lparts[i], 10);
const r = parseInt(rparts[i], 10);
if (l === r)
// eslint-disable-next-line no-continue
continue;
return l > r;
}
return true;
}
return local >= remote;
const semverGt = require('semver/functions/gt');
return !semverGt(remote, local);
}
// Make a request to the server status API and the Github releases API