Skip to content

Commit

Permalink
globalfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodebrute committed Aug 16, 2023
1 parent 947d376 commit 49f9042
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -59,7 +58,7 @@ function AnchorRenderer(props) {
Link.openOldDotLink(internalExpensifyPath);
return;
}
Linking.openURL(attrHref);
Link.openExternalLink(attrHref);
};

if (!HTMLEngineUtils.isInsideComment(props.tnode)) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/TextLink.js
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -49,7 +49,7 @@ function TextLink(props) {
return;
}

Linking.openURL(props.href);
Link.openExternalLink(props.href);
};

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
28 changes: 13 additions & 15 deletions src/libs/actions/Link.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}

Expand All @@ -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};
4 changes: 2 additions & 2 deletions src/libs/fileDownload/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/pages/GetAssistancePage.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/pages/ReimbursementAccount/BankAccountStep.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -148,7 +149,7 @@ function BankAccountStep(props) {
<View style={[styles.mv0, styles.mh5, styles.flexRow, styles.justifyContentBetween]}>
<TextLink href="https://use.expensify.com/privacy">{props.translate('common.privacy')}</TextLink>
<PressableWithoutFeedback
onPress={() => 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')}
>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/settings/Payments/AddPayPalMePage.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 */
Expand Down Expand Up @@ -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')}
>
<View style={[styles.flexRow, styles.cursorPointer]}>
<TextLink
Expand Down

0 comments on commit 49f9042

Please sign in to comment.