diff --git a/backend/src/util.rs b/backend/src/util.rs index 2d14cdb..81b2d82 100644 --- a/backend/src/util.rs +++ b/backend/src/util.rs @@ -28,7 +28,7 @@ pub fn _relative_to_seconds(rel: impl AsRef) -> u64 { pub fn version_string() -> String { format!( - "Procchi v{}.{}.{}, by {}", + r#"{{ "name": "Procchi", "version": "{}.{}.{}", "author": "{}" }}"#, env!("CARGO_PKG_VERSION_MAJOR"), env!("CARGO_PKG_VERSION_MINOR"), env!("CARGO_PKG_VERSION_PATCH"), diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index 4b474c5..f4c5a45 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -33,8 +33,16 @@ export function App() { ;(async () => { // Get version and alert it const res = await fetch('/api/version_info') - const data = await res.text() - window.dispatchEvent(ProcchiAlert(data)) + const data = await res.json() + window.dispatchEvent(ProcchiAlert(`${data.name} v${data.version} by ${data.author}`)) + + // Also check for updates + const updateRes = await fetch('https://api.github.com/repos/SpikeHD/procchi/releases/latest') + const updateData = await updateRes.json() + + if (updateData.tag_name !== `v${data.version}`) { + window.dispatchEvent(ProcchiAlert(`A new version of Procchi (${updateData.tag_name}) is available!`)) + } })() }, [])