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 double fetch when filter pill is added #63024

Merged
merged 7 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions x-pack/plugins/maps/public/layers/util/data_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ export class DataRequest {
}

getMeta(): DataMeta {
return this.hasData()
? _.get(this._descriptor, 'dataMeta', {})
: _.get(this._descriptor, 'dataMetaAtStart', {});
Copy link
Contributor

Choose a reason for hiding this comment

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

apart from the bugfix, +1 on the removal of _.get.

if (this._descriptor.dataMetaAtStart) {
return this._descriptor.dataMetaAtStart;
} else if (this._descriptor.dataMeta) {
return this._descriptor.dataMeta;
} else {
return {};
}
}

hasData(): boolean {
Expand Down
7 changes: 6 additions & 1 deletion x-pack/plugins/maps/public/reducers/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ const updateLayerInList = (state, layerId, attribute, newValue) => {
if (!layerId) {
return state;
}

const { layerList } = state;
const layerIdx = getLayerIndex(layerList, layerId);
if (layerIdx === -1) {
return state;
}

const updatedLayer = {
...layerList[layerIdx],
// Update layer w/ new value. If no value provided, toggle boolean value
Expand Down Expand Up @@ -437,7 +442,7 @@ function updateWithDataResponse(state, action) {

dataRequest.data = action.data;
dataRequest.dataMeta = { ...dataRequest.dataMetaAtStart, ...action.meta };
dataRequest.dataMetaAtStart = null;
delete dataRequest.dataMetaAtStart;
nreese marked this conversation as resolved.
Show resolved Hide resolved
return resetDataRequest(state, action, dataRequest);
}

Expand Down