Skip to content

Commit

Permalink
add version checking for tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
spartacus04 committed Mar 27, 2024
1 parent c18e5b3 commit 60726cd
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 3 deletions.
76 changes: 76 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tauri-build = { version = "1.5.1", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.6.0", features = [ "dialog-confirm", "window-set-focus", "window-request-user-attention"] }
tauri = { version = "1.6.0", features = [ "shell-open", "dialog-confirm", "window-set-focus", "window-request-user-attention"] }
ffmpeg-sidecar = "1.0.1"
base64 = "0.22.0"
tauri-plugin-deep-link = { git = "https://github.com/FabianLars/tauri-plugin-deep-link", branch = "main" }
Expand Down
5 changes: 4 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"build": {
"beforeBuildCommand": "npm run build",
"beforeDevCommand": "npm run dev",
"devPath": "http://localhost:5173",
"devPath": "http://localhost:5173/jext-reborn/",
"distDir": "../build"
},
"package": {
Expand All @@ -19,6 +19,9 @@
"dialog": {
"confirm": true
},
"shell": {
"open": true
},
"all": false
},
"bundle": {
Expand Down
27 changes: 27 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom';
import { onMount } from 'svelte';
import { UserAttentionType, appWindow } from '@tauri-apps/api/window';
import { confirm } from '@tauri-apps/api/dialog';
import { open } from '@tauri-apps/api/shell';
import { base } from '$app/paths';
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
Expand All @@ -48,6 +50,31 @@
appWindow.requestUserAttention(UserAttentionType.Critical);
appWindow.setFocus();
});
try {
(async () => {
const currentVersion = await fetch(`${base}/_app/version.json`).then((res) => res.json());
const latestVersion = await fetch('https://spartacus04.github.io/jext-reborn/_app/version.json').then((res) =>
res.json()
);
if (currentVersion.version !== latestVersion.version) {
const update = await confirm('A new version of the Jext Companion App is available. Do you want to update?');
if (update) {
const response = await fetch(
'https://api.github.com/repos/spartacus04/jext-reborn/actions/workflows/build-tauri.yml/runs?status=success&per_page=1'
);
const json = await response.json();
if (json.total_count == 0) return;
open(json.workflow_runs[0].html_url);
}
}
})();
} catch(_) { }
}
onMount(async () => {
Expand Down
3 changes: 2 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const config = {
kit: {
adapter: adapter(),
paths: {
base: '/jext-reborn'
base: process.env.TAURI_PLATFORM == undefined ? '/jext-reborn' : ''
}
}
};

export default config;

0 comments on commit 60726cd

Please sign in to comment.