From 31ccdb73a10a381fe5b629ff1ef32c663ac2e03c Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Mon, 26 Jan 2026 15:37:39 +0100 Subject: [PATCH] Add toast to autoUpdater --- src/main/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 95a91e6..4d9bbab 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -4,6 +4,7 @@ import { electronApp, optimizer, is } from '@electron-toolkit/utils' import icon from '../../resources/icon.png?asset' import { autoUpdater } from 'electron-updater' import Store from './lib/Store' +import { registerToastTarget, showErrorToast, showSuccessToast, showToast } from './lib/Toast' autoUpdater.autoDownload = false; autoUpdater.autoInstallOnAppQuit = true; @@ -80,6 +81,7 @@ function finishSetup(): void { store.set('showSetupWindow', false); createMainWindow(); mainWindow.on('ready-to-show', () => { + registerToastTarget(mainWindow); mainWindow.show(); setupWindow.close(); }) @@ -98,6 +100,8 @@ function createWindow(): void { } else { createMainWindow(); mainWindow.on('ready-to-show', () => { + registerToastTarget(mainWindow); + checkForUpdates(); splashWindow.close(); mainWindow.show(); }) @@ -132,8 +136,6 @@ app.whenReady().then(() => { // dock icon is clicked and there are no other windows open. if (BrowserWindow.getAllWindows().length === 0) createWindow() }) - - checkForUpdates(); }) // Quit when all windows are closed, except on macOS. There, it's common @@ -156,30 +158,36 @@ function showNotification(value: any) { function checkForUpdates() { autoUpdater.checkForUpdates(); console.log(`Checking for updates. Current version ${app.getVersion()}`); + showToast(`Checking for updates. Current version ${app.getVersion()}`); showNotification(`Checking for updates. Current version ${app.getVersion()}`); } /*New Update Available*/ autoUpdater.on("update-available", () => { console.log(`Update available. Current version ${app.getVersion()}`); + showToast(`Update available. Current version ${app.getVersion()}`); showNotification(`Update available. Current version ${app.getVersion()}`); let pth = autoUpdater.downloadUpdate(); console.log(pth); + showToast(`Download update path : ${pth}`); showNotification(`Download update path : ${pth}`); }); autoUpdater.on("update-not-available", () => { console.log(`No update available. Current version ${app.getVersion()}`); + showToast(`No update available. Current version ${app.getVersion()}`); showNotification(`No update available. Current version ${app.getVersion()}`); }); /*Download Completion Message*/ autoUpdater.on("update-downloaded", () => { console.log(`Update downloaded. Current version ${app.getVersion()}`); + showSuccessToast(`Update downloaded. Current version ${app.getVersion()}`); showNotification(`Update downloaded. Current version ${app.getVersion()}`); }); autoUpdater.on("error", (info) => { console.log(info); + showErrorToast(`Error: ${info}`); showNotification(`Error: ${info}`); }); \ No newline at end of file