Skip to content

Commit

Permalink
optimize for fewer state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arosiclair committed Jul 25, 2024
1 parent 9a4119f commit 716cd09
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,15 @@ function ReportActionsList({
return;
}

setUnreadMarkerTime(sortedVisibleReportActions[0]?.created ?? '');
}, [unreadMarkerReportActionID, sortedVisibleReportActions]);
const mostRecentReportActionCreated = sortedVisibleReportActions[0]?.created ?? '';
if (mostRecentReportActionCreated <= unreadMarkerTime) {
return;
}

setUnreadMarkerTime(mostRecentReportActionCreated);

// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [sortedVisibleReportActions]);

const lastActionIndex = sortedVisibleReportActions[0]?.reportActionID;
const reportActionSize = useRef(sortedVisibleReportActions.length);
Expand Down

0 comments on commit 716cd09

Please sign in to comment.