diff --git a/src/hooks/marriage/use-profile-main.ts b/src/hooks/marriage/use-profile-main.ts index 0c5725c..d433562 100644 --- a/src/hooks/marriage/use-profile-main.ts +++ b/src/hooks/marriage/use-profile-main.ts @@ -69,36 +69,8 @@ export async function getMarriageProfile() { export function useMarriageProfileQuery( options?: QueryOptions, ) { - const queryClient = useQueryClient(); - - useEffect(() => { - const handleInitialData = (e: Event) => { - const customEvent = e as CustomEvent; - const initial = getInitialMarriageProfile(); - console.log("📥 [Profile Query] Received habib:marriage-initial-data event:", { - detail: customEvent.detail, - parsedInitial: initial, - }); - if (initial) { - queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { - console.log("🔄 [Profile Query] Merging initialData into QueryCache. Old:", old, "New Initial:", initial); - if (!old) return initial; - return { - ...initial, - ...old, - }; - }); - } - }; - - window.addEventListener("habib:marriage-initial-data", handleInitialData); - return () => { - window.removeEventListener("habib:marriage-initial-data", handleInitialData); - }; - }, [queryClient]); - const query = useQuery({ - staleTime: 0, // Prioritize fresh server data from /api/marriage/profile/main/ on mount + staleTime: 30 * 1000, refetchOnWindowFocus: false, initialData: getInitialMarriageProfile as any, initialDataUpdatedAt: 0, @@ -107,5 +79,8 @@ export function useMarriageProfileQuery( queryKey: marriageQueryKeys.profile(), }); - return query; + return { + ...query, + isLiveServerFetched: query.dataUpdatedAt > 0, + }; } diff --git a/src/hooks/use-habib-web-ready.ts b/src/hooks/use-habib-web-ready.ts index ea5ac5e..c6df617 100644 --- a/src/hooks/use-habib-web-ready.ts +++ b/src/hooks/use-habib-web-ready.ts @@ -20,17 +20,7 @@ import { setCachedMarriageEntryPath } from "@/lib/entry-route-cache"; export function useHabibWebReady(ready: boolean) { useEffect(() => { if (ready && typeof window !== "undefined") { - let cancelled = false; - - // Double requestAnimationFrame guarantees the browser has executed layout & paint - // of the ready DOM state to the GPU compositor before Flutter lifts the native cover. - const raf1 = requestAnimationFrame(() => { - const raf2 = requestAnimationFrame(() => { - if (!cancelled) { - window.__announceHabibWebReady?.(); - } - }); - }); + window.__announceHabibWebReady?.(); const pathname = window.location.pathname; if (pathname) { @@ -45,11 +35,6 @@ export function useHabibWebReady(ready: boolean) { setCachedMarriageEntryPath(route); } } - - return () => { - cancelled = true; - cancelAnimationFrame(raf1); - }; } }, [ready]); }