mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
RoutingNG: Fix infinite loop caused by history state not being cleaned up (#31952)
* Fix infinite loop caused by history state not being cleaned up * Ude forceRouteReload counter instead of bool flag * Review fix
This commit is contained in:
@@ -11,7 +11,7 @@ import { config } from '../config';
|
||||
export interface LocationService {
|
||||
partial: (query: Record<string, any>, replace?: boolean) => void;
|
||||
push: (location: H.Path | H.LocationDescriptor<any>) => void;
|
||||
replace: (location: H.Path | H.LocationDescriptor<any>, forceRouteReload?: boolean) => void;
|
||||
replace: (location: H.Path | H.LocationDescriptor<any>) => void;
|
||||
reload: () => void;
|
||||
getLocation: () => H.Location;
|
||||
getHistory: () => H.History;
|
||||
@@ -95,23 +95,15 @@ export class HistoryWrapper implements LocationService {
|
||||
this.history.push(location);
|
||||
}
|
||||
|
||||
replace(location: H.Path | H.LocationDescriptor, forceRouteReload?: boolean) {
|
||||
const state = forceRouteReload ? { forceRouteReload: true } : undefined;
|
||||
|
||||
if (typeof location === 'string') {
|
||||
this.history.replace(location, state);
|
||||
} else {
|
||||
this.history.replace({
|
||||
...location,
|
||||
state,
|
||||
});
|
||||
}
|
||||
replace(location: H.Path | H.LocationDescriptor) {
|
||||
this.history.replace(location);
|
||||
}
|
||||
|
||||
reload() {
|
||||
const prevState = (this.history.location.state as any)?.routeReloadCounter;
|
||||
this.history.replace({
|
||||
...this.history.location,
|
||||
state: { forceRouteReload: true },
|
||||
state: { routeReloadCounter: prevState ? prevState + 1 : 1 },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user