Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] fix multi-select query from Controls visualization not always getting applied to map in dashboard #87310

Merged
merged 4 commits into from Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion x-pack/plugins/maps/public/actions/data_request_actions.ts
Expand Up @@ -227,11 +227,15 @@ function endDataLoad(
data: object,
meta: DataMeta
) {
return async (
return (
dispatch: ThunkDispatch<MapStoreState, void, AnyAction>,
getState: () => MapStoreState
) => {
dispatch(unregisterCancelCallback(requestToken));
const dataRequest = getDataRequestDescriptor(getState(), layerId, dataId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (dataRequest && dataRequest.dataRequestToken !== requestToken) {
throw new DataRequestAbortError();
}

const features = data && 'features' in data ? (data as FeatureCollection).features : [];

Expand Down
Expand Up @@ -41,6 +41,7 @@ import {
import { IVectorSource } from '../../sources/vector_source';
import { LICENSED_FEATURES } from '../../../licensed_features';
import { ESSearchSource } from '../../sources/es_search_source/es_search_source';
import { isSearchSourceAbortError } from '../../sources/es_source/es_source';

const ACTIVE_COUNT_DATA_ID = 'ACTIVE_COUNT_DATA_ID';

Expand Down Expand Up @@ -311,14 +312,16 @@ export class BlendedVectorLayer extends VectorLayer implements IVectorLayer {
let isSyncClustered;
try {
syncContext.startLoading(dataRequestId, requestToken, searchFilters);
const abortController = new AbortController();
syncContext.registerCancelCallback(requestToken, () => abortController.abort());
const searchSource = await this._documentSource.makeSearchSource(searchFilters, 0);
const resp = await searchSource.fetch();
const resp = await searchSource.fetch({ abortSignal: abortController.signal });
const maxResultWindow = await this._documentSource.getMaxResultWindow();
isSyncClustered = resp.hits.total > maxResultWindow;
const countData = { isSyncClustered } as CountData;
syncContext.stopLoading(dataRequestId, requestToken, countData, searchFilters);
} catch (error) {
if (!(error instanceof DataRequestAbortError)) {
if (!(error instanceof DataRequestAbortError) || !isSearchSourceAbortError(error)) {
syncContext.onLoadError(dataRequestId, requestToken, error.message);
}
return;
Expand Down
Expand Up @@ -40,6 +40,10 @@ import {
} from '../../../../../../../src/plugins/inspector/common/adapters';
import { isValidStringConfig } from '../../util/valid_string_config';

export function isSearchSourceAbortError(error: Error) {
return error.name === 'AbortError';
}

export interface IESSource extends IVectorSource {
isESSource(): true;
getId(): string;
Expand Down Expand Up @@ -191,7 +195,7 @@ export class AbstractESSource extends AbstractVectorSource implements IESSource
if (inspectorRequest) {
inspectorRequest.error(error);
}
if (error.name === 'AbortError') {
if (isSearchSourceAbortError(error)) {
throw new DataRequestAbortError();
}

Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/maps/public/embeddable/map_embeddable.tsx
Expand Up @@ -104,7 +104,9 @@ export class MapEmbeddable

this._savedMap = new SavedMap({ mapEmbeddableInput: initialInput });
this._initializeSaveMap();
this._subscription = this.getInput$().subscribe((input) => this.onContainerStateChanged(input));
this._subscription = this.getUpdated$().subscribe(() =>
this.onContainerStateChanged(this.input)
);
}

private async _initializeSaveMap() {
Expand Down