mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 04:42:03 +08:00
fix: back btn navigation on first load (#4405)
* fix: back btn navigation on first load * fix: remove console logs * chore: refactor the logic to a function and added code comments
This commit is contained in:
parent
00e97fa401
commit
255b3dd3b0
@ -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]);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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+/, '');
|
||||
|
Loading…
x
Reference in New Issue
Block a user