fix version check, link to release page

This commit is contained in:
Nystik 2026-05-17 15:48:24 +02:00
parent 80e5c610a5
commit 56776e7f13
2 changed files with 20 additions and 7 deletions

View file

@ -13,6 +13,11 @@ function getVersion(app) {
} }
} }
// SemVer build metadata (`+xyz`) is informational and ignored for precedence.
function stripBuildMetadata(version) {
return (version || "").split("+")[0];
}
async function checkForUpdate(currentVersion) { async function checkForUpdate(currentVersion) {
try { try {
const res = await fetch(GITHUB_API_LATEST); const res = await fetch(GITHUB_API_LATEST);
@ -22,10 +27,11 @@ async function checkForUpdate(currentVersion) {
} }
const data = await res.json(); const data = await res.json();
const latest = data.tag_name?.replace(/^v/, ""); const latest = stripBuildMetadata(data.tag_name?.replace(/^v/, ""));
const current = stripBuildMetadata(currentVersion);
if (latest && latest !== currentVersion) { if (latest && latest !== current) {
return latest; return { version: latest, url: data.html_url };
} }
return null; return null;
@ -59,9 +65,10 @@ function display(containerEl, app) {
cls: "ignis-header-version", cls: "ignis-header-version",
}); });
const updateIndicator = versionCol.createEl("span", { const updateIndicator = versionCol.createEl("a", {
text: "Checking...", text: "Checking...",
cls: "ignis-update-indicator", cls: "ignis-update-indicator",
attr: { target: "_blank", rel: "noopener noreferrer" },
}); });
const githubLink = right.createEl("a", { const githubLink = right.createEl("a", {
@ -75,10 +82,11 @@ function display(containerEl, app) {
attr: { src: "/assets/github.svg", alt: "GitHub" }, attr: { src: "/assets/github.svg", alt: "GitHub" },
}); });
checkForUpdate(version).then((latestVersion) => { checkForUpdate(version).then((latest) => {
if (latestVersion) { if (latest) {
updateIndicator.textContent = `v${latestVersion} available`; updateIndicator.textContent = `v${latest.version} available`;
updateIndicator.addClass("ignis-update-available"); updateIndicator.addClass("ignis-update-available");
updateIndicator.href = latest.url;
} else { } else {
updateIndicator.textContent = "Up to date"; updateIndicator.textContent = "Up to date";
} }

View file

@ -54,12 +54,17 @@
.ignis-update-indicator { .ignis-update-indicator {
font-size: var(--font-ui-smaller); font-size: var(--font-ui-smaller);
color: var(--text-faint); color: var(--text-faint);
text-decoration: none;
} }
.ignis-update-indicator.ignis-update-available { .ignis-update-indicator.ignis-update-available {
color: var(--text-accent); color: var(--text-accent);
} }
.ignis-update-indicator.ignis-update-available:hover {
text-decoration: underline;
}
.ignis-github-link { .ignis-github-link {
color: var(--text-muted); color: var(--text-muted);
display: flex; display: flex;