From 6960754c1d7b7fcf3d76f93863c200e0dd10db64 Mon Sep 17 00:00:00 2001 From: mortezaei Date: Sat, 29 Aug 2026 14:06:20 +0330 Subject: [PATCH] fix match hook start --- src/app/finding-match/finding-match-client.tsx | 9 +++++++-- src/hooks/marriage/use-match-start.ts | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/app/finding-match/finding-match-client.tsx b/src/app/finding-match/finding-match-client.tsx index fb12ca1..9db5fdf 100644 --- a/src/app/finding-match/finding-match-client.tsx +++ b/src/app/finding-match/finding-match-client.tsx @@ -31,7 +31,7 @@ export default function FindingMatchClient() { const { dictionary: t, locale } = useI18n(); const { isAdvisorOpen, openAdvisors, closeAdvisors } = useMarriageAdvisorsOverlay(); - const { data: profile, isLoading } = useMarriageProfileQuery({ + const { data: profile, isLoading, isFetched } = useMarriageProfileQuery({ refetchInterval: 3000, }); @@ -50,11 +50,16 @@ export default function FindingMatchClient() { if (!profile) { return; } + // Don't bounce away from finding-match if we only have preliminary initialData + // with pending_info before the fresh server query finishes + if (!isFetched && profile.status === "pending_info") { + return; + } const targetPath = getSubmitPath(profile); if (targetPath !== "/finding-match") { router.replace(localizePath(targetPath, locale)); } - }, [profile, locale, router]); + }, [profile, isFetched, locale, router]); // Signal Flutter to lift its loading cover immediately so page renders with 0ms latency. useHabibWebReady(true); diff --git a/src/hooks/marriage/use-match-start.ts b/src/hooks/marriage/use-match-start.ts index 0f2b33d..600c5ac 100644 --- a/src/hooks/marriage/use-match-start.ts +++ b/src/hooks/marriage/use-match-start.ts @@ -25,6 +25,13 @@ export function useStartMarriageMatchMutation( mutationFn: startMarriageMatch, onSuccess: async (data, variables, onMutateResult, context) => { setCachedMarriageEntryPath("/finding-match"); + queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { + if (!old) return old; + return { + ...old, + status: "waiting", + }; + }); Promise.all([ queryClient.invalidateQueries({ queryKey: marriageQueryKeys.profile(),