perf(outbox): Only trigger when send draft tasks are present

This commit is contained in:
Ben Gotow 2016-02-04 20:15:15 -08:00
parent bbc4b792c9
commit 835e7fe9c8
4 changed files with 10 additions and 5 deletions

View file

@ -24,6 +24,6 @@ class FeedbackButton extends React.Component
_onSendFeedback: => _onSendFeedback: =>
return if NylasEnv.inSpecMode() return if NylasEnv.inSpecMode()
require('electron').shell.openExternal('http://support.nylas.com/') require('electron').shell.openExternal('https://nylas.zendesk.com/hc/en-us/sections/203638587-N1')
module.exports = FeedbackButton module.exports = FeedbackButton

View file

@ -114,8 +114,8 @@ class ActionBridge
# Electron won't actually send the message. To work around this, we wait an # Electron won't actually send the message. To work around this, we wait an
# arbitrary amount of time before closing the window after the last IPC event # arbitrary amount of time before closing the window after the last IPC event
# was sent. https://github.com/atom/electron/issues/4366 # was sent. https://github.com/atom/electron/issues/4366
if @ipcLastSendTime and Date.now() - @ipcLastSendTime < 100 if @ipcLastSendTime and Date.now() - @ipcLastSendTime < 50
setTimeout(readyToUnload, 100) setTimeout(readyToUnload, 50)
return false return false
return true return true

View file

@ -151,7 +151,7 @@ module.exports =
setupEmitter: -> setupEmitter: ->
return if @_emitter return if @_emitter
@_emitter ?= new EventEmitter() @_emitter ?= new EventEmitter()
@_emitter.setMaxListeners(20) @_emitter.setMaxListeners(50)
listen: (callback, bindContext) -> listen: (callback, bindContext) ->
if not callback if not callback

View file

@ -7,14 +7,19 @@ class OutboxStore extends NylasStore {
constructor() { constructor() {
super(); super();
this._tasks = [];
this.listenTo(TaskQueueStatusStore, this._populate); this.listenTo(TaskQueueStatusStore, this._populate);
this._populate(); this._populate();
} }
_populate() { _populate() {
this._tasks = TaskQueueStatusStore.queue().filter((task)=> { const nextTasks = TaskQueueStatusStore.queue().filter((task)=> {
return task instanceof SendDraftTask; return task instanceof SendDraftTask;
}); });
if ((this._tasks.length === 0) && (nextTasks.length === 0)) {
return;
}
this._tasks = nextTasks;
this.trigger(); this.trigger();
} }