diff --git a/src/app/layout.tsx b/src/app/layout.tsx index bbeb056..fbcc616 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -10,6 +10,8 @@ import { isLocale, localeDirections, } from "@/translations/config"; +import { getInitialMarriageProfile } from "@/hooks/marriage/use-profile-main"; +import type { MarriageProfileResponse } from "@/hooks/marriage/types"; const faminela = localFont({ src: "../../public/fonts/Faminela/Faminela.otf", @@ -90,15 +92,18 @@ export default async function RootLayout({ cookieStore.get("habib_marriage_data")?.value; let initialMarriageJson: string | null = null; + let initialProfile: MarriageProfileResponse | undefined; if (rawMarriageCookie) { try { const decoded = decodeURIComponent(rawMarriageCookie); - JSON.parse(decoded); + const parsed = JSON.parse(decoded); initialMarriageJson = decoded; + initialProfile = getInitialMarriageProfile(parsed); } catch { try { - JSON.parse(rawMarriageCookie); + const parsed = JSON.parse(rawMarriageCookie); initialMarriageJson = rawMarriageCookie; + initialProfile = getInitialMarriageProfile(parsed); } catch {} } } @@ -405,7 +410,7 @@ export default async function RootLayout({ className={`${faminela.variable} ${amiri.variable}`} suppressHydrationWarning > - + {isDevelopment ? : null}
{children}
diff --git a/src/app/new-match/new-match-client.tsx b/src/app/new-match/new-match-client.tsx index 12f0044..921fcda 100644 --- a/src/app/new-match/new-match-client.tsx +++ b/src/app/new-match/new-match-client.tsx @@ -734,7 +734,7 @@ export default function NewMatchClient() { {/* 2. Match Summary Card Section */}
- {isLoading ? ( + {isLoading && !matchSummary ? (
diff --git a/src/app/providers.tsx b/src/app/providers.tsx index 689d5b0..e5a8d84 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -11,16 +11,20 @@ import HardwareBackBridge from "@/components/Componentes/hardware-back-bridge"; import SilentReloader from "@/components/Componentes/silent-reloader"; import { ViewPaddingsProvider } from "@/components/Componentes/view-paddings-provider"; +import { marriageQueryKeys } from "@/hooks/marriage/query-keys"; +import type { MarriageProfileResponse } from "@/hooks/marriage/types"; + // AppFocusReloader was extracted to SilentReloader in silent-reloader.tsx type ProvidersProps = { children: ReactNode; + initialProfile?: MarriageProfileResponse; }; -export default function Providers({ children }: ProvidersProps) { +export default function Providers({ children, initialProfile }: ProvidersProps) { const [queryClient] = useState( - () => - new QueryClient({ + () => { + const qc = new QueryClient({ defaultOptions: { queries: { // Keep the last successful response available while a fresh @@ -38,7 +42,12 @@ export default function Providers({ children }: ProvidersProps) { structuralSharing: true, }, }, - }), + }); + if (initialProfile) { + qc.setQueryData(marriageQueryKeys.profile(), initialProfile); + } + return qc; + }, ); return ( diff --git a/src/hooks/marriage/use-profile-main.ts b/src/hooks/marriage/use-profile-main.ts index 3e846fc..abf433b 100644 --- a/src/hooks/marriage/use-profile-main.ts +++ b/src/hooks/marriage/use-profile-main.ts @@ -13,8 +13,10 @@ import type { QueryOptions } from "./options"; import { marriageQueryKeys } from "./query-keys"; import type { MarriageProfileResponse } from "./types"; -export function getInitialMarriageProfile(): MarriageProfileResponse | undefined { - const data = authBridge.getMarriageData(); +export function getInitialMarriageProfile( + dataOverride?: any, +): MarriageProfileResponse | undefined { + const data = dataOverride ?? authBridge.getMarriageData(); if (!data) return undefined; return {