Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions v2/package-lock.json

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

1 change: 1 addition & 0 deletions v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-dialog": "^2.7.1",
"@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-process": "^2.3.1",
"@tauri-apps/plugin-updater": "^2.10.1"
},
"devDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions v2/src-tauri/Cargo.lock

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

1 change: 1 addition & 0 deletions v2/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
tauri-plugin-dialog = "2"
tauri-plugin-updater = "2"
tauri-plugin-process = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

Expand Down
3 changes: 2 additions & 1 deletion v2/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"core:default",
"opener:default",
"dialog:allow-open",
"updater:default"
"updater:default",
"process:allow-restart"
]
}
1 change: 1 addition & 0 deletions v2/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub fn run() {
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_process::init())
.manage(state)
.invoke_handler(tauri::generate_handler![
devices::list_devices,
Expand Down
28 changes: 26 additions & 2 deletions v2/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { page } from "$app/stores";
import { openUrl } from "@tauri-apps/plugin-opener";
import { check, type Update } from "@tauri-apps/plugin-updater";
import { relaunch } from "@tauri-apps/plugin-process";
import { getThemePref, setThemePref, type ThemePref } from "$lib/theme";
import { getAutoUpdate, setAutoUpdate } from "$lib/prefs";
import { api } from "$lib/api";
Expand All @@ -15,6 +16,7 @@
let update = $state<UpdateInfo | null>(null);
let pendingUpdate = $state<Update | null>(null);
let updateBusy = $state(false);
let updateInstalled = $state(false);
let updateProgress = $state("");

onMount(() => {
Expand Down Expand Up @@ -55,13 +57,24 @@
updateProgress = "Installing…";
}
});
updateProgress = "Update installed — restart the app to apply.";
updateInstalled = true;
updateBusy = false;
} catch (e) {
updateProgress = `Update failed: ${e}`;
updateBusy = false;
}
}

async function restartApp() {
try {
await relaunch();
} catch (e) {
updateProgress = `Couldn't restart automatically (${e}) — quit and reopen to finish updating.`;
updateInstalled = false;
updateBusy = true;
}
}

function toggleAutoUpdate() {
autoUpdate = !autoUpdate;
setAutoUpdate(autoUpdate);
Expand All @@ -87,7 +100,11 @@
{#if update}
<span class="version" title="Installed version">v{update.current}</span>
{#if pendingUpdate}
{#if updateBusy}
{#if updateInstalled}
<button class="update-badge installed" onclick={restartApp} title="Relaunch to finish updating">
Update installed — Restart now ↻
</button>
{:else if updateBusy}
<span class="update-badge updating">{updateProgress}</span>
{:else}
<button class="update-badge" onclick={installUpdate} title="Download and install now">
Expand Down Expand Up @@ -371,6 +388,13 @@
cursor: default;
opacity: 0.8;
}
.update-badge.installed {
background: var(--accent);
color: #fff;
}
.update-badge.installed:hover {
background: var(--accent-strong-hover);
}
.header-right {
display: flex;
align-items: center;
Expand Down
Loading