Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8349,6 +8349,7 @@ const CONST = {
},
HTML_RENDERER: {
IMAGE: 'HTMLRenderer-Image',
PRE: 'HTMLRenderer-Pre',
},
RECEIPT: {
IMAGE: 'Receipt-Image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import AttachmentView from '@components/Attachments/AttachmentView';
import {useSession} from '@components/OnyxListItemProvider';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import {ShowContextMenuContext, showContextMenuForReport} from '@components/ShowContextMenuContext';
import {showContextMenuForReport, useShowContextMenuActions, useShowContextMenuState} from '@components/ShowContextMenuContext';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -39,45 +39,44 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
const sourceURLWithAuth = addEncryptedAuthTokenToURL(source, encryptedAuthToken);

const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu} = useShowContextMenuState();
const {checkIfContextMenuActive} = useShowContextMenuActions();

return (
<ShowContextMenuContext.Consumer>
{({anchor, report, isReportArchived, action, checkIfContextMenuActive, isDisabled, shouldDisplayContextMenu}) => (
<PressableWithoutFeedback
style={[style, (isOffline || !sourceID) && styles.cursorDefault]}
onPress={() => {
if (isDownloading || isOffline || !sourceID) {
return;
}
setDownload(sourceID, true);
fileDownload(translate, sourceURLWithAuth, displayName, '', isMobileSafari()).then(() => setDownload(sourceID, false));
}}
onPressIn={onPressIn}
onPressOut={onPressOut}
onLongPress={(event) => {
if (isDisabled || !shouldDisplayContextMenu) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived));
}}
shouldUseHapticsOnLongPress
accessibilityLabel={displayName}
role={CONST.ROLE.BUTTON}
sentryLabel={CONST.SENTRY_LABEL.BASE_ANCHOR_FOR_ATTACHMENTS_ONLY.DOWNLOAD_BUTTON}
>
<AttachmentView
source={source}
file={{name: displayName}}
shouldShowDownloadIcon={!!sourceID && !isOffline}
shouldShowLoadingSpinnerIcon={isDownloading}
isUsedAsChatAttachment
isDeleted={!!isDeleted}
isUploading={!sourceID}
isAuthTokenRequired={!!sourceID}
isUploaded={!isEmptyObject(report)}
/>
</PressableWithoutFeedback>
)}
</ShowContextMenuContext.Consumer>
<PressableWithoutFeedback
style={[style, (isOffline || !sourceID) && styles.cursorDefault]}
onPress={() => {
if (isDownloading || isOffline || !sourceID) {
return;
}
setDownload(sourceID, true);
fileDownload(translate, sourceURLWithAuth, displayName, '', isMobileSafari()).then(() => setDownload(sourceID, false));
}}
onPressIn={onPressIn}
onPressOut={onPressOut}
onLongPress={(event) => {
if (isDisabled || !shouldDisplayContextMenu) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived));
}}
shouldUseHapticsOnLongPress
accessibilityLabel={displayName}
role={CONST.ROLE.BUTTON}
sentryLabel={CONST.SENTRY_LABEL.BASE_ANCHOR_FOR_ATTACHMENTS_ONLY.DOWNLOAD_BUTTON}
>
<AttachmentView
source={source}
file={{name: displayName}}
shouldShowDownloadIcon={!!sourceID && !isOffline}
shouldShowLoadingSpinnerIcon={isDownloading}
isUsedAsChatAttachment
isDeleted={!!isDeleted}
isUploading={!sourceID}
isAuthTokenRequired={!!sourceID}
isUploaded={!isEmptyObject(report)}
/>
</PressableWithoutFeedback>
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/ConnectToNetSuiteFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import {isAuthenticationError} from '@libs/actions/connections';
import {getAdminPoliciesConnectedToNetSuite} from '@libs/actions/Policy/Policy';
import Navigation from '@libs/Navigation/Navigation';
import {useAccountingContext} from '@pages/workspace/accounting/AccountingContext';
import {useAccountingState} from '@pages/workspace/accounting/AccountingContext';
import {getInitialSubPageForNetsuiteTokenInput} from '@pages/workspace/accounting/netsuite/utils';
import type {AnchorPosition} from '@styles/index';
import CONST from '@src/CONST';
Expand All @@ -26,7 +26,7 @@ function ConnectToNetSuiteFlow({policyID}: ConnectToNetSuiteFlowProps) {

const [isReuseConnectionsPopoverOpen, setIsReuseConnectionsPopoverOpen] = useState(false);
const [reuseConnectionPopoverPosition, setReuseConnectionPopoverPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0});
const {popoverAnchorRefs} = useAccountingContext();
const {popoverAnchorRefs} = useAccountingState();

const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const icons = useMemoizedLazyExpensifyIcons(['Copy', 'LinkCopy'] as const);
Expand Down
85 changes: 42 additions & 43 deletions src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {AttachmentContext} from '@components/AttachmentContext';
import {getButtonRole} from '@components/Button/utils';
import {isDeletedNode} from '@components/HTMLEngineProvider/htmlEngineUtils';
import PressableWithoutFocus from '@components/Pressable/PressableWithoutFocus';
import {ShowContextMenuContext, showContextMenuForReport} from '@components/ShowContextMenuContext';
import {showContextMenuForReport, useShowContextMenuActions, useShowContextMenuState} from '@components/ShowContextMenuContext';
import ThumbnailImage from '@components/ThumbnailImage';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -90,53 +90,52 @@ function ImageRenderer({tnode}: CustomRendererProps<TBlock>) {
/>
);

const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu} = useShowContextMenuState();
const {onShowContextMenu, checkIfContextMenuActive} = useShowContextMenuActions();

return imagePreviewModalDisabled ? (
thumbnailImageComponent
) : (
<ShowContextMenuContext.Consumer>
{({onShowContextMenu, anchor, report, isReportArchived, action, checkIfContextMenuActive, isDisabled, shouldDisplayContextMenu}) => (
<AttachmentContext.Consumer>
{({reportID, accountID, type}) => (
<PressableWithoutFocus
style={[styles.noOutline]}
onPress={() => {
if (!source || !type) {
return;
}
<AttachmentContext.Consumer>
{({reportID, accountID, type}) => (
<PressableWithoutFocus
style={[styles.noOutline]}
onPress={() => {
if (!source || !type) {
return;
}

const attachmentLink = tnode.parent?.attributes?.href;
const route = ROUTES.REPORT_ATTACHMENTS?.getRoute({
attachmentID,
reportID,
type,
source,
accountID,
isAuthTokenRequired: isAttachmentOrReceipt,
originalFileName: fileName,
attachmentLink,
});
Navigation.navigate(route);
}}
onLongPress={(event) => {
if (isDisabled || !shouldDisplayContextMenu) {
return;
}
return onShowContextMenu(() =>
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived)),
);
}}
isNested
shouldUseHapticsOnLongPress
role={getButtonRole(true)}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
sentryLabel={CONST.SENTRY_LABEL.HTML_RENDERER.IMAGE}
>
{thumbnailImageComponent}
</PressableWithoutFocus>
)}
</AttachmentContext.Consumer>
const attachmentLink = tnode.parent?.attributes?.href;
const route = ROUTES.REPORT_ATTACHMENTS?.getRoute({
attachmentID,
reportID,
type,
source,
accountID,
isAuthTokenRequired: isAttachmentOrReceipt,
originalFileName: fileName,
attachmentLink,
});
Navigation.navigate(route);
}}
onLongPress={(event) => {
if (isDisabled || !shouldDisplayContextMenu) {
return;
}
return onShowContextMenu(() =>
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived)),
);
}}
isNested
shouldUseHapticsOnLongPress
role={getButtonRole(true)}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
sentryLabel={CONST.SENTRY_LABEL.HTML_RENDERER.IMAGE}
>
{thumbnailImageComponent}
</PressableWithoutFocus>
)}
</ShowContextMenuContext.Consumer>
</AttachmentContext.Consumer>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {useContext, useMemo} from 'react';
import type {TextStyle} from 'react-native';
import {StyleSheet} from 'react-native';
import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html';
import {ShowContextMenuContext} from '@components/ShowContextMenuContext';
import Text from '@components/Text';
import {useCurrentReportIDState} from '@hooks/useCurrentReportID';
import useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -52,32 +51,28 @@ function MentionReportRenderer({style, tnode, TDefaultRenderer, ...defaultRender
const {color, ...styleWithoutColor} = flattenStyle;

return (
<ShowContextMenuContext.Consumer>
{() => (
<Text
// eslint-disable-next-line react/jsx-props-no-spreading
{...defaultRendererProps}
style={
isGroupPolicyReport && (!exactlyMatch || navigationRoute)
? [styles.link, styleWithoutColor, StyleUtils.getMentionStyle(isCurrentRoomMention), {color: StyleUtils.getMentionTextColor(isCurrentRoomMention)}]
: [flattenStyle]
}
suppressHighlighting
onPress={
navigationRoute && isGroupPolicyReport
? (event) => {
event.preventDefault();
Navigation.navigate(navigationRoute);
}
: undefined
}
role={isGroupPolicyReport ? CONST.ROLE.LINK : undefined}
accessibilityLabel={isGroupPolicyReport ? `/${navigationRoute}` : undefined}
>
#{mentionDisplayText}
</Text>
)}
</ShowContextMenuContext.Consumer>
<Text
// eslint-disable-next-line react/jsx-props-no-spreading
{...defaultRendererProps}
style={
isGroupPolicyReport && (!exactlyMatch || navigationRoute)
? [styles.link, styleWithoutColor, StyleUtils.getMentionStyle(isCurrentRoomMention), {color: StyleUtils.getMentionTextColor(isCurrentRoomMention)}]
: [flattenStyle]
}
suppressHighlighting
onPress={
navigationRoute && isGroupPolicyReport
? (event) => {
event.preventDefault();
Navigation.navigate(navigationRoute);
}
: undefined
}
role={isGroupPolicyReport ? CONST.ROLE.LINK : undefined}
accessibilityLabel={isGroupPolicyReport ? `/${navigationRoute}` : undefined}
>
#{mentionDisplayText}
</Text>
);
}

Expand Down
Loading
Loading