Skip to content

Commit

Permalink
use network hook
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenKKC authored Sep 25, 2023
1 parent 8d12ce3 commit fb1dde8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +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';
import useNetwork from '../../../../hooks/useNetwork';

/**
* Gets the HTML version of the message in an action.
Expand All @@ -44,6 +44,8 @@ const CONTEXT_MENU_TYPES = {
REPORT: 'REPORT',
};

const {isOffline} = useNetwork();

Check failure on line 47 in src/pages/home/report/ContextMenu/ContextMenuActions.js

View workflow job for this annotation

GitHub Actions / lint

React Hook "useNetwork" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function

// A list of all the context actions in this menu.
export default [
{
Expand Down Expand Up @@ -102,13 +104,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) &&
!NetworkStore.isOffline()
);
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 fb1dde8

Please sign in to comment.