From 72dd1f148ab149e015d77419c961abc1e6f126c9 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Sat, 13 May 2023 20:01:22 +0200 Subject: [PATCH 1/4] Ensure deleted essage are shown as text --- .../GenericPressable/BaseGenericPressable.js | 83 ++++++++++--------- src/pages/home/report/ReportActionItem.js | 2 +- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/src/components/Pressable/GenericPressable/BaseGenericPressable.js b/src/components/Pressable/GenericPressable/BaseGenericPressable.js index 80664f2d3521..50c933823e63 100644 --- a/src/components/Pressable/GenericPressable/BaseGenericPressable.js +++ b/src/components/Pressable/GenericPressable/BaseGenericPressable.js @@ -63,45 +63,54 @@ const GenericPressable = forwardRef((props, ref) => { return props.disabled || shouldBeDisabledByScreenReader; }, [isScreenReaderActive, enableInScreenReaderStates, props.disabled]); - const onLongPressHandler = useCallback((event) => { - if (isDisabled) { - return; - } - if (!onLongPress) { - return; - } - if (shouldUseHapticsOnLongPress) { - HapticFeedback.longPress(); - } - if (ref && ref.current) { - ref.current.blur(); - } - onLongPress(event); - - Accessibility.moveAccessibilityFocus(nextFocusRef); - }, [shouldUseHapticsOnLongPress, onLongPress, nextFocusRef, ref, isDisabled]); - - const onPressHandler = useCallback((event) => { - if (isDisabled) { - return; - } - if (shouldUseHapticsOnPress) { - HapticFeedback.press(); - } - if (ref && ref.current) { - ref.current.blur(); - } - onPress(event); + const onLongPressHandler = useCallback( + (event) => { + if (isDisabled) { + return; + } + if (!onLongPress) { + return; + } + if (shouldUseHapticsOnLongPress) { + HapticFeedback.longPress(); + } + if (ref && ref.current) { + ref.current.blur(); + } + onLongPress(event); + + Accessibility.moveAccessibilityFocus(nextFocusRef); + }, + [shouldUseHapticsOnLongPress, onLongPress, nextFocusRef, ref, isDisabled], + ); - Accessibility.moveAccessibilityFocus(nextFocusRef); - }, [shouldUseHapticsOnPress, onPress, nextFocusRef, ref, isDisabled]); + const onPressHandler = useCallback( + (event) => { + if (isDisabled) { + return; + } + if (shouldUseHapticsOnPress) { + HapticFeedback.press(); + } + if (ref && ref.current) { + ref.current.blur(); + } + onPress(event); + + Accessibility.moveAccessibilityFocus(nextFocusRef); + }, + [shouldUseHapticsOnPress, onPress, nextFocusRef, ref, isDisabled], + ); - const onKeyPressHandler = useCallback((event) => { - if (event.key !== 'Enter') { - return; - } - onPressHandler(event); - }, [onPressHandler]); + const onKeyPressHandler = useCallback( + (event) => { + if (event.key !== 'Enter') { + return; + } + onPressHandler(event); + }, + [onPressHandler], + ); useEffect(() => { if (!keyboardShortcut) { diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 38b5bda6f713..bdb5f1db9228 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -184,7 +184,7 @@ class ReportActionItem extends Component { */ renderItemContent(hovered = false) { let children; - if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { + if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && this.props.action.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.DELETE) { // There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID const iouReportID = this.props.action.originalMessage.IOUReportID ? this.props.action.originalMessage.IOUReportID.toString() : '0'; From c94b250e213c6a07738ddbc88d15d881cc2ecc35 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Sat, 13 May 2023 20:03:20 +0200 Subject: [PATCH 2/4] Styles --- src/pages/home/report/ReportActionItem.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index bdb5f1db9228..c27d76ec149d 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -184,7 +184,11 @@ class ReportActionItem extends Component { */ renderItemContent(hovered = false) { let children; - if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && this.props.action.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.DELETE) { + if ( + this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && + this.props.action.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.DELETE && + this.props.action.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.PAY + ) { // There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID const iouReportID = this.props.action.originalMessage.IOUReportID ? this.props.action.originalMessage.IOUReportID.toString() : '0'; From 9ad94416ed35cdc88442c57b58f0db71feea0fec Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Sun, 14 May 2023 15:43:15 +0200 Subject: [PATCH 3/4] Check for the report object instead of the report total --- src/components/ReportActionItem/IOUPreview.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index 4bc60914bb4d..3fab478bb42d 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -128,11 +128,7 @@ const defaultProps = { }; const IOUPreview = (props) => { - // Usually the parent determines whether the IOU Preview is displayed. But as the iouReport total cannot be known - // until it is stored locally, we need to make this check within the Component after retrieving it. This allows us - // to handle the loading UI from within this Component instead of needing to declare it within each parent, which - // would duplicate and complicate the logic - if (props.iouReport.total === 0) { + if (_.isEmpty(props.iouReport)) { return null; } const sessionEmail = lodashGet(props.session, 'email', null); From 73d3cf2e20331dde91b4a03af027955c9e83eae1 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Sun, 14 May 2023 15:56:44 +0200 Subject: [PATCH 4/4] Access the chat participants safely --- src/components/ReportActionItem/MoneyRequestAction.js | 3 ++- src/pages/iou/IOUDetailsModal.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index 801f807e36c5..7efc36baf8ae 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -2,6 +2,7 @@ import _ from 'underscore'; import React from 'react'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; +import lodashGet from 'lodash/get'; import ONYXKEYS from '../../ONYXKEYS'; import CONST from '../../CONST'; import {withNetwork} from '../OnyxProvider'; @@ -69,7 +70,7 @@ const defaultProps = { }; const MoneyRequestAction = (props) => { - const hasMultipleParticipants = props.chatReport.participants.length > 1; + const hasMultipleParticipants = lodashGet(props.chatReport, 'participants', []).length > 1; const onIOUPreviewPressed = () => { if (hasMultipleParticipants) { Navigation.navigate(ROUTES.getReportParticipantsRoute(props.chatReportID)); diff --git a/src/pages/iou/IOUDetailsModal.js b/src/pages/iou/IOUDetailsModal.js index 630fb9836071..3403bf83fb23 100644 --- a/src/pages/iou/IOUDetailsModal.js +++ b/src/pages/iou/IOUDetailsModal.js @@ -186,7 +186,7 @@ class IOUDetailsModal extends Component { 1} + isBillSplit={lodashGet(this.props, 'chatReport.participants', []).length > 1} isIOUAction={false} pendingAction={pendingAction} />