From 5ac53aa3b1dfaa1ed0f455e1ace73f08e4e8111c Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 8 May 2019 16:31:54 -0400 Subject: [PATCH] Only force refresh header editor when changing body type (Closes #931) --- packages/insomnia-app/app/ui/components/request-pane.js | 3 +++ packages/insomnia-app/app/ui/components/wrapper.js | 3 +++ packages/insomnia-app/app/ui/containers/app.js | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/insomnia-app/app/ui/components/request-pane.js b/packages/insomnia-app/app/ui/components/request-pane.js index 339e554ddf..c5acc71146 100644 --- a/packages/insomnia-app/app/ui/components/request-pane.js +++ b/packages/insomnia-app/app/ui/components/request-pane.js @@ -60,6 +60,7 @@ type Props = { isVariableUncovered: boolean, environmentId: string, forceRefreshCounter: number, + headerEditorKey: string, // Optional request: ?Request, @@ -165,6 +166,7 @@ class RequestPane extends React.PureComponent { updateSettingsShowPasswords, updateRequestMethod, updateRequestUrl, + headerEditorKey, } = this.props; const paneClasses = 'request-pane theme--pane pane'; @@ -387,6 +389,7 @@ class RequestPane extends React.PureComponent { , isVariableUncovered: boolean, + headerEditorKey: string, vcs: VCS | null, syncItems: Array, @@ -429,6 +430,7 @@ class Wrapper extends React.PureComponent { unseenWorkspaces, isVariableUncovered, vcs, + headerEditorKey, } = this.props; const realSidebarWidth = sidebarHidden ? 0 : sidebarWidth; @@ -731,6 +733,7 @@ class Wrapper extends React.PureComponent { handleSendAndDownload={this._handleSendAndDownloadRequestWithActiveEnvironment} nunjucksPowerUserMode={settings.nunjucksPowerUserMode} isVariableUncovered={isVariableUncovered} + headerEditorKey={headerEditorKey} /> diff --git a/packages/insomnia-app/app/ui/containers/app.js b/packages/insomnia-app/app/ui/containers/app.js index 197deb9018..e3aa379c3e 100644 --- a/packages/insomnia-app/app/ui/containers/app.js +++ b/packages/insomnia-app/app/ui/containers/app.js @@ -90,6 +90,7 @@ class App extends PureComponent { isVariableUncovered: props.isVariableUncovered || false, vcs: null, forceRefreshCounter: 0, + forceRefreshHeaderCounter: 0, }; this._isMigratingChildren = false; @@ -508,7 +509,9 @@ class App extends PureComponent { // Force it to update, because other editor components (header editor) // needs to change. Need to wait a delay so the next render can finish - setTimeout(this._wrapper._forceRequestPaneRefresh, 300); + setTimeout(() => { + this.setState({ forceRefreshHeaderCounter: this.state.forceRefreshHeaderCounter + 1 }); + }, 500); return newRequest; } @@ -1051,6 +1054,7 @@ class App extends PureComponent { isVariableUncovered, vcs, forceRefreshCounter, + forceRefreshHeaderCounter, } = this.state; const uniquenessKey = `${forceRefreshCounter}::${activeWorkspace._id}`; @@ -1103,6 +1107,7 @@ class App extends PureComponent { handleUpdateRequestMimeType={this._handleUpdateRequestMimeType} handleShowExportRequestsModal={this._handleShowExportRequestsModal} isVariableUncovered={isVariableUncovered} + headerEditorKey={forceRefreshHeaderCounter + ''} vcs={vcs} />