From 44150fc529e06c6c4c169018f4d0bc6c12a7da06 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 4 Feb 2016 20:15:15 -0800 Subject: [PATCH] perf(outbox): Only trigger when send draft tasks are present --- internal_packages/feedback/lib/feedback-button.cjsx | 2 +- src/flux/action-bridge.coffee | 4 ++-- src/flux/modules/reflux-coffee.coffee | 2 +- src/flux/stores/outbox-store.es6 | 7 ++++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal_packages/feedback/lib/feedback-button.cjsx b/internal_packages/feedback/lib/feedback-button.cjsx index a9f973579..acb73ff59 100644 --- a/internal_packages/feedback/lib/feedback-button.cjsx +++ b/internal_packages/feedback/lib/feedback-button.cjsx @@ -24,6 +24,6 @@ class FeedbackButton extends React.Component _onSendFeedback: => 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 diff --git a/src/flux/action-bridge.coffee b/src/flux/action-bridge.coffee index aa611393d..217ca36fc 100644 --- a/src/flux/action-bridge.coffee +++ b/src/flux/action-bridge.coffee @@ -114,8 +114,8 @@ class ActionBridge # 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 # was sent. https://github.com/atom/electron/issues/4366 - if @ipcLastSendTime and Date.now() - @ipcLastSendTime < 100 - setTimeout(readyToUnload, 100) + if @ipcLastSendTime and Date.now() - @ipcLastSendTime < 50 + setTimeout(readyToUnload, 50) return false return true diff --git a/src/flux/modules/reflux-coffee.coffee b/src/flux/modules/reflux-coffee.coffee index 6ac4c04d9..f33e696e6 100644 --- a/src/flux/modules/reflux-coffee.coffee +++ b/src/flux/modules/reflux-coffee.coffee @@ -151,7 +151,7 @@ module.exports = setupEmitter: -> return if @_emitter @_emitter ?= new EventEmitter() - @_emitter.setMaxListeners(20) + @_emitter.setMaxListeners(50) listen: (callback, bindContext) -> if not callback diff --git a/src/flux/stores/outbox-store.es6 b/src/flux/stores/outbox-store.es6 index b48ae5b2a..4b31fdd9b 100644 --- a/src/flux/stores/outbox-store.es6 +++ b/src/flux/stores/outbox-store.es6 @@ -7,14 +7,19 @@ class OutboxStore extends NylasStore { constructor() { super(); + this._tasks = []; this.listenTo(TaskQueueStatusStore, this._populate); this._populate(); } _populate() { - this._tasks = TaskQueueStatusStore.queue().filter((task)=> { + const nextTasks = TaskQueueStatusStore.queue().filter((task)=> { return task instanceof SendDraftTask; }); + if ((this._tasks.length === 0) && (nextTasks.length === 0)) { + return; + } + this._tasks = nextTasks; this.trigger(); }