Stop send interval on request change (#136)

This commit is contained in:
Gregory Schier 2017-04-10 13:07:33 -07:00 committed by GitHub
parent 59e396e3f3
commit 2aabe29289
2 changed files with 19 additions and 3 deletions

View File

@ -198,7 +198,7 @@ class RequestPane extends PureComponent {
<section className="pane request-pane"> <section className="pane request-pane">
<header className="pane__header"> <header className="pane__header">
<RequestUrlBar <RequestUrlBar
key={uniqueKey} uniquenessKey={uniqueKey}
method={request.method} method={request.method}
onMethodChange={updateRequestMethod} onMethodChange={updateRequestMethod}
onUrlChange={this._handleUpdateRequestUrl} onUrlChange={this._handleUpdateRequestUrl}
@ -210,6 +210,7 @@ class RequestPane extends PureComponent {
handleRender={handleRender} handleRender={handleRender}
handleGetRenderContext={handleGetRenderContext} handleGetRenderContext={handleGetRenderContext}
url={request.url} url={request.url}
requestId={request._id}
/> />
</header> </header>
<Tabs className="pane__body" forceRenderTabPanel> <Tabs className="pane__body" forceRenderTabPanel>

View File

@ -180,6 +180,11 @@ class RequestUrlBar extends PureComponent {
} }
} }
_handleResetTimeouts () {
this._handleStopTimeout();
this._handleStopInterval();
}
_handleClickSend (e) { _handleClickSend (e) {
const metaPressed = isMac() ? e.metaKey : e.ctrlKey; const metaPressed = isMac() ? e.metaKey : e.ctrlKey;
@ -202,6 +207,12 @@ class RequestUrlBar extends PureComponent {
document.body.removeEventListener('keydown', this._handleKeyDown); document.body.removeEventListener('keydown', this._handleKeyDown);
} }
componentWillReceiveProps (nextProps) {
if (nextProps.requestId !== this.props.requestId) {
this._handleResetTimeouts();
}
}
renderSendButton () { renderSendButton () {
const {currentInterval, currentTimeout, downloadPath} = this.state; const {currentInterval, currentTimeout, downloadPath} = this.state;
@ -278,7 +289,8 @@ class RequestUrlBar extends PureComponent {
method, method,
handleRender, handleRender,
handleGetRenderContext, handleGetRenderContext,
handleAutocompleteUrls handleAutocompleteUrls,
uniquenessKey
} = this.props; } = this.props;
return ( return (
@ -288,6 +300,7 @@ class RequestUrlBar extends PureComponent {
</MethodDropdown> </MethodDropdown>
<form onSubmit={this._handleFormSubmit}> <form onSubmit={this._handleFormSubmit}>
<OneLineEditor <OneLineEditor
key={uniquenessKey}
ref={this._setInputRef} ref={this._setInputRef}
onPaste={this._handleUrlPaste} onPaste={this._handleUrlPaste}
forceEditor forceEditor
@ -316,7 +329,9 @@ RequestUrlBar.propTypes = {
onMethodChange: PropTypes.func.isRequired, onMethodChange: PropTypes.func.isRequired,
handleGenerateCode: PropTypes.func.isRequired, handleGenerateCode: PropTypes.func.isRequired,
url: PropTypes.string.isRequired, url: PropTypes.string.isRequired,
method: PropTypes.string.isRequired method: PropTypes.string.isRequired,
requestId: PropTypes.string.isRequired,
uniquenessKey: PropTypes.string.isRequired
}; };
export default RequestUrlBar; export default RequestUrlBar;