Skip to content

Commit 56d7b8a

Browse files
authored
Merge pull request Expensify#89683 from Expensify/rory-contextmenu-remove-props
[Payment due @huult] perf: remove unnecessary props from ReportActionContextMenu (isChronosReport, isPinnedChat, isUnreadChat, isArchivedRoom)
2 parents 791a4d1 + 625a839 commit 56d7b8a

25 files changed

Lines changed: 27 additions & 123 deletions

File tree

src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import useThemeStyles from '@hooks/useThemeStyles';
1010
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
1111
import {isMobileSafari} from '@libs/Browser';
1212
import fileDownload from '@libs/fileDownload';
13-
import {isArchivedNonExpenseReport} from '@libs/ReportUtils';
1413
import {setDownload} from '@userActions/Download';
1514
import CONST from '@src/CONST';
1615
import ONYXKEYS from '@src/ONYXKEYS';
@@ -39,7 +38,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
3938
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
4039
const sourceURLWithAuth = addEncryptedAuthTokenToURL(source, encryptedAuthToken);
4140

42-
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
41+
const {anchor, report, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
4342
const {checkIfContextMenuActive} = useShowContextMenuActions();
4443

4544
return (
@@ -58,7 +57,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
5857
if (isDisabled || !shouldDisplayContextMenu) {
5958
return;
6059
}
61-
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived), originalReportID);
60+
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, originalReportID);
6261
}}
6362
shouldUseHapticsOnLongPress
6463
accessibilityLabel={displayName}

src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import useTheme from '@hooks/useTheme';
1313
import useThemeStyles from '@hooks/useThemeStyles';
1414
import {getFileName, getFileType, splitExtensionFromFileName} from '@libs/fileDownload/FileUtils';
1515
import Navigation from '@libs/Navigation/Navigation';
16-
import {isArchivedNonExpenseReport} from '@libs/ReportUtils';
1716
import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot';
1817
import CONST from '@src/CONST';
1918
import ONYXKEYS from '@src/ONYXKEYS';
@@ -90,7 +89,7 @@ function ImageRenderer({tnode}: CustomRendererProps<TBlock>) {
9089
/>
9190
);
9291

93-
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
92+
const {anchor, report, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
9493
const {onShowContextMenu, checkIfContextMenuActive} = useShowContextMenuActions();
9594

9695
return imagePreviewModalDisabled ? (
@@ -123,17 +122,7 @@ function ImageRenderer({tnode}: CustomRendererProps<TBlock>) {
123122
if (isDisabled || !shouldDisplayContextMenu) {
124123
return;
125124
}
126-
return onShowContextMenu(() =>
127-
showContextMenuForReport(
128-
event,
129-
anchor,
130-
report?.reportID,
131-
action,
132-
checkIfContextMenuActive,
133-
isArchivedNonExpenseReport(report, isReportArchived),
134-
originalReportID,
135-
),
136-
);
125+
return onShowContextMenu(() => showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, originalReportID));
137126
}}
138127
isNested
139128
shouldUseHapticsOnLongPress

src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import useStyleUtils from '@hooks/useStyleUtils';
1717
import useThemeStyles from '@hooks/useThemeStyles';
1818
import Navigation from '@libs/Navigation/Navigation';
1919
import {getAccountIDsByLogins, getDisplayNameOrDefault, getShortMentionIfFound} from '@libs/PersonalDetailsUtils';
20-
import {isArchivedNonExpenseReport} from '@libs/ReportUtils';
2120
import CONST from '@src/CONST';
2221
import ROUTES from '@src/ROUTES';
2322
import type {Route} from '@src/ROUTES';
@@ -33,7 +32,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
3332
const htmlAttribAccountID = tnode.attributes.accountid;
3433
const personalDetails = usePersonalDetails();
3534
const htmlAttributeAccountID = tnode.attributes.accountid;
36-
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
35+
const {anchor, report, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
3736
const {onShowContextMenu, checkIfContextMenuActive} = useShowContextMenuActions();
3837

3938
let accountID: number;
@@ -82,9 +81,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
8281
if (isDisabled || !shouldDisplayContextMenu) {
8382
return;
8483
}
85-
return onShowContextMenu(() =>
86-
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived), originalReportID),
87-
);
84+
return onShowContextMenu(() => showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, originalReportID));
8885
}}
8986
onPress={(event) => {
9087
event.preventDefault();

src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Text from '@components/Text';
99
import useLocalize from '@hooks/useLocalize';
1010
import useStyleUtils from '@hooks/useStyleUtils';
1111
import useThemeStyles from '@hooks/useThemeStyles';
12-
import {isArchivedNonExpenseReport} from '@libs/ReportUtils';
1312
import CONST from '@src/CONST';
1413

1514
type PreRendererProps = CustomRendererProps<TBlock> & {
@@ -33,7 +32,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d
3332
const styles = useThemeStyles();
3433
const StyleUtils = useStyleUtils();
3534
const {translate} = useLocalize();
36-
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
35+
const {anchor, report, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
3736
const {onShowContextMenu, checkIfContextMenuActive} = useShowContextMenuActions();
3837
const isLast = defaultRendererProps.renderIndex === defaultRendererProps.renderLength - 1;
3938

@@ -63,15 +62,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d
6362
if (isDisabled || !shouldDisplayContextMenu) {
6463
return;
6564
}
66-
return showContextMenuForReport(
67-
event,
68-
anchor,
69-
report?.reportID,
70-
action,
71-
checkIfContextMenuActive,
72-
isArchivedNonExpenseReport(report, isReportArchived),
73-
originalReportID,
74-
);
65+
return showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, originalReportID);
7566
});
7667
}}
7768
shouldUseHapticsOnLongPress

src/components/LHNOptionsList/OptionRowLHN/OptionRowPressable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ function OptionRowPressable({
7474
report: {
7575
reportID,
7676
originalReportID: reportID,
77-
isPinnedChat: optionItem.isPinned,
78-
isUnreadChat: !!optionItem.isUnread,
7977
},
8078
reportAction: {
8179
reportActionID: '-1',

src/components/MoneyRequestConfirmationList/sections/DescriptionField.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ function DescriptionField({
6161
const contextMenuStateValue = {
6262
anchor: null,
6363
report: undefined,
64-
isReportArchived: false,
6564
action: undefined,
6665
isDisabled: true,
6766
shouldDisplayContextMenu: false,

src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ function MoneyRequestReportPreviewContent({
633633
if (!shouldDisplayContextMenu) {
634634
return;
635635
}
636-
showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive, false, originalReportID);
636+
showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive, originalReportID);
637637
}}
638638
shouldUseHapticsOnLongPress
639639
style={[

src/components/ReportActionItem/TaskPreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function TaskPreview({
151151
if (!shouldDisplayContextMenu) {
152152
return;
153153
}
154-
return showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive, false, originalReportID);
154+
return showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive, originalReportID);
155155
})
156156
}
157157
shouldUseHapticsOnLongPress

src/components/ReportActionItem/TaskView.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ function TaskView({report, parentReport, action}: TaskViewProps) {
9292
() => ({
9393
anchor: null,
9494
report,
95-
isReportArchived: false,
9695
action,
9796
transactionThreadReport: undefined,
9897
isDisabled: true,

src/components/ReportActionItem/TransactionPreview/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function TransactionPreview(props: TransactionPreviewProps) {
8080
if (!shouldDisplayContextMenu) {
8181
return;
8282
}
83-
showContextMenuForReport(event, contextMenuAnchor, contextMenuReportID, contextMenuAction, checkIfContextMenuActive, false, originalReportID);
83+
showContextMenuForReport(event, contextMenuAnchor, contextMenuReportID, contextMenuAction, checkIfContextMenuActive, originalReportID);
8484
};
8585

8686
const offlineWithFeedbackOnClose = useCallback(() => {

0 commit comments

Comments
 (0)