@@ -13,7 +13,7 @@ autoUpdater.logger = electronLog;
1313
1414autoUpdater . autoDownload = false ;
1515
16- const setAutoUpdater = ( ) => {
16+ const setAutoUpdater = mainWindow => ( ) => {
1717 const isNotificationsSupported = Notification . isSupported ( ) ;
1818 electronLog . debug ( 'isNotificationsSupported' , isNotificationsSupported ) ;
1919
@@ -51,6 +51,14 @@ const setAutoUpdater = () => {
5151 }
5252 } ) ;
5353
54+ autoUpdater . on ( 'download-progress' , ( progressObj ) => {
55+ electronLog . debug ( 'progressObj' , JSON . stringify ( progressObj ) ) ;
56+ const percent = progressObj && progressObj . percent ;
57+ if ( typeof percent === 'number' ) {
58+ mainWindow . setProgressBar ( percent / 100 ) ;
59+ }
60+ } ) ;
61+
5462 autoUpdater . on ( 'update-downloaded' , ( ) => {
5563 // For Windows: If update-downloaded notification is created before update-available is closed,
5664 // click event does not work. Thats why we add setTimeout 3000
@@ -84,25 +92,6 @@ const setAutoUpdater = () => {
8492 } , 5000 )
8593 } ) ;
8694
87- // autoUpdater.on('download-progress', (progressObj: any) => {
88- // let logMessage: string = 'Downloaded ';
89- // const percent = progressObj.percent;
90- // TYPE NUMBER
91- // electronLog.debug('typeof percent', typeof percent);
92- // electronLog.debug('percent', percent);
93- // if (typeof percent === 'string' || percent instanceof String) {
94- // logMessage += percent.substr(0, 5);
95- // } else if (typeof percent === 'number') {
96- // logMessage += Math.floor(percent);
97- // } else {
98- // logMessage += percent;
99- // }
100- // logMessage += '%';
101- // // let log_message = 'Download speed: ' + progressObj.bytesPerSecond;
102- // // log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
103- // // log_message = log_message + ' (' + progressObj.transferred + '/' + progressObj.total + ')';
104- // sendNotificationToWindow(logMessage);
105- // });
10695} ;
10796
108- exports . runAutoUpdater = ( ) => setTimeout ( setAutoUpdater , START_DELAY ) ;
97+ exports . runAutoUpdater = ( mainWindow ) => setTimeout ( setAutoUpdater ( mainWindow ) , START_DELAY ) ;
0 commit comments