Skip to content

Commit

Permalink
Add release version lookup to About
Browse files Browse the repository at this point in the history
  • Loading branch information
kettek committed Oct 21, 2024
1 parent b2f8748 commit 3cb35a5
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions frontend/src/sections/About.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,41 @@
export const open: boolean = false
let version: string = ''
let newer: boolean = false
let availableVersion: string = ''
let availableSHA: string = ''
function followLink(e: MouseEvent) {
e.preventDefault()
BrowserOpenURL((e.target as HTMLAnchorElement).href)
}
async function getRelease() {
const url = 'https://api.github.com/repos/kettek/staxie/releases/latest'
try {
newer = false
const results = await (await fetch(url)).json()
const tag = await (await fetch(`https://api.github.com/repos/kettek/staxie/git/ref/tags/${results.tag_name}`)).json()
const sha = tag.object.sha
availableVersion = results.tag_name
availableSHA = sha
if (sha !== version) {
newer = true
} else {
newer = false
}
} catch (e) {
console.error(e)
}
}
onMount(async () => {
if ((window as any)['go']) {
version = await Version()
await getRelease()
} else {
version = 'unknown browser'
}
Expand All @@ -41,6 +67,12 @@
<header>Version</header>
<span>{version}</span>
</article>
{#if availableVersion}
<article>
<header>Latest Version</header>
<Link on:click={followLink} href="https://github.com/kettek/staxie/releases/tag/{availableVersion}">{availableVersion} ({availableSHA})</Link>
</article>
{/if}
<article>
<header>Author</header>
<Link on:click={followLink} href="https://kettek.net">kettek</Link>
Expand Down

0 comments on commit 3cb35a5

Please sign in to comment.