Add AutoUpdateManager.prototype.onUpdateError

This commit is contained in:
Antonio Scandurra 2016-03-30 15:05:57 +02:00
parent 80fc98a6ca
commit 2d5e697016
4 changed files with 26 additions and 0 deletions

View File

@ -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', () => {

View File

@ -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...)

View File

@ -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
}

View File

@ -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