Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/Insights/InsightsCatalog/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const Container = styled.div`
padding: 8px 0;
gap: 8px;
box-sizing: border-box;
overflow: auto;
`;

export const Footer = styled.div`
Expand Down
31 changes: 3 additions & 28 deletions src/components/Navigation/HistoryNavigation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { useEffect } from "react";
import type { Location } from "react-router";
import { useLocation, useNavigate } from "react-router";
import { history } from "../../../containers/Main/history";
import type { HistoryEntry } from "../../../history/History";
import { useConfigSelector } from "../../../store/config/useConfigSelector";
import { isBoolean } from "../../../typeGuards/isBoolean";
Expand All @@ -12,7 +9,7 @@ import { ScopeChangeEvent } from "../../../types";
import { changeScope } from "../../../utils/actions/changeScope";
import { sendUserActionTrackingEvent } from "../../../utils/actions/sendUserActionTrackingEvent";
import { HistoryNavigationPanel } from "../../common/HistoryNavigationPanel";
import type { HistoryState, ReactRouterLocationState } from "../../Main/types";
import type { HistoryState } from "../../Main/types";
import { useBrowserLocationUpdater } from "../../Main/updateBrowserLocationUpdater";
import { useHistory } from "../../Main/useHistory";
import { trackingEvents } from "../tracking";
Expand All @@ -35,32 +32,10 @@ const isHistoryEntryWithHistoryState = (
(isHistoryState(obj.state) || isUndefined(obj.state));

export const HistoryNavigation = () => {
const { goBack, goForward, goTo, canGoBack, canGoForward } = useHistory();
const navigate = useNavigate();
const { goBack, goForward, canGoBack, canGoForward } = useHistory();
const { environments, environment, scope } = useConfigSelector();
const location = useLocation() as Location<ReactRouterLocationState | null>;
const updateBrowserLocation = useBrowserLocationUpdater();

useEffect(() => {
// Initialize history with the current state
if (!location.state?.navigatedWithCustomHistory) {
goTo(
{
pathname: location.pathname,
search: location.search
},
{
replace: history.historyStack.length > 0,
state: {
environmentId: environment?.id,
spanCodeObjectId: scope?.span?.spanCodeObjectId,
spanDisplayName: scope?.span?.displayName
}
}
);
}
}, [location, goTo, environment?.id, scope?.span]);

useEffect(() => {
const handleHistoryChange = (e: Event) => {
if (
Expand Down Expand Up @@ -131,7 +106,7 @@ export const HistoryNavigation = () => {
return () => {
window.removeEventListener("history:navigate", handleHistoryNavigate);
};
}, [navigate]);
}, []);

const handleBackButtonClick = () => {
sendUserActionTrackingEvent(trackingEvents.BACK_BUTTON_CLICKED);
Expand Down
22 changes: 10 additions & 12 deletions src/redux/utils/getRememberEnhancer.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { rememberEnhancer } from "redux-remember";
import { isObject } from "../../typeGuards/isObject";

interface RememberEnhancerProps {
rememberedKeys: string[];
prefix: string;
version: number;
}

const rehydrateState = <T extends Record<string, unknown>>(
rehydratedState: Record<string, unknown>,
version: number
) => {
const rehydrateState = (rehydratedState: unknown, version: number) => {
if (!isObject(rehydratedState)) {
return undefined;
}

if (rehydratedState.version !== version) {
return undefined;
}

return rehydratedState as T;
return rehydratedState;
};

export const getRememberEnhancer = <T extends Record<string, unknown>>({
export const getRememberEnhancer = ({
rememberedKeys,
prefix,
version
Expand All @@ -26,12 +28,8 @@ export const getRememberEnhancer = <T extends Record<string, unknown>>({
prefix,
unserialize: (stateString: string) => {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const rehydratedState = JSON.parse(stateString);
return rehydrateState<T>(
rehydratedState as Record<string, unknown>,
version
);
const rehydratedState = JSON.parse(stateString) as unknown;
return rehydrateState(rehydratedState, version);
} catch (error) {
// eslint-disable-next-line no-console
console.error("Failed to parse persisted state:", error);
Expand Down
Loading