Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed user's own message is unread on different plaforms #2059

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function removeOptimisticActions(reportID) {
function updateReportWithNewAction(reportID, reportAction) {
const newMaxSequenceNumber = reportAction.sequenceNumber;
const isFromCurrentUser = reportAction.actorAccountID === currentUserAccountID;
const lastReadSequenceNumber = lastReadSequenceNumbers[reportID] || 0;
const initialLastReadSequenceNumber = lastReadSequenceNumbers[reportID] || 0;

// When handling an action from the current users we can assume that their
// last read actionID has been updated in the server but not necessarily reflected
Expand All @@ -352,13 +352,15 @@ function updateReportWithNewAction(reportID, reportAction) {
// by handleReportChanged
const updatedReportObject = {
reportID,
unreadActionCount: newMaxSequenceNumber - lastReadSequenceNumber,
parasharrajat marked this conversation as resolved.
Show resolved Hide resolved

// Use updated lastReadSequenceNumber, value may have been modified by setLocalLastRead
unreadActionCount: newMaxSequenceNumber - (lastReadSequenceNumbers[reportID] || 0),
maxSequenceNumber: reportAction.sequenceNumber,
};

// If the report action from pusher is a higher sequence number than we know about (meaning it has come from
// a chat participant in another application), then the last message text and author needs to be updated as well
if (newMaxSequenceNumber > lastReadSequenceNumber) {
if (newMaxSequenceNumber > initialLastReadSequenceNumber) {
updatedReportObject.lastMessageTimestamp = reportAction.timestamp;
updatedReportObject.lastMessageText = messageText;
updatedReportObject.lastActorEmail = reportAction.actorEmail;
Expand Down