Skip to content

Commit c71f5f9

Browse files
authored
Merge pull request Expensify#68424 from callstack-internal/fix/composer-remove-unused-props
Remove unused props in Composer components
2 parents dfd3996 + ec23132 commit c71f5f9

5 files changed

Lines changed: 13 additions & 38 deletions

File tree

src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ type AttachmentPickerWithMenuItemsProps = {
5858
/** Whether or not the composer is full size */
5959
isComposerFullSize: boolean;
6060

61-
/** Whether or not the user is blocked from concierge */
62-
isBlockedFromConcierge: boolean;
63-
6461
/** Whether or not the attachment picker is disabled */
6562
disabled?: boolean;
6663

@@ -112,7 +109,6 @@ function AttachmentPickerWithMenuItems({
112109
isFullComposerAvailable,
113110
isComposerFullSize,
114111
reportID,
115-
isBlockedFromConcierge,
116112
disabled,
117113
setMenuVisibility,
118114
isMenuVisible,
@@ -373,7 +369,7 @@ function AttachmentPickerWithMenuItems({
373369
setMenuVisibility(!isMenuVisible);
374370
}}
375371
style={styles.composerSizeButton}
376-
disabled={isBlockedFromConcierge || disabled}
372+
disabled={disabled}
377373
role={CONST.ROLE.BUTTON}
378374
accessibilityLabel={translate('common.create')}
379375
>
@@ -400,7 +396,7 @@ function AttachmentPickerWithMenuItems({
400396
// Keep focus on the composer when Collapse button is clicked.
401397
onMouseDown={(e) => e.preventDefault()}
402398
style={styles.composerSizeButton}
403-
disabled={isBlockedFromConcierge || disabled}
399+
disabled={disabled}
404400
role={CONST.ROLE.BUTTON}
405401
accessibilityLabel={translate('reportActionCompose.collapse')}
406402
>
@@ -424,7 +420,7 @@ function AttachmentPickerWithMenuItems({
424420
// Keep focus on the composer when Expand button is clicked.
425421
onMouseDown={(e) => e.preventDefault()}
426422
style={styles.composerSizeButton}
427-
disabled={isBlockedFromConcierge || disabled}
423+
disabled={disabled}
428424
role={CONST.ROLE.BUTTON}
429425
accessibilityLabel={translate('reportActionCompose.expand')}
430426
>

src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,8 @@ type ComposerWithSuggestionsProps = Partial<ChildrenProps> & {
103103
/** Function to display a file in a modal */
104104
displayFilesInModal: (file: FileObject[]) => void;
105105

106-
/** Whether the user is blocked from concierge */
107-
isBlockedFromConcierge: boolean;
108-
109-
/** Whether the input is disabled */
110-
disabled: boolean;
106+
/** Whether the input is disabled, defaults to false */
107+
disabled?: boolean;
111108

112109
/** Function to set whether the comment is empty */
113110
setIsCommentEmpty: (isCommentEmpty: boolean) => void;
@@ -217,7 +214,6 @@ function ComposerWithSuggestions(
217214
isMenuVisible,
218215
inputPlaceholder,
219216
displayFilesInModal,
220-
isBlockedFromConcierge,
221217
disabled,
222218
setIsCommentEmpty,
223219
handleSendMessage,
@@ -817,7 +813,7 @@ function ComposerWithSuggestions(
817813
displayFilesInModal([file]);
818814
}}
819815
onClear={onClear}
820-
isDisabled={isBlockedFromConcierge || disabled}
816+
isDisabled={disabled}
821817
selection={selection}
822818
onSelectionChange={onSelectionChange}
823819
isComposerFullSize={isComposerFullSize}

src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,12 @@ type ReportActionComposeProps = Pick<ComposerWithSuggestionsProps, 'reportID' |
9999
/** The type of action that's pending */
100100
pendingAction?: OnyxCommon.PendingAction;
101101

102-
/** Whether the report is ready for display */
103-
isReportReadyForDisplay?: boolean;
104-
105102
/** A method to call when the input is focus */
106103
onComposerFocus?: () => void;
107104

108105
/** A method to call when the input is blur */
109106
onComposerBlur?: () => void;
110107

111-
/** Should the input be disabled */
112-
disabled?: boolean;
113-
114108
/** Whether the main composer was hidden */
115109
didHideComposerInput?: boolean;
116110
};
@@ -125,13 +119,11 @@ const willBlurTextInputOnTapOutside = willBlurTextInputOnTapOutsideFunc();
125119
let onSubmitAction = noop;
126120

127121
function ReportActionCompose({
128-
disabled = false,
129122
isComposerFullSize = false,
130123
onSubmit,
131124
pendingAction,
132125
report,
133126
reportID,
134-
isReportReadyForDisplay = true,
135127
lastReportAction,
136128
onComposerFocus,
137129
onComposerBlur,
@@ -393,11 +385,11 @@ function ReportActionCompose({
393385
const isGroupPolicyReport = useMemo(() => !!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE, [report]);
394386
const reportRecipientAccountIDs = getReportRecipientAccountIDs(report, currentUserPersonalDetails.accountID);
395387
const reportRecipient = personalDetails?.[reportRecipientAccountIDs[0]];
396-
const shouldUseFocusedColor = !isBlockedFromConcierge && !disabled && isFocused;
388+
const shouldUseFocusedColor = !isBlockedFromConcierge && isFocused;
397389

398390
const hasReportRecipient = !isEmptyObject(reportRecipient);
399391

400-
const isSendDisabled = isCommentEmpty || isBlockedFromConcierge || !!disabled || !!exceededMaxLength;
392+
const isSendDisabled = isCommentEmpty || isBlockedFromConcierge || !!exceededMaxLength;
401393

402394
// Note: using JS refs is not well supported in reanimated, thus we need to store the function in a shared value
403395
// useSharedValue on web doesn't support functions, so we need to wrap it in an object.
@@ -413,13 +405,13 @@ function ReportActionCompose({
413405
throw new Error('The composerRefShared.clear function is not set yet. This should never happen, and indicates a developer error.');
414406
}
415407

416-
if (isSendDisabled || !isReportReadyForDisplay) {
408+
if (isSendDisabled) {
417409
return;
418410
}
419411

420412
// This will cause onCleared to be triggered where we actually send the message
421413
clearComposer();
422-
}, [isSendDisabled, isReportReadyForDisplay, composerRefShared]);
414+
}, [isSendDisabled, composerRefShared]);
423415

424416
const measureComposer = useCallback(
425417
(e: LayoutChangeEvent) => {
@@ -621,8 +613,7 @@ function ReportActionCompose({
621613
reportParticipantIDs={reportParticipantIDs}
622614
isFullComposerAvailable={isFullComposerAvailable}
623615
isComposerFullSize={isComposerFullSize}
624-
isBlockedFromConcierge={isBlockedFromConcierge}
625-
disabled={disabled}
616+
disabled={isBlockedFromConcierge}
626617
setMenuVisibility={setMenuVisibility}
627618
isMenuVisible={isMenuVisible}
628619
onTriggerAttachmentPicker={onTriggerAttachmentPicker}
@@ -660,8 +651,7 @@ function ReportActionCompose({
660651
setIsFullComposerAvailable={setIsFullComposerAvailable}
661652
displayFilesInModal={displayFilesInModal}
662653
onCleared={submitForm}
663-
isBlockedFromConcierge={isBlockedFromConcierge}
664-
disabled={disabled}
654+
disabled={isBlockedFromConcierge}
665655
setIsCommentEmpty={setIsCommentEmpty}
666656
handleSendMessage={handleSendMessage}
667657
shouldShowComposeInput={shouldShowComposeInput}
@@ -696,7 +686,7 @@ function ReportActionCompose({
696686
</AttachmentComposerModal>
697687
{canUseTouchScreen() && isMediumScreenWidth ? null : (
698688
<EmojiPickerButton
699-
isDisabled={isBlockedFromConcierge || disabled}
689+
isDisabled={isBlockedFromConcierge}
700690
onModalHide={(isNavigating) => {
701691
if (isNavigating) {
702692
return;

src/pages/home/report/ReportFooter.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ type ReportFooterProps = {
6262
/** The pending action when we are adding a chat */
6363
pendingAction?: PendingAction;
6464

65-
/** Whether the report is ready for display */
66-
isReportReadyForDisplay?: boolean;
67-
6865
/** Whether the composer is in full size */
6966
isComposerFullSize?: boolean;
7067

@@ -81,7 +78,6 @@ function ReportFooter({
8178
report = {reportID: '-1'},
8279
reportMetadata,
8380
policy,
84-
isReportReadyForDisplay = true,
8581
isComposerFullSize = false,
8682
onComposerBlur,
8783
onComposerFocus,
@@ -234,7 +230,6 @@ function ReportFooter({
234230
lastReportAction={lastReportAction}
235231
pendingAction={pendingAction}
236232
isComposerFullSize={isComposerFullSize}
237-
isReportReadyForDisplay={isReportReadyForDisplay}
238233
didHideComposerInput={didHideComposerInput}
239234
reportTransactions={reportTransactions}
240235
/>
@@ -254,7 +249,6 @@ export default memo(
254249
prevProps.pendingAction === nextProps.pendingAction &&
255250
prevProps.isComposerFullSize === nextProps.isComposerFullSize &&
256251
prevProps.lastReportAction === nextProps.lastReportAction &&
257-
prevProps.isReportReadyForDisplay === nextProps.isReportReadyForDisplay &&
258252
deepEqual(prevProps.reportMetadata, nextProps.reportMetadata) &&
259253
deepEqual(prevProps.policy?.employeeList, nextProps.policy?.employeeList) &&
260254
deepEqual(prevProps.policy?.role, nextProps.policy?.role) &&

tests/perf-test/ReportActionCompose.perf-test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ function ReportActionComposeWrapper() {
8383
<ReportActionCompose
8484
onSubmit={() => jest.fn()}
8585
reportID="1"
86-
disabled={false}
8786
report={LHNTestUtils.getFakeReport()}
8887
isComposerFullSize
8988
/>

0 commit comments

Comments
 (0)