From 652c349b8c3e3631f379326b32a81560730f2d4a Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Mon, 4 Jun 2018 08:56:16 -0400 Subject: [PATCH] Merge pull request #1508 from atom/aw/toggle-editor Re-render after closing commit message editor --- lib/controllers/commit-controller.js | 33 +++++++++++++++++----------- lib/views/commit-view.js | 6 +++-- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/controllers/commit-controller.js b/lib/controllers/commit-controller.js index b0e233a0d4..87f89d7471 100644 --- a/lib/controllers/commit-controller.js +++ b/lib/controllers/commit-controller.js @@ -47,7 +47,8 @@ export default class CommitController extends React.Component { this.refCommitView = null; } - componentWillMount() { + // eslint-disable-next-line camelcase + UNSAFE_componentWillMount() { this.subscriptions.add( this.props.workspace.onDidAddTextEditor(({textEditor}) => { if (this.props.repository.isPresent() && textEditor.getPath() === this.getCommitMessagePath()) { @@ -112,7 +113,8 @@ export default class CommitController extends React.Component { ); } - componentWillReceiveProps(nextProps) { + // eslint-disable-next-line camelcase + UNSAFE_componentWillReceiveProps(nextProps) { if (!this.props.isMerging && nextProps.isMerging && !this.getCommitMessage()) { this.setCommitMessage(nextProps.mergeMessage || ''); } @@ -168,7 +170,8 @@ export default class CommitController extends React.Component { async toggleExpandedCommitMessageEditor(messageFromBox) { if (this.isCommitMessageEditorExpanded()) { if (this.commitMessageEditorIsInForeground()) { - this.closeAllOpenCommitMessageEditors(); + await this.closeAllOpenCommitMessageEditors(); + this.forceUpdate(); } else { this.activateCommitMessageEditor(); } @@ -201,16 +204,20 @@ export default class CommitController extends React.Component { } closeAllOpenCommitMessageEditors() { - this.props.workspace.getPanes().forEach(pane => { - pane.getItems().forEach(async item => { - if (item && item.getPath && item.getPath() === this.getCommitMessagePath()) { - const destroyed = await pane.destroyItem(item); - if (!destroyed) { - pane.activateItem(item); - } - } - }); - }); + return Promise.all( + this.props.workspace.getPanes().map(pane => { + return Promise.all( + pane.getItems().map(async item => { + if (item && item.getPath && item.getPath() === this.getCommitMessagePath()) { + const destroyed = await pane.destroyItem(item); + if (!destroyed) { + pane.activateItem(item); + } + } + }), + ); + }), + ); } async openCommitMessageEditor(messageFromBox) { diff --git a/lib/views/commit-view.js b/lib/views/commit-view.js index 2796f88e58..fd75fa813a 100644 --- a/lib/views/commit-view.js +++ b/lib/views/commit-view.js @@ -111,7 +111,8 @@ export default class CommitView extends React.Component { }; } - componentWillMount() { + // eslint-disable-next-line camelcase + UNSAFE_componentWillMount() { this.scheduleShowWorking(this.props); this.subscriptions = new CompositeDisposable( @@ -353,7 +354,8 @@ export default class CommitView extends React.Component { }); } - componentWillReceiveProps(nextProps) { + // eslint-disable-next-line camelcase + UNSAFE_componentWillReceiveProps(nextProps) { this.scheduleShowWorking(nextProps); }