Skip to content

Commit

Permalink
prevent dispatching unchanged EQL Options
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpn committed Nov 18, 2024
1 parent b202b54 commit d11b456
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,31 @@ export const EqlQueryBarTimeline = memo(({ timelineId }: { timelineId: string })
return;
}

dispatch(
timelineActions.updateEqlOptions({
id: timelineId,
field: 'query',
value: `${formData.eqlQueryBar.query.query}`,
})
);

for (const fieldName of Object.keys(formData.eqlOptions) as Array<
keyof typeof formData.eqlOptions
>) {
if (eqlOptions.query !== `${formData.eqlQueryBar.query.query}`) {
dispatch(
timelineActions.updateEqlOptions({
id: timelineId,
field: fieldName,
value: formData.eqlOptions[fieldName],
field: 'query',
value: `${formData.eqlQueryBar.query.query}`,
})
);
}

for (const fieldName of Object.keys(formData.eqlOptions) as Array<
keyof typeof formData.eqlOptions
>) {
if (formData.eqlOptions[fieldName] !== eqlOptions[fieldName]) {
dispatch(
timelineActions.updateEqlOptions({
id: timelineId,
field: fieldName,
value: formData.eqlOptions[fieldName],
})
);
}
}
},
[dispatch, timelineId]
[dispatch, timelineId, eqlOptions]
);

const { form } = useForm<TimelineEqlQueryBar>({
Expand Down

0 comments on commit d11b456

Please sign in to comment.