11import { Str } from 'expensify-common' ;
2- import React , { useContext , useMemo } from 'react' ;
2+ import React , { useMemo } from 'react' ;
33import type { StyleProp , TextStyle } from 'react-native' ;
4- import { TNodeChildrenRenderer } from 'react-native-render-html' ;
54import type { CustomRendererProps , TBlock } from 'react-native-render-html' ;
5+ import { TNodeChildrenRenderer } from 'react-native-render-html' ;
66import AnchorForAttachmentsOnly from '@components/AnchorForAttachmentsOnly' ;
77import AnchorForCommentsOnly from '@components/AnchorForCommentsOnly' ;
88import * as HTMLEngineUtils from '@components/HTMLEngineProvider/htmlEngineUtils' ;
9- import { ShowContextMenuContext } from '@components/ShowContextMenuContext' ;
109import Text from '@components/Text' ;
11- import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
1210import useEnvironment from '@hooks/useEnvironment' ;
1311import useHover from '@hooks/useHover' ;
14- import useOnyx from '@hooks/useOnyx' ;
15- import useParentReport from '@hooks/useParentReport' ;
16- import useReportIsArchived from '@hooks/useReportIsArchived' ;
1712import useStyleUtils from '@hooks/useStyleUtils' ;
1813import useTheme from '@hooks/useTheme' ;
1914import useThemeStyles from '@hooks/useThemeStyles' ;
20- import { getInternalExpensifyPath , getInternalNewExpensifyPath , openExternalLink , openLink } from '@libs/actions/Link' ;
21- import { isAnonymousUser } from '@libs/actions/Session' ;
22- import { canActionTask , canModifyTask , completeTask } from '@libs/actions/Task' ;
23- import { setSelfTourViewed } from '@libs/actions/Welcome' ;
24- import { hasSeenTourSelector } from '@libs/onboardingSelectors' ;
25- import { getNavatticURL } from '@libs/TourUtils' ;
15+ import { getInternalExpensifyPath , getInternalNewExpensifyPath , openLink } from '@libs/actions/Link' ;
2616import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot' ;
2717import CONST from '@src/CONST' ;
28- import ONYXKEYS from '@src/ONYXKEYS' ;
2918
3019type AnchorRendererProps = CustomRendererProps < TBlock > & {
3120 /** Key of the element */
3221 key ?: string ;
3322} ;
3423
3524function AnchorRenderer ( { tnode, style, key} : AnchorRendererProps ) {
36- const currentUserPersonalDetails = useCurrentUserPersonalDetails ( ) ;
37- const { report, action} = useContext ( ShowContextMenuContext ) ;
38- const [ introSelected ] = useOnyx ( ONYXKEYS . NVP_INTRO_SELECTED , { canBeMissing : true } ) ;
39- const [ viewTourTaskReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ introSelected ?. viewTour } ` , { canBeMissing : true } ) ;
40- const [ hasSeenTour = false ] = useOnyx ( ONYXKEYS . NVP_ONBOARDING , {
41- selector : hasSeenTourSelector ,
42- canBeMissing : true ,
43- } ) ;
44- const parentReport = useParentReport ( report ?. reportID ) ;
45- const isParentReportArchived = useReportIsArchived ( parentReport ?. reportID ) ;
46- const canModifyViewTourTask = canModifyTask ( viewTourTaskReport , currentUserPersonalDetails . accountID , isParentReportArchived ) ;
47- const canActionViewTourTask = canActionTask ( viewTourTaskReport , currentUserPersonalDetails . accountID , parentReport , isParentReportArchived ) ;
48-
4925 const theme = useTheme ( ) ;
5026 const styles = useThemeStyles ( ) ;
5127 const StyleUtils = useStyleUtils ( ) ;
5228 const htmlAttribs = tnode . attributes ;
53- const { environment , environmentURL} = useEnvironment ( ) ;
29+ const { environmentURL} = useEnvironment ( ) ;
5430 const { hovered, bind} = useHover ( ) ;
5531 // An auth token is needed to download Expensify chat attachments
5632 const isAttachment = ! ! htmlAttribs [ CONST . ATTACHMENT_SOURCE_ATTRIBUTE ] ;
@@ -68,26 +44,13 @@ function AnchorRenderer({tnode, style, key}: AnchorRendererProps) {
6844
6945 const textDecorationLineStyle = isDeleted ? styles . lineThrough : { } ;
7046
71- const isInConciergeTaskView = action ?. actionName === CONST . REPORT . ACTIONS . TYPE . CREATED && report ?. type === CONST . REPORT . TYPE . TASK && report . ownerAccountID === CONST . ACCOUNT_ID . CONCIERGE ;
72- const isTourTask = attrHref === getNavatticURL ( environment , introSelected ?. choice ) && ( action ?. actorAccountID === CONST . ACCOUNT_ID . CONCIERGE || isInConciergeTaskView ) ;
73-
7447 const onLinkPress = useMemo ( ( ) => {
7548 if ( internalNewExpensifyPath || internalExpensifyPath ) {
7649 return ( ) => openLink ( attrHref , environmentURL , isAttachment ) ;
7750 }
7851
79- if ( isTourTask && ! hasSeenTour ) {
80- return ( ) => {
81- openExternalLink ( attrHref ) ;
82- setSelfTourViewed ( isAnonymousUser ( ) ) ;
83- if ( viewTourTaskReport && canModifyViewTourTask && canActionViewTourTask ) {
84- completeTask ( viewTourTaskReport ) ;
85- }
86- } ;
87- }
88-
8952 return undefined ;
90- } , [ internalNewExpensifyPath , internalExpensifyPath , attrHref , environmentURL , isAttachment , isTourTask , hasSeenTour , viewTourTaskReport , canModifyViewTourTask , canActionViewTourTask ] ) ;
53+ } , [ internalNewExpensifyPath , internalExpensifyPath , attrHref , environmentURL , isAttachment ] ) ;
9154
9255 if ( ! HTMLEngineUtils . isChildOfComment ( tnode ) && ! isChildOfTaskTitle ) {
9356 // This is not a comment from a chat, the AnchorForCommentsOnly uses a Pressable to create a context menu on right click.
0 commit comments