From 2bbcceb27f246c4bfb4afdf8db3bfb8a1b228ab4 Mon Sep 17 00:00:00 2001 From: Anusha Date: Mon, 14 Aug 2023 23:01:55 +0500 Subject: [PATCH 1/4] link config --- .../VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js b/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js index e987e67143d6..3ab57a0b2778 100755 --- a/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js +++ b/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js @@ -18,6 +18,7 @@ import Tooltip from '../Tooltip'; import {propTypes as videoChatButtonAndMenuPropTypes, defaultProps} from './videoChatButtonAndMenuPropTypes'; import * as Session from '../../libs/actions/Session'; import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback'; +import * as Link from '../../libs/actions/Link'; const propTypes = { /** Link to open when user wants to create a new google meet meeting */ @@ -40,7 +41,7 @@ function BaseVideoChatButtonAndMenu(props) { text: props.translate('videoChatButtonAndMenu.zoom'), onPress: () => { setIsVideoChatMenuActive(false); - Linking.openURL(CONST.NEW_ZOOM_MEETING_URL); + Link.openExternalLink(CONST.NEW_ZOOM_MEETING_URL); }, }, { @@ -48,7 +49,7 @@ function BaseVideoChatButtonAndMenu(props) { text: props.translate('videoChatButtonAndMenu.googleMeet'), onPress: () => { setIsVideoChatMenuActive(false); - Linking.openURL(props.googleMeetURL); + Link.openExternalLink(props.googleMeetURL); }, }, ]; From 947d3765ec9f62b7d70a2ccc0f5b32616d73737f Mon Sep 17 00:00:00 2001 From: Anusha Date: Mon, 14 Aug 2023 23:46:11 +0500 Subject: [PATCH 2/4] npm run prettier --- .../VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js b/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js index 3ab57a0b2778..94f32eca4485 100755 --- a/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js +++ b/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js @@ -18,7 +18,7 @@ import Tooltip from '../Tooltip'; import {propTypes as videoChatButtonAndMenuPropTypes, defaultProps} from './videoChatButtonAndMenuPropTypes'; import * as Session from '../../libs/actions/Session'; import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback'; -import * as Link from '../../libs/actions/Link'; +import * as Link from '../../libs/actions/Link'; const propTypes = { /** Link to open when user wants to create a new google meet meeting */ From 49f9042123b0fca2dae37f7ca325e3bfbbf023aa Mon Sep 17 00:00:00 2001 From: Anusha Date: Wed, 16 Aug 2023 14:41:22 +0500 Subject: [PATCH 3/4] globalfix --- .../HTMLRenderers/AnchorRenderer.js | 3 +- src/components/TextLink.js | 4 +-- .../BaseVideoChatButtonAndMenu.js | 4 +-- src/libs/actions/Link.js | 28 +++++++++---------- src/libs/fileDownload/index.js | 4 +-- src/pages/GetAssistancePage.js | 4 +-- .../ReimbursementAccount/BankAccountStep.js | 5 ++-- .../settings/Payments/AddPayPalMePage.js | 5 ++-- 8 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js index 1cc0acf50926..ba0d50a525fe 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js @@ -1,5 +1,4 @@ import React from 'react'; -import {Linking} from 'react-native'; import {TNodeChildrenRenderer} from 'react-native-render-html'; import lodashGet from 'lodash/get'; import htmlRendererPropTypes from './htmlRendererPropTypes'; @@ -59,7 +58,7 @@ function AnchorRenderer(props) { Link.openOldDotLink(internalExpensifyPath); return; } - Linking.openURL(attrHref); + Link.openExternalLink(attrHref); }; if (!HTMLEngineUtils.isInsideComment(props.tnode)) { diff --git a/src/components/TextLink.js b/src/components/TextLink.js index 966c49ddbffe..307a4331ef1d 100644 --- a/src/components/TextLink.js +++ b/src/components/TextLink.js @@ -1,11 +1,11 @@ import _ from 'underscore'; import React from 'react'; import PropTypes from 'prop-types'; -import {Linking} from 'react-native'; import Text from './Text'; import styles from '../styles/styles'; import stylePropTypes from '../styles/stylePropTypes'; import CONST from '../CONST'; +import * as Link from '../libs/actions/Link'; const propTypes = { /** Link to open in new tab */ @@ -49,7 +49,7 @@ function TextLink(props) { return; } - Linking.openURL(props.href); + Link.openExternalLink(props.href); }; /** diff --git a/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js b/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js index 94f32eca4485..d89c9bc7a953 100755 --- a/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js +++ b/src/components/VideoChatButtonAndMenu/BaseVideoChatButtonAndMenu.js @@ -1,6 +1,6 @@ import _ from 'underscore'; import React, {useState, useRef, useEffect, useCallback} from 'react'; -import {View, Dimensions, Linking} from 'react-native'; +import {View, Dimensions} from 'react-native'; import PropTypes from 'prop-types'; import Icon from '../Icon'; import * as Expensicons from '../Icon/Expensicons'; @@ -94,7 +94,7 @@ function BaseVideoChatButtonAndMenu(props) { // If this is the Concierge chat, we'll open the modal for requesting a setup call instead if (props.isConcierge && props.guideCalendarLink) { - Linking.openURL(props.guideCalendarLink); + Link.openExternalLink(props.guideCalendarLink); return; } setIsVideoChatMenuActive((previousVal) => !previousVal); diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index b920cb1c7ee6..575a4f8a1cc5 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -1,6 +1,5 @@ import Onyx from 'react-native-onyx'; import lodashGet from 'lodash/get'; -import {Linking} from 'react-native'; import _ from 'underscore'; import ONYXKEYS from '../../ONYXKEYS'; import Growl from '../Growl'; @@ -56,12 +55,24 @@ function buildOldDotURL(url, shortLivedAuthToken) { }); } +/** + * @param {String} url + * @param {Boolean} shouldSkipCustomSafariLogic When true, we will use `Linking.openURL` even if the browser is Safari. + */ +function openExternalLink(url, shouldSkipCustomSafariLogic = false) { + if (showGrowlIfOffline()) { + return; + } + + asyncOpenURL(Promise.resolve(), url, shouldSkipCustomSafariLogic); +} + /** * @param {String} url the url path */ function openOldDotLink(url) { if (isNetworkOffline) { - buildOldDotURL(url).then((oldDotURL) => Linking.openURL(oldDotURL)); + buildOldDotURL(url).then((oldDotURL) => openExternalLink(oldDotURL)); return; } @@ -74,17 +85,4 @@ function openOldDotLink(url) { (oldDotURL) => oldDotURL, ); } - -/** - * @param {String} url - * @param {Boolean} shouldSkipCustomSafariLogic When true, we will use `Linking.openURL` even if the browser is Safari. - */ -function openExternalLink(url, shouldSkipCustomSafariLogic = false) { - if (showGrowlIfOffline()) { - return; - } - - asyncOpenURL(Promise.resolve(), url, shouldSkipCustomSafariLogic); -} - export {buildOldDotURL, openOldDotLink, openExternalLink}; diff --git a/src/libs/fileDownload/index.js b/src/libs/fileDownload/index.js index 712a6ca2affb..a775576eb365 100644 --- a/src/libs/fileDownload/index.js +++ b/src/libs/fileDownload/index.js @@ -1,5 +1,5 @@ -import {Linking} from 'react-native'; import * as FileUtils from './FileUtils'; +import * as Link from '../actions/Link'; /** * Downloading attachment in web, desktop @@ -39,7 +39,7 @@ export default function fileDownload(url, fileName) { }) .catch(() => { // file could not be downloaded, open sourceURL in new tab - Linking.openURL(url); + Link.openExternalLink(url); return resolve(); }); }); diff --git a/src/pages/GetAssistancePage.js b/src/pages/GetAssistancePage.js index 6281b8cd769f..34f996936654 100644 --- a/src/pages/GetAssistancePage.js +++ b/src/pages/GetAssistancePage.js @@ -1,5 +1,5 @@ import React from 'react'; -import {View, ScrollView, Linking} from 'react-native'; +import {View, ScrollView} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; @@ -68,7 +68,7 @@ function GetAssistancePage(props) { if (guideCalendarLink) { menuItems.splice(1, 0, { title: props.translate('getAssistancePage.scheduleSetupCall'), - onPress: () => Linking.openURL(guideCalendarLink), + onPress: () => Link.openExternalLink(guideCalendarLink), icon: Expensicons.Phone, shouldShowRightIcon: true, iconRight: Expensicons.NewWindow, diff --git a/src/pages/ReimbursementAccount/BankAccountStep.js b/src/pages/ReimbursementAccount/BankAccountStep.js index 9617fbf46419..a9171157eac0 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.js +++ b/src/pages/ReimbursementAccount/BankAccountStep.js @@ -1,5 +1,5 @@ import React from 'react'; -import {View, ScrollView, Linking} from 'react-native'; +import {View, ScrollView} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; @@ -27,6 +27,7 @@ import Button from '../../components/Button'; import ScreenWrapper from '../../components/ScreenWrapper'; import StepPropTypes from './StepPropTypes'; import PressableWithoutFeedback from '../../components/Pressable/PressableWithoutFeedback'; +import * as Link from '../../libs/actions/Link'; const propTypes = { ...StepPropTypes, @@ -148,7 +149,7 @@ function BankAccountStep(props) { {props.translate('common.privacy')} Linking.openURL('https://community.expensify.com/discussion/5677/deep-dive-how-expensify-protects-your-information/')} + onPress={() => Link.openExternalLink('https://community.expensify.com/discussion/5677/deep-dive-how-expensify-protects-your-information/')} style={[styles.flexRow, styles.alignItemsCenter]} accessibilityLabel={props.translate('bankAccount.yourDataIsSecure')} > diff --git a/src/pages/settings/Payments/AddPayPalMePage.js b/src/pages/settings/Payments/AddPayPalMePage.js index f21362875dcb..89399d8b0bf7 100644 --- a/src/pages/settings/Payments/AddPayPalMePage.js +++ b/src/pages/settings/Payments/AddPayPalMePage.js @@ -1,5 +1,5 @@ import React, {useRef, useCallback} from 'react'; -import {View, Linking} from 'react-native'; +import {View} from 'react-native'; import _ from 'underscore'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; @@ -24,6 +24,7 @@ import * as Expensicons from '../../../components/Icon/Expensicons'; import variables from '../../../styles/variables'; import PressableWithoutFeedback from '../../../components/Pressable/PressableWithoutFeedback'; import paypalMeDataPropTypes from '../../../components/paypalMeDataPropTypes'; +import * as Link from '../../../libs/actions/Link'; const propTypes = { /** Account details for PayPal.Me */ @@ -97,7 +98,7 @@ function AddPayPalMePage(props) { shouldUseAutoHitSlop={false} accessibilityRole={CONST.ACCESSIBILITY_ROLE.LINK} accessibilityLabel={props.translate('addPayPalMePage.supportedCurrencies')} - onPress={() => Linking.openURL('https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies')} + onPress={() => Link.openExternalLink('https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies')} > Date: Thu, 17 Aug 2023 16:37:17 +0500 Subject: [PATCH 4/4] remove growl --- src/libs/actions/Link.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index 575a4f8a1cc5..06705182a626 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -2,9 +2,6 @@ import Onyx from 'react-native-onyx'; import lodashGet from 'lodash/get'; import _ from 'underscore'; import ONYXKEYS from '../../ONYXKEYS'; -import Growl from '../Growl'; -import * as Localize from '../Localize'; -import CONST from '../../CONST'; import asyncOpenURL from '../asyncOpenURL'; import * as API from '../API'; import * as Environment from '../Environment/Environment'; @@ -22,16 +19,6 @@ Onyx.connect({ callback: (val) => (currentUserEmail = lodashGet(val, 'email', '')), }); -/** - * @returns {Boolean} - */ -function showGrowlIfOffline() { - if (isNetworkOffline) { - Growl.show(Localize.translateLocal('session.offlineMessageRetry'), CONST.GROWL.WARNING); - } - return isNetworkOffline; -} - /** * @param {String} [url] the url path * @param {String} [shortLivedAuthToken] @@ -60,10 +47,6 @@ function buildOldDotURL(url, shortLivedAuthToken) { * @param {Boolean} shouldSkipCustomSafariLogic When true, we will use `Linking.openURL` even if the browser is Safari. */ function openExternalLink(url, shouldSkipCustomSafariLogic = false) { - if (showGrowlIfOffline()) { - return; - } - asyncOpenURL(Promise.resolve(), url, shouldSkipCustomSafariLogic); }