diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 24ebc13139bc..40ac159c56b7 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -258,6 +258,19 @@ function clearContactMethodErrors(contactMethod, fieldName) { }); } +/** + * Resets the state indicating whether a validation code has been sent to a specific contact method. + * + * @param {String} contactMethod - The identifier of the contact method to reset. + */ +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, }; diff --git a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js index 579e2b962cee..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'], {});