From 2d4956fe68dd71200a1eacc4b791bb61567af02f Mon Sep 17 00:00:00 2001 From: Blake Kaufman <68204898+BlakeKaufman@users.noreply.github.com> Date: Wed, 24 Jun 2026 18:21:37 -0400 Subject: [PATCH] buliding new auth setup to remove race condition during login (#961) * buliding new auth setup to remove race condition during login * revert complex fix. Just add local is loaded property * Apply suggestion from @bitcoinuser Co-authored-by: bitcoinuser --------- Co-authored-by: bitcoinuser --- App.tsx | 6 +++++- .../admin/homeComponents/contacts/addContactsPage.js | 2 +- context-store/appStatus.js | 5 +---- jest.setup.js | 8 ++++++++ locales/de-DE/translation.json | 3 ++- locales/en/translation.json | 3 ++- locales/es/translation.json | 3 ++- locales/fr/translation.json | 3 ++- locales/it/translation.json | 3 ++- locales/pt-BR/translation.json | 3 ++- locales/ru/translation.json | 3 ++- locales/sv/translation.json | 3 ++- 12 files changed, 31 insertions(+), 14 deletions(-) diff --git a/App.tsx b/App.tsx index 46a93c13..14847418 100644 --- a/App.tsx +++ b/App.tsx @@ -507,6 +507,10 @@ function ResetStack(): JSX.Element | null { ...prev, isLoggedIn: !!pin.value && !!mnemonic.value, hasSecurityEnabled: parsedSettings.isSecurityEnabled, + // Settings are now resolved — unblock the render gate below. Until this + // is true the navigator stays unmounted so Home never mounts with the + // wrong (still-loading) component. This is the login race-condition fix. + isLoaded: true, }; }); @@ -583,7 +587,7 @@ function ResetStack(): JSX.Element | null { return CreateAccountHome; }, [initSettings.isLoggedIn, initSettings.hasSecurityEnabled]); - if (theme === null || darkModeType === null) { + if (theme === null || darkModeType === null || !initSettings.isLoaded) { return null; } diff --git a/app/components/admin/homeComponents/contacts/addContactsPage.js b/app/components/admin/homeComponents/contacts/addContactsPage.js index 3ecc6d70..0bdfe205 100644 --- a/app/components/admin/homeComponents/contacts/addContactsPage.js +++ b/app/components/admin/homeComponents/contacts/addContactsPage.js @@ -29,7 +29,7 @@ export default function AddContactsPage({ selectedContact }) { diff --git a/context-store/appStatus.js b/context-store/appStatus.js index 7abcefb5..84ec598d 100644 --- a/context-store/appStatus.js +++ b/context-store/appStatus.js @@ -178,10 +178,7 @@ const AppStatusProvider = ({ children }) => { (async () => { try { - const [ - submarineSwapStats, - reverseSwapStats, - ] = await Promise.all([ + const [submarineSwapStats, reverseSwapStats] = await Promise.all([ getBoltzSwapPairInformation('submarine'), getBoltzSwapPairInformation('reverse'), ]); diff --git a/jest.setup.js b/jest.setup.js index 9d24efbf..83040b99 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -53,6 +53,14 @@ jest.mock('@react-native-firebase/storage', () => ({ getStorage: jest.fn(() => ({})), })); +// react-native-localize is a native module (RNLocalize) that throws at import +// time under Jest. Provide a sensible English default; tests can override locally. +jest.mock('react-native-localize', () => ({ + getLocales: jest.fn(() => [ + { languageCode: 'en', countryCode: 'US', languageTag: 'en-US', isRTL: false }, + ]), +})); + // react-native-quick-crypto is a Nitro/Turbo native module that throws at import // time under Jest. Delegate to Node's crypto so modules in the encryption chain // (e.g. messaging/encodingAndDecodingMessages.js) load AND actually work. diff --git a/locales/de-DE/translation.json b/locales/de-DE/translation.json index 3d82372a..52191d75 100644 --- a/locales/de-DE/translation.json +++ b/locales/de-DE/translation.json @@ -1418,7 +1418,8 @@ "invalidCharactersError": "Name und Biografie dürfen die Zeichen < > { } ` \\ nicht enthalten", "invalidReceiveAddressError": "Bitte geben Sie eine gültige Lightning-Adresse ein (z. B. benutzer@domain.com)", "aboutYou": "Über Sie", - "lightningAddress": "Lightning-Adresse" + "lightningAddress": "Lightning-Adresse", + "addContactLightningAddress": "Lightning-Adresse" }, "remotePaymentCurrencySelect": { "title": "Empfangswährung", diff --git a/locales/en/translation.json b/locales/en/translation.json index f22bd1ef..564bb859 100644 --- a/locales/en/translation.json +++ b/locales/en/translation.json @@ -1419,7 +1419,8 @@ "invalidCharactersError": "Name and bio cannot contain the characters < > { } ` \\", "invalidReceiveAddressError": "Please enter a valid Lightning address (e.g. user@domain.com)", "aboutYou": "About you", - "lightningAddress": "Lightning Address" + "lightningAddress": "Lightning Address", + "addContactLightningAddress": "Lightning Address" }, "remotePaymentCurrencySelect": { "title": "Receive currency", diff --git a/locales/es/translation.json b/locales/es/translation.json index 4d5876ef..53af16a5 100644 --- a/locales/es/translation.json +++ b/locales/es/translation.json @@ -1419,7 +1419,8 @@ "invalidCharactersError": "El nombre y la biografía no pueden contener los caracteres < > { } ` \\", "invalidReceiveAddressError": "Introduce una dirección Lightning válida (p. ej., usuario@dominio.com)", "aboutYou": "Sobre ti", - "lightningAddress": "Dirección Lightning" + "lightningAddress": "Dirección Lightning", + "addContactLightningAddress": "Dirección Lightning" }, "remotePaymentCurrencySelect": { "title": "Moneda de recepción", diff --git a/locales/fr/translation.json b/locales/fr/translation.json index 4ea051ff..bf399037 100644 --- a/locales/fr/translation.json +++ b/locales/fr/translation.json @@ -1419,7 +1419,8 @@ "invalidCharactersError": "Le nom et la bio ne peuvent pas contenir les caractères < > { } ` \\", "invalidReceiveAddressError": "Veuillez saisir une adresse Lightning valide (p. ex. utilisateur@domaine.com)", "aboutYou": "À propos de vous", - "lightningAddress": "Adresse Lightning" + "lightningAddress": "Adresse Lightning", + "addContactLightningAddress": "Adresse Lightning" }, "remotePaymentCurrencySelect": { "title": "Devise de réception", diff --git a/locales/it/translation.json b/locales/it/translation.json index 6b3b3469..f63c5c85 100644 --- a/locales/it/translation.json +++ b/locales/it/translation.json @@ -1419,7 +1419,8 @@ "invalidCharactersError": "Nome e bio non possono contenere i caratteri < > { } ` \\", "invalidReceiveAddressError": "Inserisci un indirizzo Lightning valido (es. utente@dominio.com)", "aboutYou": "Su di te", - "lightningAddress": "Indirizzo Lightning" + "lightningAddress": "Indirizzo Lightning", + "addContactLightningAddress": "Indirizzo Lightning" }, "remotePaymentCurrencySelect": { "title": "Valuta di ricezione", diff --git a/locales/pt-BR/translation.json b/locales/pt-BR/translation.json index 5e7f7074..e0885b8f 100644 --- a/locales/pt-BR/translation.json +++ b/locales/pt-BR/translation.json @@ -1418,7 +1418,8 @@ "invalidCharactersError": "O nome e a bio não podem conter os caracteres < > { } ` \\", "invalidReceiveAddressError": "Digite um endereço de pagamento válido (ex.: usuario@dominio.com)", "aboutYou": "Sobre você", - "lightningAddress": "Endereço Blitz" + "lightningAddress": "Endereço Blitz", + "addContactLightningAddress": "Endereço Lightning" }, "remotePaymentCurrencySelect": { "title": "Moeda de recebimento", diff --git a/locales/ru/translation.json b/locales/ru/translation.json index 829af36a..15b809e5 100644 --- a/locales/ru/translation.json +++ b/locales/ru/translation.json @@ -1420,7 +1420,8 @@ "invalidCharactersError": "Имя и био не могут содержать символы < > { } ` \\", "invalidReceiveAddressError": "Введите корректный адрес Молнии (например, user@domain.com)", "aboutYou": "О вас", - "lightningAddress": "Lightning-адрес" + "lightningAddress": "Lightning-адрес", + "addContactLightningAddress": "Lightning-адрес" }, "remotePaymentCurrencySelect": { "title": "Валюта получения", diff --git a/locales/sv/translation.json b/locales/sv/translation.json index da155a40..cb5e8c2a 100644 --- a/locales/sv/translation.json +++ b/locales/sv/translation.json @@ -1419,7 +1419,8 @@ "invalidCharactersError": "Namn och bio får inte innehålla tecknen < > { } ` \\", "invalidReceiveAddressError": "Ange en giltig Lightning-adress (t.ex. användare@domän.com)", "aboutYou": "Om dig", - "lightningAddress": "Lightning-adress" + "lightningAddress": "Lightning-adress", + "addContactLightningAddress": "Lightning-adress" }, "remotePaymentCurrencySelect": { "title": "Mottagningsvaluta",