Skip to content

Commit

Permalink
fix new tab opens when downloading offline
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenKKC committed Sep 25, 2023
1 parent 767bdae commit 79c2f61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 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 * as NetworkStore from '../libs/Network/NetworkStore';

/**
* Modal render prop component that exposes modal launching triggers that can be used
Expand Down Expand Up @@ -350,7 +351,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 && !NetworkStore.isOffline()}
onDownloadButtonPress={() => downloadAttachment(source)}
shouldShowCloseButton={!props.isSmallScreenWidth}
shouldShowBackButton={props.isSmallScreenWidth}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as Task from '../../../../libs/actions/Task';
import * as Localize from '../../../../libs/Localize';
import * as TransactionUtils from '../../../../libs/TransactionUtils';
import * as CurrencyUtils from '../../../../libs/CurrencyUtils';
import * as NetworkStore from '../../../../libs/Network/NetworkStore';

/**
* Gets the HTML version of the message in an action.
Expand Down Expand Up @@ -101,7 +102,7 @@ export default [
shouldShow: (type, reportAction) => {
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) && !NetworkStore.isOffline();
},
onPress: (closePopover, {reportAction}) => {
const message = _.last(lodashGet(reportAction, 'message', [{}]));
Expand Down

0 comments on commit 79c2f61

Please sign in to comment.