Skip to content

Commit

Permalink
autoupdate restart prompt works
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmichels committed May 4, 2020
1 parent 15ed15b commit 0612484
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions electron/src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const { app, BrowserWindow, autoUpdater, dialog} = require('electron');
const path = require('path');
require('update-electron-app')({
repo:'jacobmichels/boosted'
repo:'jacobmichels/boosted',
notifyUser:false
})

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
}

autoUpdater.on('update-downloaded',(event, releaseNotes, releaseName, releaseDate, updateURL)=>{
const dialogOpts = {
type: 'info',
buttons: ['Restart','Later'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version has been downloaded. Exit the application to apply the updates.'
}
let index = dialog.showMessageBoxSync(dialogOpts);
if(index===0){
autoUpdater.quitAndInstall();
}
})



const createWindow = () => {
Expand Down Expand Up @@ -46,7 +61,9 @@ const createWindow = () => {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
app.on('ready',()=>{
createWindow();
});

// Quit when all windows are closed.
app.on('window-all-closed', () => {
Expand Down

0 comments on commit 0612484

Please sign in to comment.