From ae7d787ae374c2924c1377b3af2bab597d7c75c6 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 26 Jul 2023 06:46:26 +0700 Subject: [PATCH 1/5] Reset contact method validate code sent state when leave page --- .../settings/Profile/Contacts/ContactMethodDetailsPage.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js index 579e2b962cee..77aefacbdb34 100644 --- a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js +++ b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js @@ -116,6 +116,10 @@ class ContactMethodDetailsPage extends Component { } } + componentWillUnmount() { + User.resetContactMethodValidateCodeSentState(this.getContactMethod()); + } + /** * Gets the current contact method from the route params * @returns {string} From 5c9a8b26ac67ec12814414281bd25164099dcb06 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 26 Jul 2023 09:35:44 +0700 Subject: [PATCH 2/5] Add until to reset validate code sent state --- src/libs/actions/User.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 24ebc13139bc..8cab5810dd50 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -258,6 +258,19 @@ function clearContactMethodErrors(contactMethod, fieldName) { }); } +/** + * Reset validate code sent state on a contact method + * + * @param {String} contactMethod + */ +function resetContactMethodValidateCodeSentState(contactMethod) { + Onyx.merge(ONYXKEYS.LOGIN_LIST, { + [contactMethod]: { + validateCodeSent: false, + }, + }); +} + /** * Adds a secondary login to a user's account * @@ -827,4 +840,5 @@ export { updateChatPriorityMode, setContactMethodAsDefault, updateTheme, + resetContactMethodValidateCodeSentState, }; From 8459d74f10e2f12422e6e551eb3abb26bb0b704e Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 26 Jul 2023 22:37:39 +0700 Subject: [PATCH 3/5] Move logic to componentDidMount to handle kill app/browser --- .../settings/Profile/Contacts/ContactMethodDetailsPage.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js index 77aefacbdb34..852f86d744d0 100644 --- a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js +++ b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js @@ -105,6 +105,10 @@ class ContactMethodDetailsPage extends Component { }; } + componentDidMount() { + User.resetContactMethodValidateCodeSentState(this.getContactMethod()); + } + componentDidUpdate(prevProps) { const errorFields = lodashGet(this.props.loginList, [this.getContactMethod(), 'errorFields'], {}); const prevPendingFields = lodashGet(prevProps.loginList, [this.getContactMethod(), 'pendingFields'], {}); @@ -116,10 +120,6 @@ class ContactMethodDetailsPage extends Component { } } - componentWillUnmount() { - User.resetContactMethodValidateCodeSentState(this.getContactMethod()); - } - /** * Gets the current contact method from the route params * @returns {string} From 02e26d4e162dc659596b5ebb2c9d4392d9071f57 Mon Sep 17 00:00:00 2001 From: Vinh Hoang Date: Thu, 27 Jul 2023 06:31:26 +0700 Subject: [PATCH 4/5] Update comment text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Arkadiusz ChrabÄ…szczewski --- src/libs/actions/User.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 8cab5810dd50..30de42ae5747 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -259,7 +259,7 @@ function clearContactMethodErrors(contactMethod, fieldName) { } /** - * Reset validate code sent state on a contact method + * Resets the state indicating whether a validation code has been sent to a specific contact method. * * @param {String} contactMethod */ From 2fc60da81e91e915450b8349fa83c47ef55e866c Mon Sep 17 00:00:00 2001 From: Vinh Hoang Date: Thu, 27 Jul 2023 06:31:44 +0700 Subject: [PATCH 5/5] Update comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Arkadiusz ChrabÄ…szczewski --- src/libs/actions/User.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 30de42ae5747..40ac159c56b7 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -261,7 +261,7 @@ function clearContactMethodErrors(contactMethod, fieldName) { /** * Resets the state indicating whether a validation code has been sent to a specific contact method. * - * @param {String} contactMethod + * @param {String} contactMethod - The identifier of the contact method to reset. */ function resetContactMethodValidateCodeSentState(contactMethod) { Onyx.merge(ONYXKEYS.LOGIN_LIST, {