diff --git a/frontend/src/container/TopNav/DateTimeSelection/index.tsx b/frontend/src/container/TopNav/DateTimeSelection/index.tsx index c72ff7b82d..785f65da8f 100644 --- a/frontend/src/container/TopNav/DateTimeSelection/index.tsx +++ b/frontend/src/container/TopNav/DateTimeSelection/index.tsx @@ -279,6 +279,18 @@ function DateTimeSelection({ setRefreshButtonHidden(updatedTime === 'custom'); updateTimeInterval(updatedTime, [preStartTime, preEndTime]); + + if (updatedTime !== 'custom') { + const { minTime, maxTime } = GetMinMax(updatedTime); + urlQuery.set(QueryParams.startTime, minTime.toString()); + urlQuery.set(QueryParams.endTime, maxTime.toString()); + } else { + urlQuery.set(QueryParams.startTime, preStartTime.toString()); + urlQuery.set(QueryParams.endTime, preEndTime.toString()); + } + const generatedUrl = `${location.pathname}?${urlQuery.toString()}`; + history.replace(generatedUrl); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [location.pathname, updateTimeInterval, globalTimeLoading]); diff --git a/frontend/src/store/actions/trace/getInitialFilter.ts b/frontend/src/store/actions/trace/getInitialFilter.ts index 5ff04b1eff..8a83a1d33f 100644 --- a/frontend/src/store/actions/trace/getInitialFilter.ts +++ b/frontend/src/store/actions/trace/getInitialFilter.ts @@ -25,6 +25,7 @@ import { parseQueryIntoPageSize, parseQueryIntoSelectedTags, parseSelectedFilter, + stripTimestampsFromQuery, } from './util'; export const GetInitialTraceFilter = ( @@ -113,8 +114,11 @@ export const GetInitialTraceFilter = ( ); if (response.payload && !isSelectionSkipped.currentValue) { + /** this is required as now we have timestamps updated in date time selection component + * so for initial filters we need to strip timestamps and check for initial load + */ const diff = - query.length === 0 + stripTimestampsFromQuery(query).length === 0 ? traces.filterToFetchData : xor(traces.filterToFetchData, getFilterToFetchData.currentValue); diff --git a/frontend/src/store/actions/trace/util.ts b/frontend/src/store/actions/trace/util.ts index 3556636f15..54cd819da5 100644 --- a/frontend/src/store/actions/trace/util.ts +++ b/frontend/src/store/actions/trace/util.ts @@ -86,3 +86,6 @@ export const getFilter = (data: GetFilterPayload): TraceReducer['filter'] => { return filter; }; + +export const stripTimestampsFromQuery = (query: string): string => + query.replace(/(\?|&)startTime=\d+/, '').replace(/&endTime=\d+/, '');