From 2a371745806bf2cd01ee6e588e8fbd829aa39201 Mon Sep 17 00:00:00 2001 From: mortezaei Date: Thu, 20 Aug 2026 17:29:09 +0330 Subject: [PATCH] fix(geo): support force refresh in getUserGeoRegion and pass force on auto click --- src/components/Componentes/question-birthplace.tsx | 2 +- src/lib/geo-region.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/Componentes/question-birthplace.tsx b/src/components/Componentes/question-birthplace.tsx index 1c92e4e..25a706e 100644 --- a/src/components/Componentes/question-birthplace.tsx +++ b/src/components/Componentes/question-birthplace.tsx @@ -187,7 +187,7 @@ export function QuestionBirthplace({ setIsDetecting(true); try { - const region = await getUserGeoRegion(); + const region = await getUserGeoRegion(force); if (!isMountedRef.current) return; const city = region.city || ""; diff --git a/src/lib/geo-region.ts b/src/lib/geo-region.ts index 93026a3..ef9992e 100644 --- a/src/lib/geo-region.ts +++ b/src/lib/geo-region.ts @@ -79,10 +79,15 @@ function resolvePhoneCodeFromCountryCode(isoCode?: string): string | undefined { return undefined; } -export function getUserGeoRegion(): Promise { - const existing = getStoredUserGeoRegion(); - if (existing && (existing.city || existing.country)) { - return Promise.resolve(existing); +export function getUserGeoRegion(force = false): Promise { + if (!force) { + const existing = getStoredUserGeoRegion(); + if (existing && (existing.city || existing.country)) { + return Promise.resolve(existing); + } + } else { + cachedRegion = null; + geoRegionPromise = null; } if (geoRegionPromise) {