Merge extra arguments to highlightNewComments into 'options'

Change-Id: I2e459b380ee8e1a63af5502eecf166189c9f6916
This commit is contained in:
Ed Sanders 2023-03-30 16:40:52 +01:00
parent 0b760155f9
commit fd45c64491

View file

@ -202,8 +202,10 @@ function highlightTargetComment( threadItemSet, noScroll ) {
threadItemSet, threadItemSet,
noScroll, noScroll,
url.searchParams.get( 'dtnewcomments' ) && url.searchParams.get( 'dtnewcomments' ).split( '|' ), url.searchParams.get( 'dtnewcomments' ) && url.searchParams.get( 'dtnewcomments' ).split( '|' ),
url.searchParams.get( 'dtnewcommentssince' ), {
url.searchParams.get( 'dtinthread' ) newCommentsSinceId: url.searchParams.get( 'dtnewcommentssince' ),
inThread: url.searchParams.get( 'dtinthread' )
}
); );
} }
@ -288,26 +290,28 @@ function highlightPublishedComment( threadItemSet, threadItemId ) {
* @param {ThreadItemSet} threadItemSet * @param {ThreadItemSet} threadItemSet
* @param {boolean} [noScroll] Don't scroll to the topmost highlighted comment, e.g. on popstate * @param {boolean} [noScroll] Don't scroll to the topmost highlighted comment, e.g. on popstate
* @param {string[]} [newCommentIds] A list of comment IDs to highlight * @param {string[]} [newCommentIds] A list of comment IDs to highlight
* @param {string} [newCommentsSinceId] Highlight all comments after the comment with this ID * @param {Object} [options] Extra options
* @param {boolean} [inThread] When using newCommentsSinceId, only highlight comments in the same thread * @param {string} [options.newCommentsSinceId] Highlight all comments after the comment with this ID
* @param {boolean} [options.inThread] When using newCommentsSinceId, only highlight comments in the same thread
*/ */
function highlightNewComments( threadItemSet, noScroll, newCommentIds, newCommentsSinceId, inThread ) { function highlightNewComments( threadItemSet, noScroll, newCommentIds, options ) {
if ( highlightedTarget ) { if ( highlightedTarget ) {
highlightedTarget.destroy(); highlightedTarget.destroy();
highlightedTarget = null; highlightedTarget = null;
} }
newCommentIds = newCommentIds || []; newCommentIds = newCommentIds || [];
options = options || {};
var highlightsRequested = newCommentIds.length || newCommentsSinceId; var highlightsRequested = newCommentIds.length || options.newCommentsSinceId;
var highlightsRequestedSingle = !newCommentsSinceId && newCommentIds.length === 1; var highlightsRequestedSingle = !options.newCommentsSinceId && newCommentIds.length === 1;
if ( newCommentsSinceId ) { if ( options.newCommentsSinceId ) {
var newCommentsSince = threadItemSet.findCommentById( newCommentsSinceId ); var newCommentsSince = threadItemSet.findCommentById( options.newCommentsSinceId );
if ( newCommentsSince && newCommentsSince instanceof CommentItem ) { if ( newCommentsSince && newCommentsSince instanceof CommentItem ) {
var sinceTimestamp = newCommentsSince.timestamp; var sinceTimestamp = newCommentsSince.timestamp;
var threadItems; var threadItems;
if ( inThread ) { if ( options.inThread ) {
var heading = newCommentsSince.getSubscribableHeading() || newCommentsSince.getHeading(); var heading = newCommentsSince.getSubscribableHeading() || newCommentsSince.getHeading();
threadItems = heading.getThreadItemsBelow(); threadItems = heading.getThreadItemsBelow();
} else { } else {