From d66f0fedbd0f6d42e0addc77ceec1b9291759d98 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 15 Jul 2015 13:15:55 -0700 Subject: [PATCH] fix(*): A few small bug fixes, immediate refres on renderer process crash Summary: fix(drafts): One failed promsie breaks ChangeSet.commit forever Move the quoted text button so it's beneath the quoted text not at the bottom of the composer, also fixes problem with it overlapping content slightly When the main window crashes, reload it immediately Test Plan: Run tests Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1742 --- .../composer/lib/composer-view.cjsx | 2 +- .../composer/stylesheets/composer.less | 7 ++----- src/browser/atom-window.coffee | 21 +++++++++++-------- ...nce methods to insert plaintext into draft | 10 --------- src/flux/stores/draft-store-proxy.coffee | 10 ++++----- src/flux/stores/draft-store.coffee | 3 +-- 6 files changed, 21 insertions(+), 32 deletions(-) delete mode 100644 src/convenience methods to insert plaintext into draft diff --git a/internal_packages/composer/lib/composer-view.cjsx b/internal_packages/composer/lib/composer-view.cjsx index 5edd61c31..c569f4089 100644 --- a/internal_packages/composer/lib/composer-view.cjsx +++ b/internal_packages/composer/lib/composer-view.cjsx @@ -571,7 +571,7 @@ class ComposerView extends React.Component # There can be a delay between when the send request gets initiated # by a user and when the draft is prepared on on the TaskQueue, which # is how we detect that the draft is sending. - @setState isSending: true + @setState(isSending: true) Actions.sendDraft(@props.localId) diff --git a/internal_packages/composer/stylesheets/composer.less b/internal_packages/composer/stylesheets/composer.less index 0c0987c98..ec8da1d27 100644 --- a/internal_packages/composer/stylesheets/composer.less +++ b/internal_packages/composer/stylesheets/composer.less @@ -150,10 +150,8 @@ margin: 0 8px; .quoted-text-control { - position: absolute; - bottom: 10px; - left: 15px; - margin: 0; + margin: @spacing-standard; + margin-top:0; } div[contenteditable] { @@ -166,7 +164,6 @@ margin-bottom: 30px; } .contenteditable-container { - display: flex; width: 100%; position: relative; } diff --git a/src/browser/atom-window.coffee b/src/browser/atom-window.coffee index 6d767009c..e1f606533 100644 --- a/src/browser/atom-window.coffee +++ b/src/browser/atom-window.coffee @@ -182,15 +182,18 @@ class AtomWindow @browserWindow.webContents.on 'crashed', => global.application.exit(100) if @exitWhenDone - dialog = require 'dialog' - chosen = dialog.showMessageBox @browserWindow, - type: 'warning' - buttons: ['Close Window', 'Reload', 'Keep It Open'] - message: 'Nylas Mail has crashed' - detail: 'Please report this issue to us at support@nylas.com.' - switch chosen - when 0 then @browserWindow.destroy() - when 1 then @browserWindow.restart() + if @mainWindow + @browserWindow.restart() + else + dialog = require 'dialog' + chosen = dialog.showMessageBox @browserWindow, + type: 'warning' + buttons: ['Close Window', 'Reload', 'Keep It Open'] + message: 'Nylas Mail has crashed' + detail: 'Please report this issue to us at support@nylas.com.' + switch chosen + when 0 then @browserWindow.destroy() + when 1 then @browserWindow.restart() @setupContextMenu() diff --git a/src/convenience methods to insert plaintext into draft b/src/convenience methods to insert plaintext into draft deleted file mode 100644 index f34a7e166..000000000 --- a/src/convenience methods to insert plaintext into draft +++ /dev/null @@ -1,10 +0,0 @@ -convenience methods to insert plaintext into draft -documentation of roles -documentation of DraftStore extensions - -RetinaImg with bad image name throws exception - -when third-party react components throw exceptions, it breaks everything - -when typing team @ nylas, undefined react component in dropdown list? - diff --git a/src/flux/stores/draft-store-proxy.coffee b/src/flux/stores/draft-store-proxy.coffee index 5c821a468..a35397bcd 100644 --- a/src/flux/stores/draft-store-proxy.coffee +++ b/src/flux/stores/draft-store-proxy.coffee @@ -42,14 +42,15 @@ class DraftChangeSet @_timer = setTimeout(@commit, 5000) commit: => - @_commitChain = @_commitChain.then => + @_commitChain = @_commitChain.finally => if Object.keys(@_pending).length is 0 return Promise.resolve(true) DatabaseStore = require './database-store' return DatabaseStore.findByLocalId(Message, @localId).then (draft) => if not draft - throw new Error("Tried to commit a draft that had already been removed from the database. DraftId: #{@localId}") + throw new Error("DraftChangeSet.commit: Assertion failure. Draft #{@localId} has already been removed from the database.") + @_saving = @_pending @_pending = {} draft = @applyToModel(draft) @@ -101,9 +102,8 @@ class DraftStoreProxy @_draftPromise = Promise.resolve(@) @prepare().catch (error) -> - console.error(error) console.error(error.stack) - throw new Error("DraftStoreProxy prepare() failed with error #{error.toString()}.") + throw new Error("DraftStoreProxy prepare() failed: #{error.toString()}.") # Public: Returns the draft object with the latest changes applied. # @@ -123,7 +123,7 @@ class DraftStoreProxy DatabaseStore = require './database-store' DatabaseStore.findByLocalId(Message, @draftLocalId).then (draft) => if not draft - reject(new Error("Can't prepare. Draft is null")) + reject(new Error("Assertion Failure: Draft #{@draftLocalId} not found.")) else @_setDraft(draft) resolve(@) diff --git a/src/flux/stores/draft-store.coffee b/src/flux/stores/draft-store.coffee index 8eb83a998..5e5a0cbb4 100644 --- a/src/flux/stores/draft-store.coffee +++ b/src/flux/stores/draft-store.coffee @@ -401,8 +401,7 @@ class DraftStore # Immediately save any pending changes so we don't save after sending session.changes.commit().then => - - task = new SendDraftTask draftLocalId, {fromPopout: @_isPopout()} + task = new SendDraftTask(draftLocalId, {fromPopout: @_isPopout()}) if atom.isMainWindow() # We need to wait for performLocal to finish before `trigger`ing.