Skip to content

Commit

Permalink
Merge pull request #28114 from StevenKKC/fix26258
Browse files Browse the repository at this point in the history
  • Loading branch information
thienlnam authored Sep 27, 2023
2 parents 2f1e752 + 629cb53 commit 09a0118
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import useWindowDimensions from '../hooks/useWindowDimensions';
import Navigation from '../libs/Navigation/Navigation';
import ROUTES from '../ROUTES';
import useNativeDriver from '../libs/useNativeDriver';
import useNetwork from '../hooks/useNetwork';

/**
* Modal render prop component that exposes modal launching triggers that can be used
Expand Down Expand Up @@ -121,6 +122,7 @@ function AttachmentModal(props) {
: undefined,
);
const {translate} = useLocalize();
const {isOffline} = useNetwork();

const onCarouselAttachmentChange = props.onCarouselAttachmentChange;

Expand Down Expand Up @@ -350,7 +352,7 @@ function AttachmentModal(props) {
<HeaderWithBackButton
title={props.headerTitle || translate(isAttachmentReceipt ? 'common.receipt' : 'common.attachment')}
shouldShowBorderBottom
shouldShowDownloadButton={props.allowDownload && shouldShowDownloadButton && !isAttachmentReceipt}
shouldShowDownloadButton={props.allowDownload && shouldShowDownloadButton && !isAttachmentReceipt && !isOffline}
onDownloadButtonPress={() => downloadAttachment(source)}
shouldShowCloseButton={!props.isSmallScreenWidth}
shouldShowBackButton={props.isSmallScreenWidth}
Expand Down
15 changes: 14 additions & 1 deletion src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ONYXKEYS from '../../../../ONYXKEYS';
import CONST from '../../../../CONST';
import useArrowKeyFocusManager from '../../../../hooks/useArrowKeyFocusManager';
import useKeyboardShortcut from '../../../../hooks/useKeyboardShortcut';
import useNetwork from '../../../../hooks/useNetwork';

const propTypes = {
/** String representing the context menu type [LINK, REPORT_ACTION] which controls context menu choices */
Expand Down Expand Up @@ -51,6 +52,7 @@ function BaseReportActionContextMenu(props) {
const menuItemRefs = useRef({});
const [shouldKeepOpen, setShouldKeepOpen] = useState(false);
const wrapperStyle = getReportActionContextMenuStyles(props.isMini, props.isSmallScreenWidth);
const {isOffline} = useNetwork();

const reportAction = useMemo(() => {
if (_.isEmpty(props.reportActions) || props.reportActionID === '0') {
Expand All @@ -60,7 +62,18 @@ function BaseReportActionContextMenu(props) {
}, [props.reportActions, props.reportActionID]);

const shouldShowFilter = (contextAction) =>
contextAction.shouldShow(props.type, reportAction, props.isArchivedRoom, props.betas, props.anchor, props.isChronosReport, props.reportID, props.isPinnedChat, props.isUnreadChat);
contextAction.shouldShow(
props.type,
reportAction,
props.isArchivedRoom,
props.betas,
props.anchor,
props.isChronosReport,
props.reportID,
props.isPinnedChat,
props.isUnreadChat,
isOffline,
);

const shouldEnableArrowNavigation = !props.isMini && (props.isVisible || shouldKeepOpen);
const filteredContextMenuActions = _.filter(ContextMenuActions, shouldShowFilter);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ export default [
icon: Expensicons.Download,
successTextTranslateKey: 'common.download',
successIcon: Expensicons.Download,
shouldShow: (type, reportAction) => {
shouldShow: (type, reportAction, isArchivedRoom, betas, anchor, isChronosReport, reportID, isPinnedChat, isUnreadChat, isOffline) => {
const isAttachment = ReportActionsUtils.isReportActionAttachment(reportAction);
const messageHtml = lodashGet(reportAction, ['message', 0, 'html']);
return isAttachment && messageHtml !== CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML && reportAction.reportActionID && !ReportActionsUtils.isMessageDeleted(reportAction);
return isAttachment && messageHtml !== CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML && reportAction.reportActionID && !ReportActionsUtils.isMessageDeleted(reportAction) && !isOffline;
},
onPress: (closePopover, {reportAction}) => {
const message = _.last(lodashGet(reportAction, 'message', [{}]));
Expand Down

0 comments on commit 09a0118

Please sign in to comment.