@@ -391,11 +391,16 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
391391 // Call resize to recalculate the dimensions.
392392 this . content && this . content . resize ( ) ;
393393
394+ // If we received a new message while using group messaging, force mark messages as read.
395+ const last = this . messages [ this . messages . length - 1 ] ,
396+ forceMark = this . groupMessagingEnabled && last && last . useridfrom != this . currentUserId && this . lastMessage . text != ''
397+ && ( last . text !== this . lastMessage . text || last . timecreated !== this . lastMessage . timecreated ) ;
398+
394399 // Notify that there can be a new message.
395400 this . notifyNewMessage ( ) ;
396401
397402 // Mark retrieved messages as read if they are not.
398- this . markMessagesAsRead ( ) ;
403+ this . markMessagesAsRead ( forceMark ) ;
399404 }
400405
401406 /**
@@ -577,15 +582,17 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
577582 /**
578583 * Mark messages as read.
579584 */
580- protected markMessagesAsRead ( ) : void {
585+ protected markMessagesAsRead ( forceMark : boolean ) : void {
581586 let readChanged = false ;
582587 const promises = [ ] ;
583588
584589 if ( this . messagesProvider . isMarkAllMessagesReadEnabled ( ) ) {
585590 let messageUnreadFound = false ;
586591
587592 // Mark all messages at a time if there is any unread message.
588- if ( this . groupMessagingEnabled ) {
593+ if ( forceMark ) {
594+ messageUnreadFound = true ;
595+ } else if ( this . groupMessagingEnabled ) {
589596 messageUnreadFound = this . conversation && this . conversation . unreadcount > 0 && this . conversationId > 0 ;
590597 } else {
591598 for ( const x in this . messages ) {
@@ -649,6 +656,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
649656 const last = this . messages [ this . messages . length - 1 ] ;
650657
651658 let trigger = false ;
659+
652660 if ( ! last ) {
653661 this . lastMessage = { text : '' , timecreated : 0 } ;
654662 trigger = true ;
0 commit comments