From fbddda3a21d5f824389ac924274b0c0d9476cf3a Mon Sep 17 00:00:00 2001 From: mortezaei Date: Mon, 31 Aug 2026 01:35:45 +0330 Subject: [PATCH] fix: prioritize existing cache data during profile state updates and persistence --- src/hooks/marriage/use-profile-main.ts | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/hooks/marriage/use-profile-main.ts b/src/hooks/marriage/use-profile-main.ts index 041f5d5..9adf54c 100644 --- a/src/hooks/marriage/use-profile-main.ts +++ b/src/hooks/marriage/use-profile-main.ts @@ -123,18 +123,34 @@ export function useMarriageProfileQuery( (old: MarriageProfileResponse | undefined) => { if (!old) return data; return { - ...old, ...data, - match_summary: data.match_summary ?? old.match_summary, - active_case: data.active_case ?? old.active_case, + ...old, + match_summary: old.match_summary ?? data.match_summary, + active_case: old.active_case ?? data.active_case, active_subscription: - data.active_subscription ?? old.active_subscription, + old.active_subscription ?? data.active_subscription, + recommended_plan: + old.recommended_plan ?? data.recommended_plan, }; }, ); if (data.id && (data.match_summary || data.status)) { - saveScopedMarriageProfile(data); + const currentPersisted = getScopedMarriageProfile(); + const merged = { + ...data, + ...(currentPersisted || {}), + match_summary: + currentPersisted?.match_summary ?? data.match_summary, + active_case: + currentPersisted?.active_case ?? data.active_case, + recommended_plan: + currentPersisted?.recommended_plan ?? data.recommended_plan, + active_subscription: + currentPersisted?.active_subscription ?? + data.active_subscription, + }; + saveScopedMarriageProfile(merged); } } }