Skip to content

Commit

Permalink
[TSVB] Fields lists do not populate all the times (#85530)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp authored Dec 14, 2020
1 parent acdca75 commit 3f7f0be
Showing 1 changed file with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,26 @@ export class VisEditor extends Component {
this.props.eventEmitter.emit('dirtyStateChange', {
isDirty: false,
});

const extractedIndexPatterns = extractIndexPatterns(this.state.model);
if (!isEqual(this.state.extractedIndexPatterns, extractedIndexPatterns)) {
this.abortableFetchFields(extractedIndexPatterns).then((visFields) => {
this.setState({
visFields,
extractedIndexPatterns,
});
});
}
}, VIS_STATE_DEBOUNCE_DELAY);

debouncedFetchFields = debounce(
(extractedIndexPatterns) => {
if (this.abortControllerFetchFields) {
this.abortControllerFetchFields.abort();
}
this.abortControllerFetchFields = new AbortController();
abortableFetchFields = (extractedIndexPatterns) => {
if (this.abortControllerFetchFields) {
this.abortControllerFetchFields.abort();
}
this.abortControllerFetchFields = new AbortController();

return fetchFields(extractedIndexPatterns, this.abortControllerFetchFields.signal);
},
VIS_STATE_DEBOUNCE_DELAY,
{ leading: true }
);
return fetchFields(extractedIndexPatterns, this.abortControllerFetchFields.signal);
};

handleChange = (partialModel) => {
if (isEmpty(partialModel)) {
Expand All @@ -105,16 +111,6 @@ export class VisEditor extends Component {
dirty = false;
}

const extractedIndexPatterns = extractIndexPatterns(nextModel);
if (!isEqual(this.state.extractedIndexPatterns, extractedIndexPatterns)) {
this.debouncedFetchFields(extractedIndexPatterns).then((visFields) =>
this.setState({
visFields,
extractedIndexPatterns,
})
);
}

this.setState({
dirty,
model: nextModel,
Expand Down

0 comments on commit 3f7f0be

Please sign in to comment.