Skip to content

Commit caa4d9e

Browse files
committed
MOBILE-3039 messages: Fix mark as read not called in 3.6+
1 parent ed35e57 commit caa4d9e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/addon/messages/pages/discussion/discussion.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,16 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
390390
// Call resize to recalculate the dimensions.
391391
this.content && this.content.resize();
392392

393+
// If we received a new message while using group messaging, force mark messages as read.
394+
const last = this.messages[this.messages.length - 1],
395+
forceMark = this.groupMessagingEnabled && last && last.useridfrom != this.currentUserId && this.lastMessage.text != ''
396+
&& (last.text !== this.lastMessage.text || last.timecreated !== this.lastMessage.timecreated);
397+
393398
// Notify that there can be a new message.
394399
this.notifyNewMessage();
395400

396401
// Mark retrieved messages as read if they are not.
397-
this.markMessagesAsRead();
402+
this.markMessagesAsRead(forceMark);
398403
}
399404

400405
/**
@@ -576,15 +581,17 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
576581
/**
577582
* Mark messages as read.
578583
*/
579-
protected markMessagesAsRead(): void {
584+
protected markMessagesAsRead(forceMark: boolean): void {
580585
let readChanged = false;
581586
const promises = [];
582587

583588
if (this.messagesProvider.isMarkAllMessagesReadEnabled()) {
584589
let messageUnreadFound = false;
585590

586591
// Mark all messages at a time if there is any unread message.
587-
if (this.groupMessagingEnabled) {
592+
if (forceMark) {
593+
messageUnreadFound = true;
594+
} else if (this.groupMessagingEnabled) {
588595
messageUnreadFound = this.conversation && this.conversation.unreadcount > 0 && this.conversationId > 0;
589596
} else {
590597
for (const x in this.messages) {
@@ -648,6 +655,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
648655
const last = this.messages[this.messages.length - 1];
649656

650657
let trigger = false;
658+
651659
if (!last) {
652660
this.lastMessage = {text: '', timecreated: 0};
653661
trigger = true;

0 commit comments

Comments
 (0)