mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-18 02:51:26 +00:00
Highlight new comments when refreshing
Bug: T300215 Change-Id: I72655e05dccbe96f9dfa4ccca4e91b3edf133d97
This commit is contained in:
parent
487be9e202
commit
4f91a0b883
|
@ -9,6 +9,7 @@ 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' ),
|
||||
|
@ -291,6 +292,20 @@ 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;
|
||||
}
|
||||
}
|
||||
// Teardown active reply widget(s)
|
||||
commentController.replyWidgetPromise.then( function ( replyWidget ) {
|
||||
lastControllerScrollOffset = $( commentController.newListItem ).offset().top;
|
||||
|
@ -387,6 +402,8 @@ function init( $container, state ) {
|
|||
} );
|
||||
}
|
||||
}
|
||||
} else if ( state.newCommentsSinceId ) {
|
||||
highlighter.highlightNewComments( pageThreads, true, [], state.newCommentsSinceId, true );
|
||||
}
|
||||
|
||||
// Check topic subscription states if the user has automatic subscriptions enabled
|
||||
|
@ -416,7 +433,9 @@ function init( $container, state ) {
|
|||
} );
|
||||
pageHandlersSetup = true;
|
||||
}
|
||||
if ( state.firstLoad ) {
|
||||
highlighter.highlightTargetComment( pageThreads );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -294,6 +294,7 @@ module.exports = {
|
|||
highlight: highlight,
|
||||
highlightTargetComment: highlightTargetComment,
|
||||
highlightPublishedComment: highlightPublishedComment,
|
||||
highlightNewComments: highlightNewComments,
|
||||
clearHighlightTargetComment: clearHighlightTargetComment,
|
||||
getLastHighlightedPublishedComment: getLastHighlightedPublishedComment
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue