mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +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) {
|
||||
this.setState({error, warning});
|
||||
}
|
||||
|
||||
this.props.didChange();
|
||||
}
|
||||
|
||||
_setEditorRef (n) {
|
||||
@ -80,7 +81,6 @@ class EnvironmentEditor extends PureComponent {
|
||||
lineWrapping={lineWrapping}
|
||||
keyMap={editorKeyMap}
|
||||
onChange={this._handleChange}
|
||||
debounceMillis={DEBOUNCE_MILLIS * 6}
|
||||
defaultValue={JSON.stringify(environment)}
|
||||
nunjucksPowerUserMode={nunjucksPowerUserMode}
|
||||
render={render}
|
||||
|
@ -41,6 +41,7 @@ type State = {
|
||||
class WorkspaceEnvironmentsEditModal extends React.PureComponent<Props, State> {
|
||||
environmentEditorRef: EnvironmentEditor | null;
|
||||
colorChangeTimeout: any;
|
||||
saveTimeout: any;
|
||||
modal: Modal;
|
||||
|
||||
constructor (props: Props) {
|
||||
@ -189,13 +190,13 @@ class WorkspaceEnvironmentsEditModal extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
_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) {
|
||||
this.setState({isValid});
|
||||
}
|
||||
|
||||
this._saveChanges();
|
||||
}
|
||||
|
||||
_getActiveEnvironment (): Environment | null {
|
||||
@ -247,7 +248,10 @@ class WorkspaceEnvironmentsEditModal extends React.PureComponent<Props, State> {
|
||||
const activeEnvironment = this._getActiveEnvironment();
|
||||
|
||||
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