From 27e0cd239f0fefb73138d5308a0371aef48dda96 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 6 Aug 2025 18:40:40 +0700 Subject: [PATCH 1/3] remove connect method --- src/libs/PersonalDetailsUtils.ts | 17 ----------------- .../PersonalDetails/PersonalAddressPage.tsx | 4 ++-- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 4f940a8842a1..eaa2c1086039 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -50,18 +50,6 @@ Onyx.connect({ }, }); -let defaultCountry = ''; - -Onyx.connect({ - key: ONYXKEYS.COUNTRY, - callback: (value) => { - if (!value) { - return; - } - defaultCountry = value; - }, -}); - const regexMergedAccount = new RegExp(CONST.REGEX.MERGED_ACCOUNT_PREFIX); function getDisplayNameOrDefault( @@ -425,10 +413,6 @@ const getShortMentionIfFound = (displayText: string, userAccountID: string, curr return displayText.split('@').at(0); }; -function getDefaultCountry() { - return defaultCountry; -} - /** * Gets the phone number to display for SMS logins */ @@ -464,7 +448,6 @@ export { getPersonalDetailsLength, getUserNameByEmail, getShortMentionIfFound, - getDefaultCountry, getLoginByAccountID, getPhoneNumber, }; diff --git a/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx b/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx index bbaf785c7ba8..a98343a6cb71 100644 --- a/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx +++ b/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx @@ -26,9 +26,9 @@ function updateAddress(values: FormOnyxValues getCurrentAddress(privatePersonalDetails), [privatePersonalDetails]); - const defaultCountry = getDefaultCountry(); return ( Date: Thu, 7 Aug 2025 22:54:24 +0700 Subject: [PATCH 2/3] eslint --- .../settings/Profile/PersonalDetails/PersonalAddressPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx b/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx index a98343a6cb71..69a024df1e26 100644 --- a/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx +++ b/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx @@ -1,7 +1,7 @@ import React, {useMemo} from 'react'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; -import {getCurrentAddress, getDefaultCountry} from '@libs/PersonalDetailsUtils'; +import {getCurrentAddress} from '@libs/PersonalDetailsUtils'; import AddressPage from '@pages/AddressPage'; import type {FormOnyxValues} from '@src/components/Form/types'; import type {Country} from '@src/CONST'; @@ -25,7 +25,7 @@ function updateAddress(values: FormOnyxValues getCurrentAddress(privatePersonalDetails), [privatePersonalDetails]); From 6d0c280279bf063a083693e780c6bb5184beaf51 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 8 Aug 2025 18:32:52 +0700 Subject: [PATCH 3/3] fix bug --- package.json | 2 +- .../Profile/PersonalDetails/PersonalAddressPage.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b9d65b377773..459c0d4b8c01 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "test:debug": "TZ=utc NODE_OPTIONS='--inspect-brk --experimental-vm-modules' jest --runInBand", "perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", - "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=285 --cache --cache-location=node_modules/.cache/eslint", + "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=284 --cache --cache-location=node_modules/.cache/eslint", "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh", "lint-watch": "npx eslint-watch --watch --changed", "shellcheck": "./scripts/shellCheck.sh", diff --git a/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx b/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx index 69a024df1e26..4b6e89f065eb 100644 --- a/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx +++ b/src/pages/settings/Profile/PersonalDetails/PersonalAddressPage.tsx @@ -1,4 +1,5 @@ import React, {useMemo} from 'react'; +import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import {getCurrentAddress} from '@libs/PersonalDetailsUtils'; @@ -7,6 +8,7 @@ import type {FormOnyxValues} from '@src/components/Form/types'; import type {Country} from '@src/CONST'; import {updateAddress as updateAddressPersonalDetails} from '@src/libs/actions/PersonalDetails'; import ONYXKEYS from '@src/ONYXKEYS'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; /** * Submit form to update user's first and last legal name @@ -27,9 +29,12 @@ function PersonalAddressPage() { const {translate} = useLocalize(); const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS, {canBeMissing: true}); const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); - const [defaultCountry] = useOnyx(ONYXKEYS.COUNTRY, {canBeMissing: true}); + const [defaultCountry, defaultCountryStatus] = useOnyx(ONYXKEYS.COUNTRY, {canBeMissing: true}); + const isLoading = isLoadingOnyxValue(defaultCountryStatus); const address = useMemo(() => getCurrentAddress(privatePersonalDetails), [privatePersonalDetails]); - + if (isLoading) { + return ; + } return (