From c3ca512395a6b5899e15e711881c280007a5ff73 Mon Sep 17 00:00:00 2001 From: didirus Date: Sat, 20 Jun 2026 00:43:55 +0300 Subject: [PATCH] fix(app-frontend): compare launcher versions numerically --- .../src/helpers/astralrinth/update.ts | 52 +++++++++++++++++-- apps/app/tauri.conf.json | 2 +- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/apps/app-frontend/src/helpers/astralrinth/update.ts b/apps/app-frontend/src/helpers/astralrinth/update.ts index 7fc2ddae8..b425a5db3 100644 --- a/apps/app-frontend/src/helpers/astralrinth/update.ts +++ b/apps/app-frontend/src/helpers/astralrinth/update.ts @@ -58,18 +58,33 @@ export async function fetchRemote(): Promise { latestLauncherRelease.value = remoteData if (systems.includes(currentOS.value as (typeof systems)[number])) { - const localVersion = normalizeVersion(await getVersion()) + const rawLocalVersion = await getVersion() + const localVersion = normalizeVersion(rawLocalVersion) const remoteVersion = normalizeVersion(remoteData.tag_name) - isUpdateAvailable.value = remoteVersion !== localVersion + const versionComparison = compareVersions(remoteVersion, localVersion) + isUpdateAvailable.value = versionComparison > 0 + + if (isDeveloper) { + console.debug('Raw local version is', rawLocalVersion) + console.debug('Normalized local version is', localVersion) + console.debug('Raw remote version is', remoteData.tag_name) + console.debug('Normalized remote version is', remoteVersion) + console.debug('Local version parts are', parseVersionParts(localVersion)) + console.debug('Remote version parts are', parseVersionParts(remoteVersion)) + console.debug('Version comparison result is', versionComparison) + } } else { isUpdateAvailable.value = false + + if (isDeveloper) { + console.debug('Skipped update comparison for unsupported OS', currentOS.value) + } } if (isDeveloper) { console.debug('Update available state is', isUpdateAvailable.value) console.debug('Remote version is', remoteData.tag_name) console.debug('Remote title is', remoteData.name) - console.debug('Local version is', await getVersion()) console.debug('Operating System is', currentOS.value) } } catch (error) { @@ -146,3 +161,34 @@ function resolveOperationalSystemExtension(): string[] { function normalizeVersion(version: string): string { return version.trim().replace(/^v/i, '') } + +function compareVersions(left: string, right: string): number { + const leftParts = parseVersionParts(left) + const rightParts = parseVersionParts(right) + const maxLength = Math.max(leftParts.length, rightParts.length) + + for (let index = 0; index < maxLength; index += 1) { + const leftPart = leftParts[index] ?? 0 + const rightPart = rightParts[index] ?? 0 + + if (leftPart !== rightPart) { + if (isDeveloper) { + console.debug('Version parts differ at index', index, leftPart, rightPart) + } + return leftPart - rightPart + } + } + + if (isDeveloper) { + console.debug('Version parts are equal', leftParts, rightParts) + } + + return 0 +} + +function parseVersionParts(version: string): number[] { + return normalizeVersion(version) + .split(/[.-]/) + .map((part) => Number.parseInt(part, 10)) + .filter((part) => !Number.isNaN(part)) +} diff --git a/apps/app/tauri.conf.json b/apps/app/tauri.conf.json index 6e645a399..7e6c5b49f 100644 --- a/apps/app/tauri.conf.json +++ b/apps/app/tauri.conf.json @@ -63,7 +63,7 @@ ] }, "productName": "AstralRinth App", - "version": "0.14.701", + "version": "0.14.702", "mainBinaryName": "AstralRinth App", "identifier": "AstralRinthApp", "plugins": {