@@ -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