mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Add applicationDelegate.getAutoUpdateManagerErrorMessage()
Sometimes, the error event gets emitted before the renderer process has the chance to subscribe. Therefore, we expose an `autoUpdateManager.getErrorMessage()` in the browser process, so that we don’t lose that information.
This commit is contained in:
parent
e8e2370ed1
commit
4d4ee6bf3b
@ -70,7 +70,6 @@ describe('AutoUpdateManager (renderer)', () => {
|
||||
autoUpdateManager.onUpdateError(spy)
|
||||
electronAutoUpdater.emit('error', {}, 'an error')
|
||||
waitsFor(() => spy.callCount === 1)
|
||||
runs(() => expect(spy).toHaveBeenCalledWith('an error'))
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -252,3 +252,6 @@ class ApplicationDelegate
|
||||
|
||||
getAutoUpdateManagerState: ->
|
||||
ipcRenderer.sendSync('get-auto-update-manager-state')
|
||||
|
||||
getAutoUpdateManagerErrorMessage: ->
|
||||
ipcRenderer.sendSync('get-auto-update-manager-error')
|
||||
|
@ -21,9 +21,8 @@ export default class AutoUpdateManager {
|
||||
applicationDelegate.onUpdateNotAvailable(() => {
|
||||
this.emitter.emit('update-not-available')
|
||||
}),
|
||||
applicationDelegate.onUpdateError((message) => {
|
||||
console.error(message)
|
||||
this.emitter.emit('update-error', message)
|
||||
applicationDelegate.onUpdateError(() => {
|
||||
this.emitter.emit('update-error')
|
||||
})
|
||||
)
|
||||
}
|
||||
@ -45,6 +44,10 @@ export default class AutoUpdateManager {
|
||||
return this.applicationDelegate.getAutoUpdateManagerState()
|
||||
}
|
||||
|
||||
getErrorMessage () {
|
||||
return this.applicationDelegate.getAutoUpdateManagerErrorMessage()
|
||||
}
|
||||
|
||||
platformSupportsUpdates () {
|
||||
return atom.getReleaseChannel() !== 'dev' && this.getState() !== 'unsupported'
|
||||
}
|
||||
|
@ -311,6 +311,9 @@ class AtomApplication
|
||||
ipcMain.on 'get-auto-update-manager-state', (event) =>
|
||||
event.returnValue = @autoUpdateManager.getState()
|
||||
|
||||
ipcMain.on 'get-auto-update-manager-error', (event) =>
|
||||
event.returnValue = @autoUpdateManager.getErrorMessage()
|
||||
|
||||
ipcMain.on 'execute-javascript-in-dev-tools', (event, code) ->
|
||||
event.sender.devToolsWebContents?.executeJavaScript(code)
|
||||
|
||||
|
@ -32,8 +32,8 @@ class AutoUpdateManager
|
||||
{autoUpdater} = require 'electron'
|
||||
|
||||
autoUpdater.on 'error', (event, message) =>
|
||||
@setState(ErrorState)
|
||||
@emitWindowEvent('update-error', message)
|
||||
@setState(ErrorState, message)
|
||||
@emitWindowEvent('update-error')
|
||||
console.error "Error Downloading Update: #{message}"
|
||||
|
||||
autoUpdater.setFeedURL @feedUrl
|
||||
@ -83,14 +83,18 @@ class AutoUpdateManager
|
||||
atomWindow.sendMessage(eventName, payload)
|
||||
return
|
||||
|
||||
setState: (state) ->
|
||||
setState: (state, errorMessage) ->
|
||||
return if @state is state
|
||||
@state = state
|
||||
@errorMessage = errorMessage
|
||||
@emit 'state-changed', @state
|
||||
|
||||
getState: ->
|
||||
@state
|
||||
|
||||
getErrorMessage: ->
|
||||
@errorMessage
|
||||
|
||||
scheduleUpdateCheck: ->
|
||||
# Only schedule update check periodically if running in release version and
|
||||
# and there is no existing scheduled update check.
|
||||
|
Loading…
Reference in New Issue
Block a user