From 59af9d61a0bb33a7320a180329373db0a5162937 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 10 Sep 2015 11:16:42 -0700 Subject: [PATCH] fix(composer): Always open new composer windows from the main window so that AccountStore.current() is correct Fixes T3479 --- src/atom.coffee | 2 +- src/browser/application.coffee | 1 + src/flux/stores/draft-store.coffee | 5 ++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index 919b2a859..1a50645a1 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -202,7 +202,7 @@ class Atom extends Model # up into the browser process. This prevents us from needing this crap, which has to be # updated every time a new application: command is added: # https://github.com/atom/atom/blob/master/src/workspace-element.coffee#L119 - if event.binding.command.indexOf('application:') is 0 and event.binding.selector is "body" + if event.binding.command.indexOf('application:') is 0 and event.binding.selector.indexOf("body") is 0 ipc.send('command', event.binding.command) unless @inSpecMode() diff --git a/src/browser/application.coffee b/src/browser/application.coffee index 306eb80eb..0bb0e1085 100644 --- a/src/browser/application.coffee +++ b/src/browser/application.coffee @@ -254,6 +254,7 @@ class Application atomWindow ?= @windowManager.focusedWindow() atomWindow?.browserWindow.inspectElement(x, y) + @on 'application:new-message', => @windowManager.sendToMainWindow('new-message') @on 'application:send-feedback', => @windowManager.sendToMainWindow('send-feedback') @on 'application:open-preferences', => @windowManager.sendToMainWindow('open-preferences') @on 'application:show-main-window', => @openWindowsForTokenState() diff --git a/src/flux/stores/draft-store.coffee b/src/flux/stores/draft-store.coffee index e8ea06d45..574ca35b8 100644 --- a/src/flux/stores/draft-store.coffee +++ b/src/flux/stores/draft-store.coffee @@ -55,8 +55,8 @@ class DraftStore @listenTo Actions.composeNewBlankDraft, @_onPopoutBlankDraft @listenTo Actions.draftSendingFailed, @_onDraftSendingFailed - atom.commands.add 'body', - 'application:new-message': => @_onPopoutBlankDraft() + if atom.isMainWindow() + ipc.on 'new-message', => @_onPopoutBlankDraft() # Remember that these two actions only fire in the current window and # are picked up by the instance of the DraftStore in the current @@ -92,7 +92,6 @@ class DraftStore ipc.on 'mailto', @_onHandleMailtoLink - ipc.on 'inline-styles-result', @_onInlineStylesResult # TODO: Doesn't work if we do window.addEventListener, but this is