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 ),
|
storage = new MemoryStorage( mw.storage.session.store ),
|
||||||
Parser = require( './Parser.js' ),
|
Parser = require( './Parser.js' ),
|
||||||
ThreadItemSet = require( './ThreadItemSet.js' ),
|
ThreadItemSet = require( './ThreadItemSet.js' ),
|
||||||
|
CommentItem = require( './CommentItem.js' ),
|
||||||
CommentDetails = require( './CommentDetails.js' ),
|
CommentDetails = require( './CommentDetails.js' ),
|
||||||
ReplyLinksController = require( './ReplyLinksController.js' ),
|
ReplyLinksController = require( './ReplyLinksController.js' ),
|
||||||
logger = require( './logger.js' ),
|
logger = require( './logger.js' ),
|
||||||
|
@ -291,6 +292,20 @@ function init( $container, state ) {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
commentController.on( 'reloadPage', function () {
|
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)
|
// Teardown active reply widget(s)
|
||||||
commentController.replyWidgetPromise.then( function ( replyWidget ) {
|
commentController.replyWidgetPromise.then( function ( replyWidget ) {
|
||||||
lastControllerScrollOffset = $( commentController.newListItem ).offset().top;
|
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
|
// Check topic subscription states if the user has automatic subscriptions enabled
|
||||||
|
@ -416,7 +433,9 @@ function init( $container, state ) {
|
||||||
} );
|
} );
|
||||||
pageHandlersSetup = true;
|
pageHandlersSetup = true;
|
||||||
}
|
}
|
||||||
|
if ( state.firstLoad ) {
|
||||||
highlighter.highlightTargetComment( pageThreads );
|
highlighter.highlightTargetComment( pageThreads );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -294,6 +294,7 @@ module.exports = {
|
||||||
highlight: highlight,
|
highlight: highlight,
|
||||||
highlightTargetComment: highlightTargetComment,
|
highlightTargetComment: highlightTargetComment,
|
||||||
highlightPublishedComment: highlightPublishedComment,
|
highlightPublishedComment: highlightPublishedComment,
|
||||||
|
highlightNewComments: highlightNewComments,
|
||||||
clearHighlightTargetComment: clearHighlightTargetComment,
|
clearHighlightTargetComment: clearHighlightTargetComment,
|
||||||
getLastHighlightedPublishedComment: getLastHighlightedPublishedComment
|
getLastHighlightedPublishedComment: getLastHighlightedPublishedComment
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue