From 6a85dc6610c73d5570de0ce78cbe870d826e7d91 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 4 Dec 2024 22:11:37 +0800 Subject: [PATCH 1/5] fix new msg marker shows when the last action is a transaction thread system message in a one-expense report --- src/pages/home/report/ReportActionsList.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index ff6f635e3c6f..4b0d390782bc 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -211,6 +211,11 @@ function ReportActionsList({ return ReportConnection.getReport(report.reportID)?.lastReadTime ?? report.lastReadTime ?? ''; }, [report.reportID, report.lastReadTime]); + const lastReadTime = + (transactionThreadReport?.lastReadTime ?? '') > reportLastReadTime + ? transactionThreadReport?.lastReadTime + : reportLastReadTime; + /** * The timestamp for the unread marker. * @@ -219,9 +224,9 @@ function ReportActionsList({ * - marks a message as read/unread * - reads a new message as it is received */ - const [unreadMarkerTime, setUnreadMarkerTime] = useState(reportLastReadTime); + const [unreadMarkerTime, setUnreadMarkerTime] = useState(lastReadTime); useEffect(() => { - setUnreadMarkerTime(reportLastReadTime); + setUnreadMarkerTime(lastReadTime); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [report.reportID]); From e1bc9e5ab02fb21b1b21c4426bb100aeffb05e7a Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 4 Dec 2024 22:39:42 +0800 Subject: [PATCH 2/5] prettier --- src/pages/home/report/ReportActionsList.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 4b0d390782bc..98b16350b4ff 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -211,10 +211,7 @@ function ReportActionsList({ return ReportConnection.getReport(report.reportID)?.lastReadTime ?? report.lastReadTime ?? ''; }, [report.reportID, report.lastReadTime]); - const lastReadTime = - (transactionThreadReport?.lastReadTime ?? '') > reportLastReadTime - ? transactionThreadReport?.lastReadTime - : reportLastReadTime; + const lastReadTime = (transactionThreadReport?.lastReadTime ?? '') > reportLastReadTime ? transactionThreadReport?.lastReadTime : reportLastReadTime; /** * The timestamp for the unread marker. From 6980a2a991cd1373e97b1367d08d980667073ce3 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 5 Dec 2024 11:09:02 +0800 Subject: [PATCH 3/5] fix type --- src/pages/home/report/ReportActionsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 3341307f9d41..cf1e87366639 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -211,7 +211,7 @@ function ReportActionsList({ return ReportConnection.getReport(report.reportID)?.lastReadTime ?? report.lastReadTime ?? ''; }, [report.reportID, report.lastReadTime]); - const lastReadTime = (transactionThreadReport?.lastReadTime ?? '') > reportLastReadTime ? transactionThreadReport?.lastReadTime : reportLastReadTime; + const lastReadTime = transactionThreadReport?.lastReadTime && transactionThreadReport.lastReadTime > reportLastReadTime ? transactionThreadReport.lastReadTime : reportLastReadTime; /** * The timestamp for the unread marker. From 040a8d67a4f70293330052519310096feaed687a Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 6 Dec 2024 12:03:11 +0800 Subject: [PATCH 4/5] add comment --- src/pages/home/report/ReportActionsList.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index cf1e87366639..fbe0a0e3a084 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -211,6 +211,11 @@ function ReportActionsList({ return ReportConnection.getReport(report.reportID)?.lastReadTime ?? report.lastReadTime ?? ''; }, [report.reportID, report.lastReadTime]); + // In a one-expense report, the report actions from the expense report and transaction thread are combined. + // If the transaction thread has a newer action, it will show an unread marker if we compare it with the expense report lastReadTime. + // - expense report action A <- expense report lastReadTime + // - transaction thread action A <- transaction thread lastReadTime + // So, we use whichever lastReadTime that is bigger. const lastReadTime = transactionThreadReport?.lastReadTime && transactionThreadReport.lastReadTime > reportLastReadTime ? transactionThreadReport.lastReadTime : reportLastReadTime; /** From 8f4ab74cb8897cc4c3fd6ed56bb4dc76bb651762 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 6 Dec 2024 18:52:04 +0800 Subject: [PATCH 5/5] prettier --- src/pages/home/report/ReportActionsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index fbe0a0e3a084..24119bedaa8c 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -211,7 +211,7 @@ function ReportActionsList({ return ReportConnection.getReport(report.reportID)?.lastReadTime ?? report.lastReadTime ?? ''; }, [report.reportID, report.lastReadTime]); - // In a one-expense report, the report actions from the expense report and transaction thread are combined. + // In a one-expense report, the report actions from the expense report and transaction thread are combined. // If the transaction thread has a newer action, it will show an unread marker if we compare it with the expense report lastReadTime. // - expense report action A <- expense report lastReadTime // - transaction thread action A <- transaction thread lastReadTime