mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Add AutoUpdateManager.prototype.onUpdateError
This commit is contained in:
parent
80fc98a6ca
commit
2d5e697016
@ -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', () => {
|
||||
|
@ -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...)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user