From 8195e25b8c5bff76e7ba24ba1fdf7c73be096011 Mon Sep 17 00:00:00 2001 From: reya <123083837+reyamir@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:47:17 +0700 Subject: [PATCH] fix: updater --- .github/workflows/release.yml | 2 +- src-tauri/capabilities/default.json | 7 +++- src/commons.ts | 52 ++++++++++++++------------ src/routes/$account.chats.$id.lazy.tsx | 4 +- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0809593..f4fc545 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,4 +70,4 @@ jobs: releaseDraft: true prerelease: false args: ${{ matrix.args }} - includeDebug: true + includeDebug: false diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 056f9dc..b85a66d 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -17,6 +17,8 @@ "shell:allow-open", "dialog:default", "dialog:allow-open", + "dialog:allow-ask", + "dialog:allow-message", "window:allow-close", "window:allow-center", "window:allow-minimize", @@ -25,6 +27,9 @@ "window:allow-set-focus", "window:allow-start-dragging", "decorum:allow-show-snap-overlay", - "prevent-default:default" + "prevent-default:default", + "updater:default", + "updater:allow-check", + "updater:allow-download-and-install" ] } diff --git a/src/commons.ts b/src/commons.ts index c420f17..af767a4 100644 --- a/src/commons.ts +++ b/src/commons.ts @@ -101,36 +101,40 @@ export function isEmojiOnly(str: string) { */ export async function checkForAppUpdates(silent: boolean) { - const update = await check(); + try { + const update = await check(); - if (!update) { - if (silent) return; + if (!update) { + if (silent) return; - await message("You are on the latest version. Stay awesome!", { - title: "No Update Available", - kind: "info", - okLabel: "OK", - }); - - return; - } - - if (update?.available) { - const yes = await ask( - `Update to ${update.version} is available!\n\nRelease notes: ${update.body}`, - { - title: "Update Available", + await message("You are on the latest version. Stay awesome!", { + title: "No Update Available", kind: "info", - okLabel: "Update", - cancelLabel: "Cancel", - }, - ); + okLabel: "OK", + }); - if (yes) { - await update.downloadAndInstall(); - await relaunch(); + return; } + if (update?.available) { + const yes = await ask( + `Update to ${update.version} is available!\n\nRelease notes: ${update.body}`, + { + title: "Update Available", + kind: "info", + okLabel: "Update", + cancelLabel: "Cancel", + }, + ); + + if (yes) { + await update.downloadAndInstall(); + await relaunch(); + } + + return; + } + } catch { return; } } diff --git a/src/routes/$account.chats.$id.lazy.tsx b/src/routes/$account.chats.$id.lazy.tsx index 9b4474c..972ac20 100644 --- a/src/routes/$account.chats.$id.lazy.tsx +++ b/src/routes/$account.chats.$id.lazy.tsx @@ -256,12 +256,12 @@ function Form() { ) : (
-
-
+
*/}