diff options
| author | Brendan Allan <[email protected]> | 2025-12-17 22:51:14 +0800 |
|---|---|---|
| committer | Brendan Allan <[email protected]> | 2025-12-17 22:51:14 +0800 |
| commit | c6f84f32d7e7361a0919fc8573b55ff920196f72 (patch) | |
| tree | 3484595fb5bf515415c54d68e1ca0062d48cc475 | |
| parent | ebe25c3e9a2114938f63de989cdcb2c6924eaa8b (diff) | |
| download | opencode-c6f84f32d7e7361a0919fc8573b55ff920196f72.tar.gz opencode-c6f84f32d7e7361a0919fc8573b55ff920196f72.zip | |
tauri: only alert on update failure when triggered manually
| -rw-r--r-- | packages/tauri/src/index.tsx | 2 | ||||
| -rw-r--r-- | packages/tauri/src/menu.ts | 2 | ||||
| -rw-r--r-- | packages/tauri/src/updater.ts | 24 |
3 files changed, 14 insertions, 14 deletions
diff --git a/packages/tauri/src/index.tsx b/packages/tauri/src/index.tsx index f3c329b34..01df8166a 100644 --- a/packages/tauri/src/index.tsx +++ b/packages/tauri/src/index.tsx @@ -54,7 +54,7 @@ createMenu() render(() => { onMount(() => { - if (UPDATER_ENABLED) runUpdater() + if (UPDATER_ENABLED) runUpdater({ alertOnFail: false }) }) return ( diff --git a/packages/tauri/src/menu.ts b/packages/tauri/src/menu.ts index d32506d32..d1a5fba8e 100644 --- a/packages/tauri/src/menu.ts +++ b/packages/tauri/src/menu.ts @@ -16,7 +16,7 @@ export async function createMenu() { }), await MenuItem.new({ enabled: UPDATER_ENABLED, - action: () => runUpdater(), + action: () => runUpdater({ alertOnFail: true }), text: "Check For Updates...", }), await PredefinedMenuItem.new({ diff --git a/packages/tauri/src/updater.ts b/packages/tauri/src/updater.ts index 2dd94e831..2ecb0f2e0 100644 --- a/packages/tauri/src/updater.ts +++ b/packages/tauri/src/updater.ts @@ -1,42 +1,42 @@ -import { check, DownloadEvent } from "@tauri-apps/plugin-updater" +import { check } from "@tauri-apps/plugin-updater" import { relaunch } from "@tauri-apps/plugin-process" import { ask, message } from "@tauri-apps/plugin-dialog" import { invoke } from "@tauri-apps/api/core" export const UPDATER_ENABLED = window.__OPENCODE__?.updaterEnabled ?? false -export async function runUpdater(onDownloadEvent?: (progress: DownloadEvent) => void) { +export async function runUpdater({ alertOnFail }: { alertOnFail: boolean }) { let update try { update = await check() } catch { - await message("Failed to check for updates") - return false + if(alertOnFail) await message("Failed to check for updates", { title: "Update Check Failed"}) } - if (!update) return - if (update.version <= update.currentVersion) return + if (!update){ + if(alertOnFail) await message("You are already using the latest version of OpenCode", { title: "No Update Available"}) + + return + } try { - await update.download(onDownloadEvent) + await update.download() } catch { - return false + if(alertOnFail) await message("Failed to download update", { title: "Update Failed" }) } const shouldUpdate = await ask( `Version ${update.version} of OpenCode has been downloaded, would you like to install it and relaunch?`, + { title: "Update Downloaded" } ) if (!shouldUpdate) return try { await update.install() } catch { - await message("Failed to install update") - return false + await message("Failed to install update", { title: "Update Failed" }) } await invoke("kill_sidecar") await relaunch() - - return true } |
