mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Fix env editor debounce so no longer lose changes
This commit is contained in:
parent
c83c58b65a
commit
b27515edb6
@ -36,11 +36,12 @@ class EnvironmentEditor extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.props.didChange();
|
||||||
|
|
||||||
|
// Call this last in case component unmounted
|
||||||
if (this.state.error !== error || this.state.warning !== warning) {
|
if (this.state.error !== error || this.state.warning !== warning) {
|
||||||
this.setState({error, warning});
|
this.setState({error, warning});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.didChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_setEditorRef (n) {
|
_setEditorRef (n) {
|
||||||
@ -80,7 +81,6 @@ class EnvironmentEditor extends PureComponent {
|
|||||||
lineWrapping={lineWrapping}
|
lineWrapping={lineWrapping}
|
||||||
keyMap={editorKeyMap}
|
keyMap={editorKeyMap}
|
||||||
onChange={this._handleChange}
|
onChange={this._handleChange}
|
||||||
debounceMillis={DEBOUNCE_MILLIS * 6}
|
|
||||||
defaultValue={JSON.stringify(environment)}
|
defaultValue={JSON.stringify(environment)}
|
||||||
nunjucksPowerUserMode={nunjucksPowerUserMode}
|
nunjucksPowerUserMode={nunjucksPowerUserMode}
|
||||||
render={render}
|
render={render}
|
||||||
|
@ -41,6 +41,7 @@ type State = {
|
|||||||
class WorkspaceEnvironmentsEditModal extends React.PureComponent<Props, State> {
|
class WorkspaceEnvironmentsEditModal extends React.PureComponent<Props, State> {
|
||||||
environmentEditorRef: EnvironmentEditor | null;
|
environmentEditorRef: EnvironmentEditor | null;
|
||||||
colorChangeTimeout: any;
|
colorChangeTimeout: any;
|
||||||
|
saveTimeout: any;
|
||||||
modal: Modal;
|
modal: Modal;
|
||||||
|
|
||||||
constructor (props: Props) {
|
constructor (props: Props) {
|
||||||
@ -189,13 +190,13 @@ class WorkspaceEnvironmentsEditModal extends React.PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_didChange () {
|
_didChange () {
|
||||||
const isValid = this.environmentEditorRef ? this.environmentEditorRef.isValid() : false;
|
this._saveChanges();
|
||||||
|
|
||||||
|
// Call this last in case component unmounted
|
||||||
|
const isValid = this.environmentEditorRef ? this.environmentEditorRef.isValid() : false;
|
||||||
if (this.state.isValid !== isValid) {
|
if (this.state.isValid !== isValid) {
|
||||||
this.setState({isValid});
|
this.setState({isValid});
|
||||||
}
|
}
|
||||||
|
|
||||||
this._saveChanges();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_getActiveEnvironment (): Environment | null {
|
_getActiveEnvironment (): Environment | null {
|
||||||
@ -247,7 +248,10 @@ class WorkspaceEnvironmentsEditModal extends React.PureComponent<Props, State> {
|
|||||||
const activeEnvironment = this._getActiveEnvironment();
|
const activeEnvironment = this._getActiveEnvironment();
|
||||||
|
|
||||||
if (activeEnvironment) {
|
if (activeEnvironment) {
|
||||||
models.environment.update(activeEnvironment, {data});
|
clearTimeout(this.saveTimeout);
|
||||||
|
this.saveTimeout = setTimeout(() => {
|
||||||
|
models.environment.update(activeEnvironment, {data});
|
||||||
|
}, DEBOUNCE_MILLIS * 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user