From b19951d672f58d9da2ed8406f410e1c76558cf8d Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 28 Sep 2024 13:24:57 -0300 Subject: [PATCH] Clean up unsigned commits. --- .../ReportActionCompose.tsx | 5 +++++ src/pages/home/report/ReportActionItem.tsx | 1 + src/pages/home/report/ReportActionsList.tsx | 19 ++++++++++++++++++- src/pages/home/report/clearReportAction.ts | 9 +++++++++ .../FloatingActionButtonAndPopover.tsx | 9 ++++++++- 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/pages/home/report/clearReportAction.ts diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index e4b0eef6ca52..2202963faee4 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -45,6 +45,7 @@ import * as Report from '@userActions/Report'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {getClearIsReportActionLinked} from '@src/pages/home/report/clearReportAction'; import type * as OnyxTypes from '@src/types/onyx'; import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -230,6 +231,8 @@ function ReportActionCompose({ const onItemSelected = useCallback(() => { isKeyboardVisibleWhenShowingModalRef.current = false; + // Clear the highlighted report item when an action from the + menu is taken + getClearIsReportActionLinked()(); }, []); const updateShouldShowSuggestionMenuToFalse = useCallback(() => { @@ -274,6 +277,8 @@ function ReportActionCompose({ Performance.markStart(CONST.TIMING.MESSAGE_SENT, {message: newCommentTrimmed}); onSubmit(newCommentTrimmed); } + // Clear the highlighted report item when a new comment or attachment is sent + getClearIsReportActionLinked()(); }, [onSubmit, reportID], ); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 33664e2a4162..84610e32b05e 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -121,6 +121,7 @@ type ReportActionItemProps = { /** Flag to show, hide the thread divider line */ shouldHideThreadDividerLine?: boolean; + /** Linked report action ID */ linkedReportActionID?: string; /** Callback to be called on onPress */ diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 8f5fc907a962..99e09850ad8b 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -32,6 +32,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; +import {setClearIsReportActionLinked} from './clearReportAction'; import FloatingMessageCounter from './FloatingMessageCounter'; import getInitialNumToRender from './getInitialNumReportActionsToRender'; import ListBoundaryLoader from './ListBoundaryLoader'; @@ -184,7 +185,23 @@ function ReportActionsList({ const readActionSkipped = useRef(false); const hasHeaderRendered = useRef(false); const hasFooterRendered = useRef(false); - const linkedReportActionID = route?.params?.reportActionID ?? '-1'; + const [linkedReportActionID, setLinkedReportActionID] = useState(route?.params?.reportActionID ?? '-1'); + + const clearIsReportActionLinked = useCallback(() => { + setLinkedReportActionID('-1'); + }, []); + + useEffect(() => { + setClearIsReportActionLinked(clearIsReportActionLinked); + }, [clearIsReportActionLinked]); + + useEffect(() => { + if (route?.params?.reportActionID) { + setLinkedReportActionID(route.params.reportActionID); + } else { + setLinkedReportActionID('-1'); + } + }, [route]); const sortedVisibleReportActions = useMemo( () => diff --git a/src/pages/home/report/clearReportAction.ts b/src/pages/home/report/clearReportAction.ts new file mode 100644 index 000000000000..9a0ae46d247c --- /dev/null +++ b/src/pages/home/report/clearReportAction.ts @@ -0,0 +1,9 @@ +let clearIsReportActionLinked: () => void = () => {}; + +const setClearIsReportActionLinked = (fn: () => void) => { + clearIsReportActionLinked = fn; +}; + +const getClearIsReportActionLinked = () => clearIsReportActionLinked; + +export {setClearIsReportActionLinked, getClearIsReportActionLinked}; diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 8791a2fc7ec8..13f9368ebc4f 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -33,6 +33,7 @@ import * as Task from '@userActions/Task'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; +import {getClearIsReportActionLinked} from '@src/pages/home/report/clearReportAction'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; @@ -351,13 +352,19 @@ function FloatingActionButtonAndPopover( // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps const selfDMReportID = useMemo(() => ReportUtils.findSelfDMReportID(), [isLoading]); + const onItemSelected = useCallback(() => { + hideCreateMenu(); + // Clear the highlighted report item when an action from the + menu is taken + getClearIsReportActionLinked()(); + }, [hideCreateMenu]); + return (