diff --git a/spec/auto-update-manager-spec.js b/spec/auto-update-manager-spec.js index 6f7dbbb1a..12fe0c825 100644 --- a/spec/auto-update-manager-spec.js +++ b/spec/auto-update-manager-spec.js @@ -64,6 +64,16 @@ describe('AutoUpdateManager (renderer)', () => { }) }) + describe('::onUpdateError', () => { + it('subscribes to "update-error" event', () => { + const spy = jasmine.createSpy('spy') + autoUpdateManager.onUpdateError(spy) + electronAutoUpdater.emit('error', {}, 'an error') + waitsFor(() => spy.callCount === 1) + runs(() => expect(spy).toHaveBeenCalledWith('an error')) + }) + }) + describe('::platformSupportsUpdates', () => { let state, releaseChannel it('returns true on OS X and Windows when in stable', () => { diff --git a/src/application-delegate.coffee b/src/application-delegate.coffee index 3aff9e457..ecefc4b67 100644 --- a/src/application-delegate.coffee +++ b/src/application-delegate.coffee @@ -211,6 +211,14 @@ class ApplicationDelegate new Disposable -> ipcRenderer.removeListener('message', outerCallback) + onUpdateError: (callback) -> + outerCallback = (event, message, detail) -> + callback(detail) if message is 'update-error' + + ipcRenderer.on('message', outerCallback) + new Disposable -> + ipcRenderer.removeListener('message', outerCallback) + onApplicationMenuCommand: (callback) -> outerCallback = (event, args...) -> callback(args...) diff --git a/src/auto-update-manager.js b/src/auto-update-manager.js index 62cc03f85..07e0db4be 100644 --- a/src/auto-update-manager.js +++ b/src/auto-update-manager.js @@ -20,6 +20,9 @@ export default class AutoUpdateManager { }), applicationDelegate.onUpdateNotAvailable(() => { this.emitter.emit('update-not-available') + }), + applicationDelegate.onUpdateError((message) => { + this.emitter.emit('update-error', message) }) ) } @@ -67,6 +70,10 @@ export default class AutoUpdateManager { return this.emitter.on('update-not-available', callback) } + onUpdateError (callback) { + return this.emitter.on('update-error', callback) + } + getPlatform () { return process.platform } diff --git a/src/browser/auto-update-manager.coffee b/src/browser/auto-update-manager.coffee index c8c57cb01..391d1f0b4 100644 --- a/src/browser/auto-update-manager.coffee +++ b/src/browser/auto-update-manager.coffee @@ -33,6 +33,7 @@ class AutoUpdateManager autoUpdater.on 'error', (event, message) => @setState(ErrorState) + @emitWindowEvent('update-error', message) console.error "Error Downloading Update: #{message}" autoUpdater.setFeedURL @feedUrl