From 8222d82b0146065467442b290ab1b8e56d99db66 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sat, 1 Mar 2025 14:22:54 +0100 Subject: [PATCH] fix(update): ensure update check is only performed in Tauri environment --- src/app/app.component.ts | 66 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f9f87ae01..471beaf73 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -121,41 +121,43 @@ export class AppComponent { } async checkForUpdates() { - const update = await check(); - if (update?.available) { - console.log( - `found update ${update.version} from ${update.date} with notes ${update.body}` - ); - let downloaded = 0; - let contentLength = 0; + if (isTauri()) { + const update = await check(); + if (update?.available) { + console.log( + `found update ${update.version} from ${update.date} with notes ${update.body}` + ); + let downloaded = 0; + let contentLength = 0; - const wantsUpdate = await ask( - `New version ${update.version} is available. Do you want to update now?` - ); + const wantsUpdate = await ask( + `New version ${update.version} is available. Do you want to update now?` + ); - if (wantsUpdate) { - await update.downloadAndInstall((event) => { - switch (event.event) { - case 'Started': - contentLength = event.data.contentLength; - console.log( - `started downloading ${event.data.contentLength} bytes` - ); - break; - case 'Progress': - downloaded += event.data.chunkLength; - console.log( - `downloaded ${downloaded} from ${contentLength}` - ); - break; - case 'Finished': - console.log('download finished'); - break; - } - }); + if (wantsUpdate) { + await update.downloadAndInstall((event) => { + switch (event.event) { + case 'Started': + contentLength = event.data.contentLength; + console.log( + `started downloading ${event.data.contentLength} bytes` + ); + break; + case 'Progress': + downloaded += event.data.chunkLength; + console.log( + `downloaded ${downloaded} from ${contentLength}` + ); + break; + case 'Finished': + console.log('download finished'); + break; + } + }); - console.log('update installed'); - await relaunch(); + console.log('update installed'); + await relaunch(); + } } } }