Skip to content

Commit 0790417

Browse files
authored
Merge pull request #2744 from pyth-network/cprussin/fix-insights-hub-url-restoring
fix(insights): properly restore feed component url
2 parents b8ab018 + c91da63 commit 0790417

File tree

1 file changed

+13
-3
lines changed
  • apps/insights/src/components/PriceComponentDrawer

1 file changed

+13
-3
lines changed

apps/insights/src/components/PriceComponentDrawer/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ import dynamic from "next/dynamic";
1717
import { useRouter } from "next/navigation";
1818
import { useQueryState, parseAsString } from "nuqs";
1919
import type { ReactNode } from "react";
20-
import { Suspense, useState, useCallback, useMemo, useTransition } from "react";
20+
import {
21+
Suspense,
22+
useState,
23+
useCallback,
24+
useMemo,
25+
useTransition,
26+
useRef,
27+
} from "react";
2128
import {
2229
RouterProvider,
2330
useDateFormatter,
@@ -68,6 +75,7 @@ export const usePriceComponentDrawer = ({
6875
const drawer = useDrawer();
6976
const router = useRouter();
7077
const [isRouting, startTransition] = useTransition();
78+
const didRestoreUrl = useRef(false);
7179

7280
const navigate = useCallback(
7381
(route: string) => {
@@ -102,10 +110,12 @@ export const usePriceComponentDrawer = ({
102110
}, [updateSelectedComponentId]);
103111

104112
useMountEffect(() => {
105-
if (selectedComponentId) {
113+
if (selectedComponentId && !didRestoreUrl.current) {
114+
didRestoreUrl.current = true;
106115
const component = components.find(
107116
(component) =>
108-
component[identifiesPublisher ? "publisherKey" : "feedKey"],
117+
component[identifiesPublisher ? "publisherKey" : "feedKey"] ===
118+
selectedComponentId,
109119
);
110120
if (component) {
111121
openDrawer(component);

0 commit comments

Comments
 (0)