mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-01 03:26:28 +00:00
Merge "Fix highlight when new topic is posted without a title"
This commit is contained in:
commit
872867c422
|
@ -222,7 +222,7 @@ function getCheckboxesPromise( pageName, oldId ) {
|
||||||
|
|
||||||
function init( $container, state ) {
|
function init( $container, state ) {
|
||||||
var parser, pageThreads,
|
var parser, pageThreads,
|
||||||
repliedToComment,
|
repliedToComment, lastComment,
|
||||||
$addSectionTab,
|
$addSectionTab,
|
||||||
i, hash, comment, commentNodes, newId,
|
i, hash, comment, commentNodes, newId,
|
||||||
pageExists = !!mw.config.get( 'wgRelevantArticleId' ),
|
pageExists = !!mw.config.get( 'wgRelevantArticleId' ),
|
||||||
|
@ -332,8 +332,19 @@ function init( $container, state ) {
|
||||||
mw.dt.pageThreads = pageThreads;
|
mw.dt.pageThreads = pageThreads;
|
||||||
|
|
||||||
if ( state.repliedTo === 'new' ) {
|
if ( state.repliedTo === 'new' ) {
|
||||||
highlight( pageThreads[ pageThreads.length - 1 ] );
|
// Highlight the last comment on the page
|
||||||
highlight( pageThreads[ pageThreads.length - 1 ].replies[ 0 ] );
|
lastComment = threadItems[ threadItems.length - 1 ];
|
||||||
|
highlight( lastComment );
|
||||||
|
|
||||||
|
// If it's the only comment under its heading, highlight the heading too.
|
||||||
|
// (It might not be if the new discussion topic was posted without a title: T272666.)
|
||||||
|
if (
|
||||||
|
lastComment.parent &&
|
||||||
|
lastComment.parent.type === 'heading' &&
|
||||||
|
lastComment.parent.replies.length === 1
|
||||||
|
) {
|
||||||
|
highlight( lastComment.parent );
|
||||||
|
}
|
||||||
|
|
||||||
mw.hook( 'postEdit' ).fire( {
|
mw.hook( 'postEdit' ).fire( {
|
||||||
message: mw.msg( 'discussiontools-postedit-confirmation-topicadded', mw.user )
|
message: mw.msg( 'discussiontools-postedit-confirmation-topicadded', mw.user )
|
||||||
|
|
Loading…
Reference in a new issue