Skip to content

Commit

Permalink
feat: confirm update dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Mar 21, 2024
1 parent 2bf8527 commit 5eb71a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src-tauri/capabilities/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dialog:allow-message",
"dialog:allow-open",
"dialog:allow-confirm",
"dialog:allow-ask",
"shell:allow-open",
"process:allow-exit",
"updater:default"
Expand Down
5 changes: 1 addition & 4 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEU1QkM5MTlDREQ4NkEzNjMKUldSam80YmRuSkc4NVNxS2MzYVZPN1I4a283RkdsS0lPTjVjRWlxQ1JhdzFZUkRtc0c1eEtqSzQK",
"endpoints": [
"https://api.liquidbounce.net/api/v1/launcher/releases/{{target}}/{{current_version}}"
],
"windows": {
"installMode": "basicUi"
}
]
}
}
}
9 changes: 7 additions & 2 deletions src/lib/Window.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
import MainScreen from "./main/MainScreen.svelte";
import { check } from "@tauri-apps/plugin-updater";
import { relaunch } from "@tauri-apps/plugin-process";
import { ask } from "@tauri-apps/plugin-dialog";
check()
.then((result) => {
.then(async (result) => {
console.debug("Update Check Result", result);
if (result && result.available) {
if (!await ask("An launcher update is available. Do you want to install it now?", "LiquidLaunher")) {
return;
}
result
.downloadAndInstall()
.then(() => {
relaunch().catch((e) => console.error(e));
relaunch().catch(console.error);
})
.catch((e) =>
console.error("Download and Install Failed", e),
Expand Down

0 comments on commit 5eb71a4

Please sign in to comment.