Browse Source

fix match hook start

master
mortezaei 3 weeks ago
parent
commit
6960754c1d
  1. 9
      src/app/finding-match/finding-match-client.tsx
  2. 7
      src/hooks/marriage/use-match-start.ts

9
src/app/finding-match/finding-match-client.tsx

@ -31,7 +31,7 @@ export default function FindingMatchClient() {
const { dictionary: t, locale } = useI18n(); const { dictionary: t, locale } = useI18n();
const { isAdvisorOpen, openAdvisors, closeAdvisors } = const { isAdvisorOpen, openAdvisors, closeAdvisors } =
useMarriageAdvisorsOverlay(); useMarriageAdvisorsOverlay();
const { data: profile, isLoading } = useMarriageProfileQuery({
const { data: profile, isLoading, isFetched } = useMarriageProfileQuery({
refetchInterval: 3000, refetchInterval: 3000,
}); });
@ -50,11 +50,16 @@ export default function FindingMatchClient() {
if (!profile) { if (!profile) {
return; 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); const targetPath = getSubmitPath(profile);
if (targetPath !== "/finding-match") { if (targetPath !== "/finding-match") {
router.replace(localizePath(targetPath, locale)); 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. // Signal Flutter to lift its loading cover immediately so page renders with 0ms latency.
useHabibWebReady(true); useHabibWebReady(true);

7
src/hooks/marriage/use-match-start.ts

@ -25,6 +25,13 @@ export function useStartMarriageMatchMutation(
mutationFn: startMarriageMatch, mutationFn: startMarriageMatch,
onSuccess: async (data, variables, onMutateResult, context) => { onSuccess: async (data, variables, onMutateResult, context) => {
setCachedMarriageEntryPath("/finding-match"); setCachedMarriageEntryPath("/finding-match");
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => {
if (!old) return old;
return {
...old,
status: "waiting",
};
});
Promise.all([ Promise.all([
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: marriageQueryKeys.profile(), queryKey: marriageQueryKeys.profile(),

Loading…
Cancel
Save