|
1 | 1 | "use client"; |
2 | 2 |
|
3 | | -import React, { useState, useEffect, useMemo, useCallback, Suspense } from "react"; |
| 3 | +import React, { useState, useEffect, useMemo, useCallback, Suspense, useRef } from "react"; |
4 | 4 | import dynamic from "next/dynamic"; |
5 | 5 | import { useSearchParams, useRouter, usePathname } from "next/navigation"; |
6 | 6 | import Sidebar from "@/components/HUD/Sidebar"; |
@@ -54,6 +54,7 @@ function PageContent() { |
54 | 54 | const [telemetry, setTelemetry] = useState<any>(null); |
55 | 55 | const [currentTime, setCurrentTime] = useState<Date | null>(null); |
56 | 56 | const [isLoading, setIsLoading] = useState(true); |
| 57 | + const initialDeepLinkRef = useRef(false); |
57 | 58 |
|
58 | 59 | // Sync selected satellite with URL |
59 | 60 | useEffect(() => { |
@@ -210,23 +211,26 @@ function PageContent() { |
210 | 211 |
|
211 | 212 | // Deep Linking: Auto-select satellite from URL |
212 | 213 | useEffect(() => { |
213 | | - if (satId && objects.length > 0 && !isLoading) { |
214 | | - const currentId = selectedObject?.id; |
215 | | - if (satId !== currentId) { |
216 | | - const sat = objects.find(o => o.id === satId); |
217 | | - if (sat) { |
218 | | - setSelectedObject(sat); |
219 | | - // Only toast on initial track or if triggered by link |
220 | | - if (!currentId) { |
221 | | - toast.info(`Tracking: ${sat.name}`, { |
222 | | - icon: '🛰️', |
223 | | - duration: 5000 |
224 | | - }); |
| 214 | + if (!initialDeepLinkRef.current && objects.length > 0 && !isLoading) { |
| 215 | + initialDeepLinkRef.current = true; |
| 216 | + if (satId) { |
| 217 | + const currentId = selectedObject?.id; |
| 218 | + if (satId !== currentId) { |
| 219 | + const sat = objects.find(o => o.id === satId); |
| 220 | + if (sat) { |
| 221 | + setSelectedObject(sat); |
| 222 | + // Only toast on initial track or if triggered by link |
| 223 | + if (!currentId) { |
| 224 | + toast.info(`Tracking: ${sat.name}`, { |
| 225 | + icon: '🛰️', |
| 226 | + duration: 5000 |
| 227 | + }); |
| 228 | + } |
225 | 229 | } |
226 | 230 | } |
227 | 231 | } |
228 | 232 | } |
229 | | - }, [satId, objects, isLoading]); |
| 233 | + }, [satId, objects, isLoading, selectedObject?.id]); |
230 | 234 |
|
231 | 235 | useEffect(() => { |
232 | 236 | const timer = setInterval(() => { |
|
0 commit comments