From d4f2e9f75d0dcfd5d2b2c359837f1adbe1a26dca Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 2 Feb 2024 04:25:28 +0530 Subject: [PATCH 1/2] fixes crash on long press expensify classic option --- src/pages/settings/InitialSettingsPage.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index dfa4262549fc..3997fe0bec75 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -171,7 +171,7 @@ function InitialSettingsPage(props) { action: () => { Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX); }, - link: Link.buildOldDotURL(CONST.OLDDOT_URLS.INBOX), + link: () => Link.buildOldDotURL(CONST.OLDDOT_URLS.INBOX), }, { translationKey: 'initialSettingsPage.signOut', @@ -225,6 +225,15 @@ function InitialSettingsPage(props) { * @returns {String|undefined} the user's wallet balance */ const getWalletBalance = (isPaymentItem) => (isPaymentItem ? CurrencyUtils.convertToDisplayString(props.userWallet.currentBalance) : undefined); + + const onSecondaryInteraction = (link, event) => { + if (typeof link === 'function') { + link().then((url) => ReportActionContextMenu.showContextMenu(CONST.CONTEXT_MENU_TYPES.LINK, event, url, popoverAnchor.current)); + } else if (link) { + ReportActionContextMenu.showContextMenu(CONST.CONTEXT_MENU_TYPES.LINK, event, link, popoverAnchor.current); + } + }; + return ( {translate(menuItemsData.sectionTranslationKey)} @@ -259,9 +268,7 @@ function InitialSettingsPage(props) { ref={popoverAnchor} hoverAndPressStyle={styles.hoveredComponentBG} shouldBlockSelection={Boolean(item.link)} - onSecondaryInteraction={ - !_.isEmpty(item.link) ? (e) => ReportActionContextMenu.showContextMenu(CONST.CONTEXT_MENU_TYPES.LINK, e, item.link, popoverAnchor.current) : undefined - } + onSecondaryInteraction={item.link ? (event) => onSecondaryInteraction(item.link, event) : undefined} focused={activeRoute && item.routeName && activeRoute.toLowerCase().replaceAll('_', '') === item.routeName.toLowerCase().replaceAll('/', '')} isPaneMenu /> From ff3aee9ce7f6b38b94ebb97277da3f4a0e048ef8 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 2 Feb 2024 04:43:20 +0530 Subject: [PATCH 2/2] fixes variable naming --- src/pages/settings/InitialSettingsPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index 3997fe0bec75..8dfce10fc081 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -226,7 +226,7 @@ function InitialSettingsPage(props) { */ const getWalletBalance = (isPaymentItem) => (isPaymentItem ? CurrencyUtils.convertToDisplayString(props.userWallet.currentBalance) : undefined); - const onSecondaryInteraction = (link, event) => { + const openPopover = (link, event) => { if (typeof link === 'function') { link().then((url) => ReportActionContextMenu.showContextMenu(CONST.CONTEXT_MENU_TYPES.LINK, event, url, popoverAnchor.current)); } else if (link) { @@ -268,7 +268,7 @@ function InitialSettingsPage(props) { ref={popoverAnchor} hoverAndPressStyle={styles.hoveredComponentBG} shouldBlockSelection={Boolean(item.link)} - onSecondaryInteraction={item.link ? (event) => onSecondaryInteraction(item.link, event) : undefined} + onSecondaryInteraction={item.link ? (event) => openPopover(item.link, event) : undefined} focused={activeRoute && item.routeName && activeRoute.toLowerCase().replaceAll('_', '') === item.routeName.toLowerCase().replaceAll('/', '')} isPaneMenu />