From ced6292f4cc030d8c800970c594a3ee5254d3d07 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 16:17:40 -0700 Subject: [PATCH 1/3] Make getContinuousReportActionChain consider any optimistic action --- src/libs/ReportActionsUtils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 64bac4f46b5a..1a5daa803c9a 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -262,10 +262,12 @@ function getSortedReportActions(reportActions: ReportAction[] | null, shouldSort function getContinuousReportActionChain(sortedReportActions: ReportAction[], id?: string): ReportAction[] { let index; + console.log('RORY_DEBUG sortedReportActions', sortedReportActions); + if (id) { index = sortedReportActions.findIndex((obj) => obj.reportActionID === id); } else { - index = sortedReportActions.findIndex((obj) => obj.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); + index = sortedReportActions.findIndex((obj) => obj.pendingAction === null); } if (index === -1) { @@ -298,12 +300,14 @@ function getContinuousReportActionChain(sortedReportActions: ReportAction[], id? // This additional check is to include recently sent messages that might not yet be part of the established sequence. while ( (startIndex > 0 && sortedReportActions[startIndex].reportActionID === sortedReportActions[startIndex - 1].previousReportActionID) || - sortedReportActions[startIndex - 1]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD || + sortedReportActions[startIndex - 1]?.pendingAction !== null || sortedReportActions[startIndex - 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM ) { startIndex--; } + console.log('RORY_DEBUG continuous reportAction chain', sortedReportActions.slice(startIndex, endIndex + 1)); + return sortedReportActions.slice(startIndex, endIndex + 1); } From 046780d6690624ce68e410ee487a46a5ccf1e93c Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 16:54:36 -0700 Subject: [PATCH 2/3] Ignore update actions --- src/libs/ReportActionsUtils.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 1a5daa803c9a..3a1056cd78b7 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -265,9 +265,14 @@ function getContinuousReportActionChain(sortedReportActions: ReportAction[], id? console.log('RORY_DEBUG sortedReportActions', sortedReportActions); if (id) { - index = sortedReportActions.findIndex((obj) => obj.reportActionID === id); + index = sortedReportActions.findIndex((reportAction) => reportAction.reportActionID === id); } else { - index = sortedReportActions.findIndex((obj) => obj.pendingAction === null); + index = sortedReportActions.findIndex( + (reportAction) => + reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && + reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && + !reportAction.isOptimisticAction, + ); } if (index === -1) { @@ -300,7 +305,10 @@ function getContinuousReportActionChain(sortedReportActions: ReportAction[], id? // This additional check is to include recently sent messages that might not yet be part of the established sequence. while ( (startIndex > 0 && sortedReportActions[startIndex].reportActionID === sortedReportActions[startIndex - 1].previousReportActionID) || - sortedReportActions[startIndex - 1]?.pendingAction !== null || + sortedReportActions[startIndex - 1]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD || + sortedReportActions[startIndex - 1]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + sortedReportActions[startIndex - 1]?.isOptimisticAction || sortedReportActions[startIndex - 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM ) { startIndex--; From df38b414bcb2b94a7e67204497ffd51c5f58ac22 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 26 Mar 2024 09:58:19 -0700 Subject: [PATCH 3/3] Remove debug logs --- src/libs/ReportActionsUtils.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 3a1056cd78b7..11f870b891b6 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -262,8 +262,6 @@ function getSortedReportActions(reportActions: ReportAction[] | null, shouldSort function getContinuousReportActionChain(sortedReportActions: ReportAction[], id?: string): ReportAction[] { let index; - console.log('RORY_DEBUG sortedReportActions', sortedReportActions); - if (id) { index = sortedReportActions.findIndex((reportAction) => reportAction.reportActionID === id); } else { @@ -314,8 +312,6 @@ function getContinuousReportActionChain(sortedReportActions: ReportAction[], id? startIndex--; } - console.log('RORY_DEBUG continuous reportAction chain', sortedReportActions.slice(startIndex, endIndex + 1)); - return sortedReportActions.slice(startIndex, endIndex + 1); }