From 931ea4519b351c596e183cb27d7830e884c43ad1 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Tue, 2 Apr 2024 23:14:36 +0100 Subject: [PATCH 01/14] Update thread headers and ancestry to deep link back to the original comment using comment linking --- src/components/AvatarWithDisplayName.tsx | 1 + src/components/ParentNavigationSubtitle.tsx | 7 +++++-- src/pages/ReportDetailsPage.tsx | 1 + src/pages/home/HeaderView.tsx | 1 + src/pages/home/report/ReportActionItemParentAction.tsx | 2 +- src/pages/home/report/ThreadDivider.tsx | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/AvatarWithDisplayName.tsx b/src/components/AvatarWithDisplayName.tsx index 396c10151fbf..f6afb4dae2d6 100644 --- a/src/components/AvatarWithDisplayName.tsx +++ b/src/components/AvatarWithDisplayName.tsx @@ -141,6 +141,7 @@ function AvatarWithDisplayName({ )} diff --git a/src/components/ParentNavigationSubtitle.tsx b/src/components/ParentNavigationSubtitle.tsx index 3109453ca6b0..d36a2e93f5b3 100644 --- a/src/components/ParentNavigationSubtitle.tsx +++ b/src/components/ParentNavigationSubtitle.tsx @@ -15,11 +15,14 @@ type ParentNavigationSubtitleProps = { /** parent Report ID */ parentReportID?: string; + /** parent Report Action ID */ + parentReportActionID?: string; + /** PressableWithoutFeedack additional styles */ pressableStyles?: StyleProp; }; -function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportID = '', pressableStyles}: ParentNavigationSubtitleProps) { +function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportActionID, parentReportID = '', pressableStyles}: ParentNavigationSubtitleProps) { const styles = useThemeStyles(); const {workspaceName, reportName} = parentNavigationSubtitleData; @@ -28,7 +31,7 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportID return ( { - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, parentReportActionID)); }} accessibilityLabel={translate('threads.parentNavigationSummary', {reportName, workspaceName})} role={CONST.ROLE.LINK} diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 9093bf32b9dd..ccfe329419e3 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -253,6 +253,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD )} diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 515a63aa5265..c42984be2959 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -272,6 +272,7 @@ function HeaderView({report, personalDetails, parentReport, parentReportAction, )} diff --git a/src/pages/home/report/ReportActionItemParentAction.tsx b/src/pages/home/report/ReportActionItemParentAction.tsx index 3d98973c86c4..bf34a833b081 100644 --- a/src/pages/home/report/ReportActionItemParentAction.tsx +++ b/src/pages/home/report/ReportActionItemParentAction.tsx @@ -103,7 +103,7 @@ function ReportActionItemParentAction({ > Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? ''))} + onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID))} parentReportAction={parentReportAction} report={ancestor.report} reportActions={reportActions} diff --git a/src/pages/home/report/ThreadDivider.tsx b/src/pages/home/report/ThreadDivider.tsx index 083129e15e6d..f2f929091f93 100644 --- a/src/pages/home/report/ThreadDivider.tsx +++ b/src/pages/home/report/ThreadDivider.tsx @@ -26,7 +26,7 @@ function ThreadDivider({ancestor}: ThreadDividerProps) { return ( Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor?.report?.parentReportID ?? ''))} + onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor?.report?.parentReportID ?? '', ancestor.reportAction.reportActionID))} accessibilityLabel={translate('threads.thread')} role={CONST.ROLE.BUTTON} style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]} From 9d56c094774075b7bc944d79a9f718f5a15f8750 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:47:18 +0100 Subject: [PATCH 02/14] Fix: when linking the last message, New sent message is not displayed until refresh, the cause of the bug: when we already have messages after the linked message, loadNewerChats and handleReportActionPagination are called and isFirstLinkedActionRender.current is set to false, but when the linked message is the last message in the report handleReportActionPagination is not called (based on hasNewestReportAction) and isFirstLinkedActionRender.current remains true. --- src/pages/home/report/ReportActionsView.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 1b6a9614a466..d9b1dc43c940 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -382,13 +382,17 @@ function ReportActionsView({ // Determines if loading older reports is necessary when the content is smaller than the list // and there are fewer than 23 items, indicating we've reached the oldest message. const isLoadingOlderReportsFirstNeeded = checkIfContentSmallerThanList() && reportActions.length > 23; - + if ( (reportActionID && indexOfLinkedAction > -1 && !hasNewestReportAction && !isLoadingOlderReportsFirstNeeded) || (!reportActionID && !hasNewestReportAction && !isLoadingOlderReportsFirstNeeded) ) { handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID}); } + if (reportActionID && indexOfLinkedAction > -1 && hasNewestReportAction && isFirstLinkedActionRender.current) { + isFirstLinkedActionRender.current = false; + setCurrentReportActionID(newestReportAction?.reportActionID); + } }, [ isLoadingInitialReportActions, isLoadingOlderReportActions, From 35e9511c56b5858e43ff8082563cbd50ed4ad31c Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:51:59 +0100 Subject: [PATCH 03/14] Fix: Not here page shows up when opening room link under header subtitle in a deleted report with messages --- src/pages/home/ReportScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 152b02366227..12d2af21e7af 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -580,7 +580,7 @@ function ReportScreen({ return false; } const action = sortedAllReportActions.find((item) => item.reportActionID === reportActionIDFromRoute); - return action && ReportActionsUtils.isDeletedAction(action); + return action && !ReportActionsUtils.shouldReportActionBeVisible(action, action.reportActionID); }, [reportActionIDFromRoute, sortedAllReportActions]); if (isLinkedReportActionDeleted ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) { From 5f0581d85df2e2db8ea98e4991254b3bfb2540b0 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:16:26 +0100 Subject: [PATCH 04/14] Fix: Not here page shows up when opening room link under header subtitle in a deleted report with no messages --- src/components/ParentNavigationSubtitle.tsx | 5 ++++- src/pages/home/report/ReportActionItemParentAction.tsx | 6 +++++- src/pages/home/report/ReportActionsView.tsx | 2 +- src/pages/home/report/ThreadDivider.tsx | 6 +++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/ParentNavigationSubtitle.tsx b/src/components/ParentNavigationSubtitle.tsx index d36a2e93f5b3..a72de3d4eafb 100644 --- a/src/components/ParentNavigationSubtitle.tsx +++ b/src/components/ParentNavigationSubtitle.tsx @@ -3,6 +3,7 @@ import type {StyleProp, ViewStyle} from 'react-native'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; +import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import CONST from '@src/CONST'; import type {ParentNavigationSummaryParams} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; @@ -31,7 +32,9 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportAct return ( { - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, parentReportActionID)); + const parentAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? ''); + const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(parentAction, parentAction?.reportActionID ?? ''); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, isVisibleAction ? parentReportActionID : undefined)); }} accessibilityLabel={translate('threads.parentNavigationSummary', {reportName, workspaceName})} role={CONST.ROLE.LINK} diff --git a/src/pages/home/report/ReportActionItemParentAction.tsx b/src/pages/home/report/ReportActionItemParentAction.tsx index bf34a833b081..0394a290b9af 100644 --- a/src/pages/home/report/ReportActionItemParentAction.tsx +++ b/src/pages/home/report/ReportActionItemParentAction.tsx @@ -7,6 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; import onyxSubscribe from '@libs/onyxSubscribe'; +import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as Report from '@userActions/Report'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -103,7 +104,10 @@ function ReportActionItemParentAction({ > Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID))} + onPress={() => { + const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? ''); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', isVisibleAction ? ancestor.reportAction.reportActionID : undefined)); + }} parentReportAction={parentReportAction} report={ancestor.report} reportActions={reportActions} diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index d9b1dc43c940..ce5e693c8b48 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -382,7 +382,7 @@ function ReportActionsView({ // Determines if loading older reports is necessary when the content is smaller than the list // and there are fewer than 23 items, indicating we've reached the oldest message. const isLoadingOlderReportsFirstNeeded = checkIfContentSmallerThanList() && reportActions.length > 23; - + if ( (reportActionID && indexOfLinkedAction > -1 && !hasNewestReportAction && !isLoadingOlderReportsFirstNeeded) || (!reportActionID && !hasNewestReportAction && !isLoadingOlderReportsFirstNeeded) diff --git a/src/pages/home/report/ThreadDivider.tsx b/src/pages/home/report/ThreadDivider.tsx index f2f929091f93..e1ccca8725cf 100644 --- a/src/pages/home/report/ThreadDivider.tsx +++ b/src/pages/home/report/ThreadDivider.tsx @@ -8,6 +8,7 @@ import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; +import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import type {Ancestor} from '@libs/ReportUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; @@ -26,7 +27,10 @@ function ThreadDivider({ancestor}: ThreadDividerProps) { return ( Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor?.report?.parentReportID ?? '', ancestor.reportAction.reportActionID))} + onPress={() => { + const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? ''); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', isVisibleAction ? ancestor.reportAction.reportActionID : undefined)); + }} accessibilityLabel={translate('threads.thread')} role={CONST.ROLE.BUTTON} style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]} From 55495c71a6628ae95684fcd2dbfba71b7708b371 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Thu, 4 Apr 2024 23:38:34 +0100 Subject: [PATCH 05/14] Fix: Thread - App shows skeleton loading when clicking on parent/ancestor message offline --- src/components/ParentNavigationSubtitle.tsx | 5 +++-- src/pages/home/report/ReportActionItemParentAction.tsx | 6 +++++- src/pages/home/report/ThreadDivider.tsx | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/ParentNavigationSubtitle.tsx b/src/components/ParentNavigationSubtitle.tsx index a72de3d4eafb..0ad32f18659b 100644 --- a/src/components/ParentNavigationSubtitle.tsx +++ b/src/components/ParentNavigationSubtitle.tsx @@ -1,6 +1,7 @@ import React from 'react'; import type {StyleProp, ViewStyle} from 'react-native'; import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; @@ -26,7 +27,7 @@ type ParentNavigationSubtitleProps = { function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportActionID, parentReportID = '', pressableStyles}: ParentNavigationSubtitleProps) { const styles = useThemeStyles(); const {workspaceName, reportName} = parentNavigationSubtitleData; - + const {isOffline} = useNetwork(); const {translate} = useLocalize(); return ( @@ -34,7 +35,7 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportAct onPress={() => { const parentAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? ''); const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(parentAction, parentAction?.reportActionID ?? ''); - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, isVisibleAction ? parentReportActionID : undefined)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, isVisibleAction && !isOffline ? parentReportActionID : undefined)); }} accessibilityLabel={translate('threads.parentNavigationSummary', {reportName, workspaceName})} role={CONST.ROLE.LINK} diff --git a/src/pages/home/report/ReportActionItemParentAction.tsx b/src/pages/home/report/ReportActionItemParentAction.tsx index 0394a290b9af..537f6292c3e4 100644 --- a/src/pages/home/report/ReportActionItemParentAction.tsx +++ b/src/pages/home/report/ReportActionItemParentAction.tsx @@ -2,6 +2,7 @@ import React, {useEffect, useRef, useState} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import useNetwork from '@hooks/useNetwork'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -59,6 +60,7 @@ function ReportActionItemParentAction({ const {isSmallScreenWidth} = useWindowDimensions(); const ancestorIDs = useRef(ReportUtils.getAllAncestorReportActionIDs(report)); const [allAncestors, setAllAncestors] = useState([]); + const {isOffline} = useNetwork(); useEffect(() => { const unsubscribeReports: Array<() => void> = []; @@ -106,7 +108,9 @@ function ReportActionItemParentAction({ { const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? ''); - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', isVisibleAction ? ancestor.reportAction.reportActionID : undefined)); + Navigation.navigate( + ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', isVisibleAction && !isOffline ? ancestor.reportAction.reportActionID : undefined), + ); }} parentReportAction={parentReportAction} report={ancestor.report} diff --git a/src/pages/home/report/ThreadDivider.tsx b/src/pages/home/report/ThreadDivider.tsx index e1ccca8725cf..c728cdf20db4 100644 --- a/src/pages/home/report/ThreadDivider.tsx +++ b/src/pages/home/report/ThreadDivider.tsx @@ -5,6 +5,7 @@ import * as Expensicons from '@components/Icon/Expensicons'; import {PressableWithoutFeedback} from '@components/Pressable'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; @@ -23,13 +24,16 @@ function ThreadDivider({ancestor}: ThreadDividerProps) { const styles = useThemeStyles(); const theme = useTheme(); const {translate} = useLocalize(); + const {isOffline} = useNetwork(); return ( { const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? ''); - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', isVisibleAction ? ancestor.reportAction.reportActionID : undefined)); + Navigation.navigate( + ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', isVisibleAction && !isOffline ? ancestor.reportAction.reportActionID : undefined), + ); }} accessibilityLabel={translate('threads.thread')} role={CONST.ROLE.BUTTON} From 75bc45904754626d199a9feaa07e190118c01650 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:04:53 +0100 Subject: [PATCH 06/14] Fix: Thread - New message does not appear in main chat after returning from thread and sending text | Report - 'New message' button is not displayed when navigating to parent report | Chat - Parent msgs disappear after back from thread by clicking header/browser back button --- src/pages/home/report/ReportActionsView.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index ce5e693c8b48..7ce9182d4335 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -1,5 +1,6 @@ import type {RouteProp} from '@react-navigation/native'; import {useIsFocused, useRoute} from '@react-navigation/native'; +import {useFocusEffect} from '@react-navigation/native'; import lodashIsEqual from 'lodash/isEqual'; import React, {useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; import {InteractionManager} from 'react-native'; @@ -239,6 +240,17 @@ function ReportActionsView({ [fetchNewerAction, hasMoreCached, newestReportAction], ); + useFocusEffect( + useCallback(() => { + if (isFirstLinkedActionRender.current) { + isFirstLinkedActionRender.current = false; + } + if (newestReportAction?.reportActionID) { + setCurrentReportActionID(newestReportAction.reportActionID); + } + }, [newestReportAction?.reportActionID]), + ); + const mostRecentIOUReportActionID = useMemo(() => ReportActionsUtils.getMostRecentIOURequestActionID(reportActions), [reportActions]); const hasCachedActionOnFirstRender = useInitialValue(() => reportActions.length > 0); const hasNewestReportAction = reportActions[0]?.created === report.lastVisibleActionCreated || reportActions[0]?.created === transactionThreadReport?.lastVisibleActionCreated; @@ -389,10 +401,6 @@ function ReportActionsView({ ) { handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID}); } - if (reportActionID && indexOfLinkedAction > -1 && hasNewestReportAction && isFirstLinkedActionRender.current) { - isFirstLinkedActionRender.current = false; - setCurrentReportActionID(newestReportAction?.reportActionID); - } }, [ isLoadingInitialReportActions, isLoadingOlderReportActions, From 14ae8252c06e0483a2d400dcad55f298327e5e56 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:14:51 +0100 Subject: [PATCH 07/14] Fix lint error --- src/pages/home/report/ReportActionsView.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 7ce9182d4335..f6152111b4e7 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -1,6 +1,5 @@ import type {RouteProp} from '@react-navigation/native'; -import {useIsFocused, useRoute} from '@react-navigation/native'; -import {useFocusEffect} from '@react-navigation/native'; +import {useIsFocused, useRoute, useFocusEffect} from '@react-navigation/native'; import lodashIsEqual from 'lodash/isEqual'; import React, {useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; import {InteractionManager} from 'react-native'; From 97316f029efa245c5dcc493fbc33a5fd31f7055c Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:22:01 +0100 Subject: [PATCH 08/14] Prettier --- src/pages/home/report/ReportActionsView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index f6152111b4e7..1b88176ef8f1 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -1,5 +1,5 @@ import type {RouteProp} from '@react-navigation/native'; -import {useIsFocused, useRoute, useFocusEffect} from '@react-navigation/native'; +import {useFocusEffect, useIsFocused, useRoute} from '@react-navigation/native'; import lodashIsEqual from 'lodash/isEqual'; import React, {useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; import {InteractionManager} from 'react-native'; From 2dfabdc373ddbb428dc734c7845e6b70450b1296 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 01:29:07 +0100 Subject: [PATCH 09/14] Fix: Report - 'New message' button is not displayed when navigating to parent report --- src/pages/home/report/ReportActionsList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index d1b9c420b0af..85566b8c5fa0 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -464,10 +464,10 @@ function ReportActionsList({ setCurrentUnreadMarker(reportAction.reportActionID); } }); - if (!markerFound) { + if (!markerFound && !linkedReportActionID) { setCurrentUnreadMarker(null); } - }, [sortedVisibleReportActions, report.reportID, shouldDisplayNewMarker, currentUnreadMarker]); + }, [sortedVisibleReportActions, report.reportID, shouldDisplayNewMarker, currentUnreadMarker, linkedReportActionID]); useEffect(() => { calculateUnreadMarker(); From 4f6f0e3bf0d676309e30df30b750153ea8c07424 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 02:56:49 +0100 Subject: [PATCH 10/14] Fix: comment linking does not preserve message position on native --- src/pages/home/report/ReportActionsView.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index bce4a54f0f35..1b0424e12f0a 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -99,6 +99,7 @@ function ReportActionsView({ // we don't set currentReportActionID on initial render as linkedID as it should trigger visibleReportActions after linked message was positioned const [currentReportActionID, setCurrentReportActionID] = useState(''); const isFirstLinkedActionRender = useRef(true); + const isFirstRender = useRef(true); const network = useNetwork(); const {isSmallScreenWidth, windowHeight} = useWindowDimensions(); @@ -231,6 +232,10 @@ function ReportActionsView({ useFocusEffect( useCallback(() => { + if (isFirstRender.current) { + isFirstRender.current = false; + return; + } if (isFirstLinkedActionRender.current) { isFirstLinkedActionRender.current = false; } From 61d378ae066f9010229014fcf635288f9600a94e Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 07:09:30 +0100 Subject: [PATCH 11/14] Fix: comment linking does not preserve message position --- src/pages/home/report/ReportActionsView.tsx | 23 ++++----------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 1b0424e12f0a..b7d13cd56d97 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -225,26 +225,11 @@ function ReportActionsView({ if (isFirstLinkedActionRender.current) { isFirstLinkedActionRender.current = false; } - setCurrentReportActionID(firstReportActionID); + setCurrentReportActionID(firstReportActionID); }, [fetchNewerAction, hasMoreCached, newestReportAction], ); - useFocusEffect( - useCallback(() => { - if (isFirstRender.current) { - isFirstRender.current = false; - return; - } - if (isFirstLinkedActionRender.current) { - isFirstLinkedActionRender.current = false; - } - if (newestReportAction?.reportActionID) { - setCurrentReportActionID(newestReportAction.reportActionID); - } - }, [newestReportAction?.reportActionID]), - ); - const mostRecentIOUReportActionID = useMemo(() => ReportActionsUtils.getMostRecentIOURequestActionID(reportActions), [reportActions]); const hasCachedActionOnFirstRender = useInitialValue(() => reportActions.length > 0); const hasNewestReportAction = reportActions[0]?.created === report.lastVisibleActionCreated || reportActions[0]?.created === transactionThreadReport?.lastVisibleActionCreated; @@ -368,10 +353,10 @@ function ReportActionsView({ const isLoadingOlderReportsFirstNeeded = checkIfContentSmallerThanList() && reportActions.length > 23; if ( - (reportActionID && indexOfLinkedAction > -1 && !hasNewestReportAction && !isLoadingOlderReportsFirstNeeded) || - (!reportActionID && !hasNewestReportAction && !isLoadingOlderReportsFirstNeeded) + (reportActionID && indexOfLinkedAction > -1 && !isLoadingOlderReportsFirstNeeded) || + (!reportActionID && !isLoadingOlderReportsFirstNeeded) ) { - handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID}); + handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID, hasNewestReportAction}); } }, [ isLoadingInitialReportActions, From ce32cad16d80f3c3af265c62b08e60d50a87a5dd Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 07:24:11 +0100 Subject: [PATCH 12/14] Fix lint errors --- src/pages/home/report/ReportActionsView.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index b7d13cd56d97..92717a1b8896 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -1,5 +1,5 @@ import type {RouteProp} from '@react-navigation/native'; -import {useFocusEffect, useIsFocused, useRoute} from '@react-navigation/native'; +import {useIsFocused, useRoute} from '@react-navigation/native'; import lodashIsEqual from 'lodash/isEqual'; import React, {useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; import {InteractionManager} from 'react-native'; @@ -99,7 +99,6 @@ function ReportActionsView({ // we don't set currentReportActionID on initial render as linkedID as it should trigger visibleReportActions after linked message was positioned const [currentReportActionID, setCurrentReportActionID] = useState(''); const isFirstLinkedActionRender = useRef(true); - const isFirstRender = useRef(true); const network = useNetwork(); const {isSmallScreenWidth, windowHeight} = useWindowDimensions(); @@ -356,7 +355,7 @@ function ReportActionsView({ (reportActionID && indexOfLinkedAction > -1 && !isLoadingOlderReportsFirstNeeded) || (!reportActionID && !isLoadingOlderReportsFirstNeeded) ) { - handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID, hasNewestReportAction}); + handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID}); } }, [ isLoadingInitialReportActions, From 2750dce4b5709297041c7c34006036f0e6f7dd0d Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 07:33:30 +0100 Subject: [PATCH 13/14] Fix lint errors --- src/pages/home/report/ReportActionsView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 92717a1b8896..9f2d982c4fab 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -363,7 +363,6 @@ function ReportActionsView({ checkIfContentSmallerThanList, reportActionID, indexOfLinkedAction, - hasNewestReportAction, handleReportActionPagination, network.isOffline, reportActions.length, From 45e1992fc5a80984d3218ae0c6fbaaaca2e6ca5c Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 5 Apr 2024 07:40:44 +0100 Subject: [PATCH 14/14] Prettier --- src/pages/home/report/ReportActionsView.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 9f2d982c4fab..b8c683a803db 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -224,7 +224,7 @@ function ReportActionsView({ if (isFirstLinkedActionRender.current) { isFirstLinkedActionRender.current = false; } - setCurrentReportActionID(firstReportActionID); + setCurrentReportActionID(firstReportActionID); }, [fetchNewerAction, hasMoreCached, newestReportAction], ); @@ -351,10 +351,7 @@ function ReportActionsView({ // and there are fewer than 23 items, indicating we've reached the oldest message. const isLoadingOlderReportsFirstNeeded = checkIfContentSmallerThanList() && reportActions.length > 23; - if ( - (reportActionID && indexOfLinkedAction > -1 && !isLoadingOlderReportsFirstNeeded) || - (!reportActionID && !isLoadingOlderReportsFirstNeeded) - ) { + if ((reportActionID && indexOfLinkedAction > -1 && !isLoadingOlderReportsFirstNeeded) || (!reportActionID && !isLoadingOlderReportsFirstNeeded)) { handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID}); } }, [