From c59f5ab4e989c07a25fae02f2e1e0b3b37627f31 Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Thu, 15 Jul 2021 17:04:55 +0200 Subject: [PATCH] Remove unnecessary calls to updateLastRead --- src/libs/actions/Report.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index b7f52429555d..b82d0ad9ca16 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1132,6 +1132,11 @@ function updateLastReadActionID(reportID, sequenceNumber) { // action). If 1 isn't subtracted then the "New" marker appears one row below the action (the first unread action) const lastReadSequenceNumber = (sequenceNumber - 1) || reportMaxSequenceNumbers[reportID]; + // We call this method in many cases where there's nothing to update because we already updated it, so we avoid + // doing an unnecessary server call if the last read is the same one we had already + if (lastReadSequenceNumbers[reportID] === lastReadSequenceNumber) { + return; + } setLocalLastRead(reportID, lastReadSequenceNumber); // Mark the report as not having any unread items