Skip to content

Commit

Permalink
Fix updateChart() missing filter expressions map
Browse files Browse the repository at this point in the history
When a filter is applied, updateChart() should not be called without the
filter expression map.

Replace method updateSearchFilters(), which computes the filter
expression map and calls updateChart with the map if it applies, with
method filterExpressionsMap() which only computes the map. This method
is now always called to compute the parameter to be passed in
updateChart().

Method _debouncedUpdateSearch() is removed, as _debouncedUpdateChart()
can always be used instead.

Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
  • Loading branch information
PatrickTasse committed Sep 24, 2024
1 parent 98da981 commit a5ddfb9
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
this.doHandleContextMenuContributed(payload);
private pendingSelection: TimeGraphEntry | undefined;

private _debouncedUpdateSearch = debounce(() => this.updateSearchFilters(), 500);
private _debouncedUpdateChart = debounce(() => {
this.chartLayer.updateChart();
this.chartLayer.updateChart(this.filterExpressionsMap());
}, 500);

constructor(props: TimegraphOutputProps) {
Expand Down Expand Up @@ -332,7 +331,7 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
prevProps.markerSetId !== this.props.markerSetId
) {
this.selectedMarkerCategories = this.props.markerCategories;
this.chartLayer.updateChart();
this.chartLayer.updateChart(this.filterExpressionsMap());
this.markersChartLayer.updateChart();
this.rangeEventsLayer.update();
this.arrowLayer.update();
Expand All @@ -357,7 +356,7 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
!isEqual(this.state.searchString, prevState.searchString) ||
!isEqual(this.state.filters, prevState.filters)
) {
this._debouncedUpdateSearch();
this._debouncedUpdateChart();
}
if (!isEqual(this.state.multiSelectedRows, prevState.multiSelectedRows)) {
const signalPayload: RowSelectionsChangedSignalPayload = new RowSelectionsChangedSignalPayload(
Expand Down Expand Up @@ -872,7 +871,7 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
);
};

private updateSearchFilters = () => {
private filterExpressionsMap() {
const filterExpressionsMap: { [key: number]: string[] } = {};
if (this.state.searchString) {
const DIMMED = 1;
Expand All @@ -882,13 +881,12 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
const FILTERED = 4;
filterExpressionsMap[FILTERED] = this.state.filters; // For filtering
}

if (Object.keys(filterExpressionsMap).length > 0) {
this.chartLayer.updateChart(filterExpressionsMap);
return filterExpressionsMap;
} else {
this.chartLayer.updateChart();
return undefined;
}
};
}

private clearSearchBox() {
this.setState({ searchString: '' });
Expand Down

0 comments on commit a5ddfb9

Please sign in to comment.