Skip to content

Commit

Permalink
Merge pull request #50679 from Expensify/neil-chronos-offline
Browse files Browse the repository at this point in the history
Display Chronos offline time tracking nicely
  • Loading branch information
deetergp authored Oct 17, 2024
2 parents 4796961 + 30b8866 commit cc7ac35
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,22 @@ function isConsecutiveActionMadeByPreviousActor(reportActions: ReportAction[] |
return currentAction.actorAccountID === previousAction.actorAccountID;
}

function isChronosAutomaticTimerAction(reportAction: OnyxInputOrEntry<ReportAction>, isChronosReport: boolean): boolean {
const isAutomaticStartTimerAction = () => /start(?:ed|ing)?(?:\snow)?/i.test(getReportActionText(reportAction));
const isAutomaticStopTimerAction = () => /stop(?:ped|ping)?(?:\snow)?/i.test(getReportActionText(reportAction));
return isChronosReport && (isAutomaticStartTimerAction() || isAutomaticStopTimerAction());
}

/**
* If the user sends consecutive actions to Chronos to automatically start/stop the timer,
* then detect that and show each individually so that the user can easily see when they were sent.
*/
function isConsecutiveChronosAutomaticTimerAction(reportActions: ReportAction[], actionIndex: number, isChronosReport: boolean): boolean {
const previousAction = findPreviousAction(reportActions, actionIndex);
const currentAction = reportActions?.at(actionIndex);
return isChronosAutomaticTimerAction(currentAction, isChronosReport) && isChronosAutomaticTimerAction(previousAction, isChronosReport);
}

/**
* Checks if a reportAction is deprecated.
*/
Expand Down Expand Up @@ -1834,6 +1850,7 @@ export {
isChronosOOOListAction,
isClosedAction,
isConsecutiveActionMadeByPreviousActor,
isConsecutiveChronosAutomaticTimerAction,
isCreatedAction,
isCreatedTaskReportAction,
isCurrentActionUnread,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,10 @@ function ReportActionsList({
report={report}
transactionThreadReport={transactionThreadReport}
linkedReportActionID={linkedReportActionID}
displayAsGroup={ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedVisibleReportActions, index)}
displayAsGroup={
!ReportActionsUtils.isConsecutiveChronosAutomaticTimerAction(sortedVisibleReportActions, index, ReportUtils.chatIncludesChronosWithID(reportAction?.reportID)) &&
ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedVisibleReportActions, index)
}
mostRecentIOUReportActionID={mostRecentIOUReportActionID}
shouldHideThreadDividerLine={shouldHideThreadDividerLine}
shouldDisplayNewMarker={reportAction.reportActionID === unreadMarkerReportActionID}
Expand Down

0 comments on commit cc7ac35

Please sign in to comment.