Fix highlighting of comments when reloading

The CommentController stores a list of the new comments that
triggered the reload warning. Just highlight all the comments
in this list, as we always reload to the revision we got from
the same API call.

Bug: T303261
Change-Id: I960f3cf33e25004bad6ab6df907121a87555aaf4
This commit is contained in:
Ed Sanders 2022-03-08 23:09:30 +00:00
parent 4134a80fdc
commit 457f6eb7d1

View file

@ -9,7 +9,6 @@ var
storage = new MemoryStorage( mw.storage.session.store ),
Parser = require( './Parser.js' ),
ThreadItemSet = require( './ThreadItemSet.js' ),
CommentItem = require( './CommentItem.js' ),
CommentDetails = require( './CommentDetails.js' ),
ReplyLinksController = require( './ReplyLinksController.js' ),
logger = require( './logger.js' ),
@ -292,20 +291,9 @@ function init( $container, state ) {
}
} );
commentController.on( 'reloadPage', function () {
if ( commentController.threadItem instanceof CommentItem ) {
var heading = commentController.threadItem.getSubscribableHeading() || commentController.threadItem.getHeading();
var newestTimestamp = 0;
var newestThreadItem = null;
heading.getThreadItemsBelow().forEach( function ( threadItem ) {
if ( threadItem instanceof CommentItem && threadItem.timestamp > newestTimestamp ) {
newestThreadItem = threadItem;
newestTimestamp = threadItem.timestamp;
}
} );
if ( newestThreadItem ) {
mw.dt.initState.newCommentsSinceId = newestThreadItem.id;
}
}
mw.dt.initState.newCommentIds = commentController.newComments.map( function ( cmt ) {
return cmt.id;
} );
// Teardown active reply widget(s)
commentController.replyWidgetPromise.then( function ( replyWidget ) {
lastControllerScrollOffset = $( commentController.newListItem ).offset().top;
@ -402,8 +390,8 @@ function init( $container, state ) {
} );
}
}
} else if ( state.newCommentsSinceId ) {
highlighter.highlightNewComments( pageThreads, true, [], state.newCommentsSinceId, true );
} else if ( state.newCommentIds ) {
highlighter.highlightNewComments( pageThreads, true, state.newCommentIds );
}
// Check topic subscription states if the user has automatic subscriptions enabled