Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See release notes before updating with electron-updater

I'm trying to get to update my Electron app via auto-update. I managed to get it working fine whereas it checks for updates, downloads the update, installs the update and restarts the application.

But what I really want is that I can check if there's an update; if there is show the release notes that are in my latest.yml file and the user can agree or cancel the update. (See screenshot below) enter image description here

I've tried checking for the releaseNote when I enter my update-available event, but the 2nd parameter is "undefined".

Along with that I can't really figure out how I can show a scrollable text dialog with a yes/no button structure either.

For now I've made a very crude messageBox to see if I can get the releaseNote from my yml file, with no luck. So, the newbie as I am when it comes to Electron and building/updating apps with it; I'm officially out of ideas.

This is how my update-available event looks now:

autoUpdater.on('update-available', (ev, info) => {
  sendStatusToWindow('Update available.' + info)
  dialog.showMessageBox({
    type: 'info',
    title: 'Found Updates',
    message: info.releaseNotes,
    buttons: ['Yes', 'No']
  }, (buttonIndex) => {
    if (buttonIndex === 0) {
      autoUpdater.downloadUpdate()
    }
  })
})

And my update-downloaded event:

autoUpdater.on('update-downloaded', (ev, info) => {
  sendStatusToWindow('Update downloaded: ' + info)
  autoUpdater.quitAndInstall()
})
like image 421
CaptainCarl Avatar asked Oct 18 '22 07:10

CaptainCarl


1 Answers

The electron-builder documentation is rather vague in regards to the object that is emitted in any of the autoUpdater instance events.

After quite some fiddling around, searching through the web, and reading documentation, I discovered that there should be only one parameter in the autoUpdater events:

autoUpdater.on('update-available', (updateInfo) => { //Callback function });

updateInfo is an arbitrary parameter name but the paramter is an object that contains the releaseNotes, releaseDate, and other information from the update. I am on electron-updater v4.0.6.

updateInfo then is an object with these values as its properties: updateInfo object properties

Source: electron.build/auto-update#module_electron-updater

like image 135
Nerux95 Avatar answered Oct 21 '22 04:10

Nerux95