mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
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:
parent
4134a80fdc
commit
457f6eb7d1
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue