Add toast to autoUpdater
This commit is contained in:
parent
ff31625544
commit
31ccdb73a1
|
|
@ -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}`);
|
||||
});
|
||||
Loading…
Reference in a new issue