From 7465c122735c12a5c348591b058cd8a4707a02bd Mon Sep 17 00:00:00 2001 From: mateusbra Date: Mon, 25 Apr 2022 16:09:28 -0300 Subject: [PATCH 1/3] open old dot links with openOldDotLink() function --- .../HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js index e768e59bbf98..3348ae10f2ba 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js @@ -8,9 +8,11 @@ import htmlRendererPropTypes from './htmlRendererPropTypes'; import * as HTMLEngineUtils from '../htmlEngineUtils'; import Text from '../../Text'; import CONST from '../../../CONST'; +import CONFIG from '../../../CONFIG'; import styles from '../../../styles/styles'; import Navigation from '../../../libs/Navigation/Navigation'; import AnchorForCommentsOnly from '../../AnchorForCommentsOnly'; +import * as Link from '../../../libs/actions/Link'; const AnchorRenderer = (props) => { const htmlAttribs = props.tnode.attributes; @@ -22,14 +24,15 @@ const AnchorRenderer = (props) => { const attrHref = htmlAttribs.href || ''; const internalExpensifyPath = (attrHref.startsWith(CONST.NEW_EXPENSIFY_URL) && attrHref.replace(CONST.NEW_EXPENSIFY_URL, '')) || (attrHref.startsWith(CONST.STAGING_NEW_EXPENSIFY_URL) && attrHref.replace(CONST.STAGING_NEW_EXPENSIFY_URL, '')); + const oldDotPath = attrHref.startsWith(CONFIG.EXPENSIFY.EXPENSIFY_URL) && attrHref.replace(CONFIG.EXPENSIFY.EXPENSIFY_URL, ''); // If we are handling a New Expensify link then we will assume this should be opened by the app internally. This ensures that the links are opened internally via react-navigation // instead of in a new tab or with a page refresh (which is the default behavior of an anchor tag) - if (internalExpensifyPath) { + if (internalExpensifyPath || oldDotPath) { return ( Navigation.navigate(internalExpensifyPath)} + onPress={() => (internalExpensifyPath ? Navigation.navigate(internalExpensifyPath) : Link.openOldDotLink(oldDotPath))} > From 3a41612a8d6835d99e32b477c1642fba8fe0ca1f Mon Sep 17 00:00:00 2001 From: mateusbra Date: Wed, 27 Apr 2022 01:57:07 -0300 Subject: [PATCH 2/3] change variable names --- .../HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js index 3348ae10f2ba..77f426a0d5a5 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js @@ -22,17 +22,17 @@ const AnchorRenderer = (props) => { const displayName = lodashGet(props.tnode, 'domNode.children[0].data', ''); const parentStyle = lodashGet(props.tnode, 'parent.styles.nativeTextRet', {}); const attrHref = htmlAttribs.href || ''; - const internalExpensifyPath = (attrHref.startsWith(CONST.NEW_EXPENSIFY_URL) && attrHref.replace(CONST.NEW_EXPENSIFY_URL, '')) + const internalNewExpensifyPath = (attrHref.startsWith(CONST.NEW_EXPENSIFY_URL) && attrHref.replace(CONST.NEW_EXPENSIFY_URL, '')) || (attrHref.startsWith(CONST.STAGING_NEW_EXPENSIFY_URL) && attrHref.replace(CONST.STAGING_NEW_EXPENSIFY_URL, '')); - const oldDotPath = attrHref.startsWith(CONFIG.EXPENSIFY.EXPENSIFY_URL) && attrHref.replace(CONFIG.EXPENSIFY.EXPENSIFY_URL, ''); + const internalExpensifyPath = attrHref.startsWith(CONFIG.EXPENSIFY.EXPENSIFY_URL) && attrHref.replace(CONFIG.EXPENSIFY.EXPENSIFY_URL, ''); // If we are handling a New Expensify link then we will assume this should be opened by the app internally. This ensures that the links are opened internally via react-navigation // instead of in a new tab or with a page refresh (which is the default behavior of an anchor tag) - if (internalExpensifyPath || oldDotPath) { + if (internalNewExpensifyPath || internalExpensifyPath) { return ( (internalExpensifyPath ? Navigation.navigate(internalExpensifyPath) : Link.openOldDotLink(oldDotPath))} + onPress={() => (internalNewExpensifyPath ? Navigation.navigate(internalNewExpensifyPath) : Link.openOldDotLink(internalExpensifyPath))} > From d3fa8e03234db1f13fb2a2233fdf45418e7c9011 Mon Sep 17 00:00:00 2001 From: mateusbra Date: Wed, 27 Apr 2022 19:07:20 -0300 Subject: [PATCH 3/3] move internalExpensifyPath to it's own branch statement --- .../HTMLRenderers/AnchorRenderer.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js index 77f426a0d5a5..bf70adda9f07 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js @@ -28,11 +28,23 @@ const AnchorRenderer = (props) => { // If we are handling a New Expensify link then we will assume this should be opened by the app internally. This ensures that the links are opened internally via react-navigation // instead of in a new tab or with a page refresh (which is the default behavior of an anchor tag) - if (internalNewExpensifyPath || internalExpensifyPath) { + if (internalNewExpensifyPath) { return ( (internalNewExpensifyPath ? Navigation.navigate(internalNewExpensifyPath) : Link.openOldDotLink(internalExpensifyPath))} + onPress={() => Navigation.navigate(internalNewExpensifyPath)} + > + + + ); + } + + // If we are handling an old dot Expensify link we need to open it with openOldDotLink() so we can navigate to it with the user already logged in. + if (internalExpensifyPath) { + return ( + Link.openOldDotLink(internalExpensifyPath)} >