-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add feature to delete unverified contact methods #54784
Changes from 4 commits
0a78fbe
a88ac96
c50cfc5
715d047
874605e
9ccb8bf
dedbbfd
32da5c6
5413f30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import useLocalize from '@hooks/useLocalize'; | |
import usePrevious from '@hooks/usePrevious'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import blurActiveElement from '@libs/Accessibility/blurActiveElement'; | ||
import {canUseTouchScreen} from '@libs/DeviceCapabilities'; | ||
import * as ErrorUtils from '@libs/ErrorUtils'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
|
@@ -177,6 +178,24 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) { | |
const isFailedAddContactMethod = !!loginData.errorFields?.addedLogin; | ||
const isFailedRemovedContactMethod = !!loginData.errorFields?.deletedLogin; | ||
|
||
const getDeleteConfirmationModal = () => ( | ||
<ConfirmModal | ||
title={translate('contacts.removeContactMethod')} | ||
onConfirm={confirmDeleteAndHideModal} | ||
onCancel={() => toggleDeleteModal(false)} | ||
onModalHide={() => { | ||
InteractionManager.runAfterInteractions(() => { | ||
validateCodeFormRef.current?.focusLastSelected?.(); | ||
}); | ||
}} | ||
prompt={translate('contacts.removeAreYouSure')} | ||
confirmText={translate('common.yesContinue')} | ||
cancelText={translate('common.cancel')} | ||
isVisible={isDeleteModalOpen && !isDefaultContactMethod} | ||
danger | ||
/> | ||
); | ||
|
||
const getMenuItems = () => ( | ||
<> | ||
{canChangeDefaultContactMethod ? ( | ||
|
@@ -216,22 +235,7 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) { | |
/> | ||
</OfflineWithFeedback> | ||
)} | ||
|
||
<ConfirmModal | ||
title={translate('contacts.removeContactMethod')} | ||
onConfirm={confirmDeleteAndHideModal} | ||
onCancel={() => toggleDeleteModal(false)} | ||
onModalHide={() => { | ||
InteractionManager.runAfterInteractions(() => { | ||
validateCodeFormRef.current?.focusLastSelected?.(); | ||
}); | ||
}} | ||
prompt={translate('contacts.removeAreYouSure')} | ||
confirmText={translate('common.yesContinue')} | ||
cancelText={translate('common.cancel')} | ||
isVisible={isDeleteModalOpen && !isDefaultContactMethod} | ||
danger | ||
/> | ||
{getDeleteConfirmationModal()} | ||
</> | ||
); | ||
|
||
|
@@ -273,6 +277,16 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) { | |
}} | ||
sendValidateCode={() => User.requestContactMethodValidateCode(contactMethod)} | ||
descriptionPrimary={translate('contacts.enterMagicCode', {contactMethod: formattedContactMethod})} | ||
shouldShowThreeDotsButton={isValidateCodeActionModalVisible} | ||
onThreeDotsButtonPress={() => blurActiveElement()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you test it? There is no logic on native for this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I tested it. The keyboard hides automatically on native when the user clicks the three-dot menu, so there's no need to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I overlooked that after clicking the remove button. I applied |
||
threeDotsMenuItems={[ | ||
{ | ||
icon: Expensicons.Trashcan, | ||
text: translate('common.remove'), | ||
onSelected: () => toggleDeleteModal(true), | ||
}, | ||
]} | ||
footer={getDeleteConfirmationModal} | ||
/> | ||
|
||
{!isValidateCodeActionModalVisible && getMenuItems()} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the value of this prop be determined by the length of
threeDotsMenuItems
? ie. it should be TRUE when there are items in the array and FALSE when there are no items in the array? It seems unnecessary to have theshouldShowThreeDotsButton
prop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, I’ll update it based on threeDotsMenuItems.length as
shouldShowThreeDotsButton={threeDotsMenuItems.length>0}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgolen , after looking at it again, I realized that the three-dot menu only shows when the contact is not primary and not verified. If I use the
threeDotsMenuItems.length>0
, it would always show the button, so I guess we need this prop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. If I follow that logic though, if the menu is not shown, why would it need to have any menu items at all? I would say, remove the menu items based on
the contact is not primary and not verified
and it should still work the same. Right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we can do that as well.
I added the
shouldShowThreeDotsButton
prop because it was already available in the props for theThreeDotsMenu
andHeaderWithBackButton
It seems we could use the same logic there as well, but that would need to update the
threeDotsMenuItems
in different pages