put back the code that make everything works (#49643) (#49676)

This commit is contained in:
Xavier Mouligneau 2019-10-29 22:09:28 -04:00 committed by GitHub
parent 2562c5866b
commit 2eb2e17e07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,13 +55,18 @@ interface UpdateReduxTime extends OnTimeChangeProps {
timelineId?: string;
}
interface ReturnUpdateReduxTime {
kqlHaveBeenUpdated: boolean;
}
export type DispatchUpdateReduxTime = ({
end,
id,
isQuickSelection,
kql,
start,
timelineId,
}: UpdateReduxTime) => void;
}: UpdateReduxTime) => ReturnUpdateReduxTime;
interface SuperDatePickerDispatchProps {
setDuration: ({ id, duration }: { id: InputsModelId; duration: number }) => void;
@ -105,7 +110,7 @@ export const SuperDatePickerComponent = React.memo<SuperDatePickerProps>(
);
const onRefresh = useCallback(
({ start: newStart, end: newEnd }: OnRefreshProps): void => {
updateReduxTime({
const { kqlHaveBeenUpdated } = updateReduxTime({
end: newEnd,
id,
isInvalid: false,
@ -118,7 +123,10 @@ export const SuperDatePickerComponent = React.memo<SuperDatePickerProps>(
const currentEnd = isQuickSelection
? formatDate(newEnd, { roundUp: true })
: formatDate(newEnd);
if (!isQuickSelection || (start === currentStart && end === currentEnd)) {
if (
!kqlHaveBeenUpdated &&
(!isQuickSelection || (start === currentStart && end === currentEnd))
) {
refetchQuery(queries);
}
},
@ -217,9 +225,10 @@ export const dispatchUpdateReduxTime = (dispatch: Dispatch) => ({
end,
id,
isQuickSelection,
kql,
start,
timelineId,
}: UpdateReduxTime): void => {
}: UpdateReduxTime): ReturnUpdateReduxTime => {
const fromDate = formatDate(start);
let toDate = formatDate(end, { roundUp: true });
if (isQuickSelection) {
@ -251,6 +260,15 @@ export const dispatchUpdateReduxTime = (dispatch: Dispatch) => ({
})
);
}
if (kql) {
return {
kqlHaveBeenUpdated: kql.refetch(dispatch),
};
}
return {
kqlHaveBeenUpdated: false,
};
};
export const makeMapStateToProps = () => {