4

I'm developing my app with electron and I'm using electron-updater to show a window that asks to the user if he wants download a new app version or not. I've tried to show in a window a progress bar during the downloading like this. progress-bar

I've tried to use progress-bar but if I install it, the electron-updater stop working. Now I can see the progress only in dev mode into the electron shell.

autoUpdater.on('download-progress', (progressObj) => {
    let log_message = "Scaricamento aggiornamenti in corso...  \n";
    log_message = log_message +  "Velocita\' scaricamento: " + 
        progressObj.bytesPerSecond;
    log_message = log_message + ' - Scaricati ' + progressObj.percent + '%';
    log_message = log_message + ' (' + progressObj.transferred + "/" + 
        progressObj.total + ')';
    log.log('info', log_message);
})

Thank you in advance

pushkin
  • 9,575
  • 15
  • 51
  • 95
Jean
  • 453
  • 4
  • 16

1 Answers1

2

(I'm not 100% clear on what you are asking and i don't have enough reputation to add a comment...so i'll do my best)

I assume that autoUpdater is in the main process, not in a renderer. So, the first thing you need to do is get the data from the progress update to the correct renderer. You can do this using electron's ipcMain and ipcRenderer modules.

Once you have the data in the renderer process you need to get it to the progress bar. If you are using redux, you can call your store's dispatch(), passing a downloadProgress action to it.

In my app, which uses redux, I create a DownloadProgress action in the main process and send it over IPC to the renderer. I'd recommend doing the same since you'll probably want to pass DownloadCancelled and DownloadComplete actions too.

If this is not helpful, please clarify the following:

  • please add the code that doesn't work your question -- this would help understand more precisely what you are trying to do
  • is autoUpdate running in the main process, or in a renderer
  • which progress bar implementation you are using (an npm package?) and how will you send data to it (directly or through a store?)
Troy Gonsalves
  • 171
  • 2
  • 7