Skip to content

Commit

Permalink
Refactor markCommentAsUnread to use reportActionTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetlath committed Dec 12, 2022
1 parent ed866d3 commit 9b5e726
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,23 +696,20 @@ function readNewestAction(reportID, created) {
* @param {String} created
* @param {Number} sequenceNumber
*/
function markCommentAsUnread(reportID, created, sequenceNumber) {
const newLastReadSequenceNumber = sequenceNumber - 1;
function markCommentAsUnread(reportID, created) {
// We subtract 1 millisecond so that the lastRead is updated to just before this reportAction's created date
const lastRead = DateUtils.getDBTime(new Date(created) - 1);
API.write('MarkAsUnread',
{
reportID,

// We subtract 1 millisecond so that the lastRead is updated to just before this reportAction's created date
created: DateUtils.getDBTime(new Date(created) - 1),
sequenceNumber,
created: lastRead,
},
{
optimisticData: [{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
lastReadSequenceNumber: newLastReadSequenceNumber,
lastReadTimestamp: Date.now(),
lastReadTimestamp: Date.parse(lastRead),
},
}],
});
Expand Down

0 comments on commit 9b5e726

Please sign in to comment.