Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
feat(electron): show native progress when extracting/verifying assets
Browse files Browse the repository at this point in the history
  • Loading branch information
devinus committed Aug 27, 2018
1 parent eaf30f0 commit f568456
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ember-electron/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ const { startDaemon } = require('./daemon');
const { ipcMain } = electron;

const downloadStart = ({ sender }, url) => {
const window = sender.getOwnerBrowserWindow();
const onProgress = debounceFn((progress = 0) => {
if (!window.isDestroyed()) {
window.setProgressBar(progress);
}

if (!sender.isDestroyed()) {
sender.send('download-progress', progress);
}
Expand All @@ -23,12 +28,20 @@ const downloadStart = ({ sender }, url) => {

return downloadAsset(sender, url, onStarted, onProgress)
.then(() => {
if (!window.isDestroyed()) {
window.setProgressBar(-1);
}

if (!sender.isDestroyed()) {
sender.send('download-done');
}
})
.catch((err) => {
log.error('Error downloading asset:', err);
if (!window.isDestroyed()) {
window.setProgressBar(-1);
}

if (!sender.isDestroyed()) {
sender.send('download-error', err);
}
Expand Down

0 comments on commit f568456

Please sign in to comment.