Skip to content

Commit

Permalink
[Dashboard] [Controls] Skip First Reload (#142868)
Browse files Browse the repository at this point in the history
* Skip first reload of dashboard controls to ensure only the filters from control group initialization are applied
  • Loading branch information
ThomThomson authored Oct 6, 2022
1 parent e794156 commit 5a17c64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,17 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
isProjectEnabledInLabs('labs:dashboard:dashboardControls')
) {
this.controlGroup = controlGroup;
syncDashboardControlGroup({ dashboardContainer: this, controlGroup: this.controlGroup }).then(
(result) => {
this.controlGroup.untilReady().then(() => {
if (!this.controlGroup || isErrorEmbeddable(this.controlGroup)) return;
syncDashboardControlGroup({
dashboardContainer: this,
controlGroup: this.controlGroup,
}).then((result) => {
if (!result) return;
const { onDestroyControlGroup } = result;
this.onDestroyControlGroup = onDestroyControlGroup;
}
);
});
});
}

this.subscriptions.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import _ from 'lodash';
import { Subscription } from 'rxjs';
import deepEqual from 'fast-deep-equal';
import { compareFilters, COMPARE_ALL_OPTIONS, type Filter } from '@kbn/es-query';
import { debounceTime, distinctUntilChanged, distinctUntilKeyChanged } from 'rxjs/operators';
import { debounceTime, distinctUntilChanged, distinctUntilKeyChanged, skip } from 'rxjs/operators';

import {
ControlGroupInput,
Expand Down Expand Up @@ -140,11 +140,10 @@ export const syncDashboardControlGroup = async ({
.pipe(
distinctUntilChanged(({ filters: filtersA }, { filters: filtersB }) =>
compareAllFilters(filtersA, filtersB)
)
),
skip(1) // skip first filter output because it will have been applied in initialize
)
.subscribe(() => {
dashboardContainer.updateInput({ lastReloadRequestTime: Date.now() });
})
.subscribe(() => dashboardContainer.updateInput({ lastReloadRequestTime: Date.now() }))
);

subscriptions.add(
Expand Down

0 comments on commit 5a17c64

Please sign in to comment.