mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
Ensure highlighted comment is defined before we try to show auto topic sub popup next to it
This was a logical merge conflict between4912a1bf5c
and9ded06a655
that I didn't notice when rebasing the latter. Waiting for the 'mobile.init' module to load changes the order of operations if we're highlighting the new comment after reloading a page, which we also do after creating new talk page with the new topic tool. Bug: T295945 Change-Id: Ief4810cc67c1bda9256585da1e2140b3a222dc5e
This commit is contained in:
parent
0110fe8b8d
commit
b3b28dd1ab
|
@ -779,42 +779,42 @@ function init( $container, state ) {
|
|||
}, 3000 );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
// Check topic subscription states if the user has automatic subscriptions enabled
|
||||
// and has recently edited this page.
|
||||
if ( featuresEnabled.autotopicsub && mw.user.options.get( 'discussiontools-autotopicsub' ) ) {
|
||||
var recentComments = [];
|
||||
var headingsToUpdate = {};
|
||||
if ( state.repliedTo ) {
|
||||
// Edited by using the reply tool or new topic tool. Only check the edited topic.
|
||||
if ( state.repliedTo === utils.NEW_TOPIC_COMMENT_ID ) {
|
||||
recentComments.push( threadItems[ threadItems.length - 1 ] );
|
||||
} else {
|
||||
recentComments.push( threadItemsById[ state.repliedTo ] );
|
||||
}
|
||||
} else if ( mw.config.get( 'wgPostEdit' ) ) {
|
||||
// Edited by using wikitext editor. Check topics with their own comments within last minute.
|
||||
for ( i = 0; i < threadItems.length; i++ ) {
|
||||
if (
|
||||
threadItems[ i ] instanceof CommentItem &&
|
||||
threadItems[ i ].author === mw.user.getName() &&
|
||||
threadItems[ i ].timestamp.isSameOrAfter( moment().subtract( 1, 'minute' ), 'minute' )
|
||||
) {
|
||||
recentComments.push( threadItems[ i ] );
|
||||
// Check topic subscription states if the user has automatic subscriptions enabled
|
||||
// and has recently edited this page.
|
||||
if ( featuresEnabled.autotopicsub && mw.user.options.get( 'discussiontools-autotopicsub' ) ) {
|
||||
var recentComments = [];
|
||||
var headingsToUpdate = {};
|
||||
if ( state.repliedTo ) {
|
||||
// Edited by using the reply tool or new topic tool. Only check the edited topic.
|
||||
if ( state.repliedTo === utils.NEW_TOPIC_COMMENT_ID ) {
|
||||
recentComments.push( threadItems[ threadItems.length - 1 ] );
|
||||
} else {
|
||||
recentComments.push( threadItemsById[ state.repliedTo ] );
|
||||
}
|
||||
} else if ( mw.config.get( 'wgPostEdit' ) ) {
|
||||
// Edited by using wikitext editor. Check topics with their own comments within last minute.
|
||||
for ( i = 0; i < threadItems.length; i++ ) {
|
||||
if (
|
||||
threadItems[ i ] instanceof CommentItem &&
|
||||
threadItems[ i ].author === mw.user.getName() &&
|
||||
threadItems[ i ].timestamp.isSameOrAfter( moment().subtract( 1, 'minute' ), 'minute' )
|
||||
) {
|
||||
recentComments.push( threadItems[ i ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( i = 0; i < recentComments.length; i++ ) {
|
||||
var headingItem = recentComments[ i ].getHeading();
|
||||
while ( headingItem instanceof HeadingItem && headingItem.headingLevel !== 2 ) {
|
||||
headingItem = headingItem.parent;
|
||||
for ( i = 0; i < recentComments.length; i++ ) {
|
||||
var headingItem = recentComments[ i ].getHeading();
|
||||
while ( headingItem instanceof HeadingItem && headingItem.headingLevel !== 2 ) {
|
||||
headingItem = headingItem.parent;
|
||||
}
|
||||
// Use names as object keys to deduplicate if there are multiple comments in a topic.
|
||||
headingsToUpdate[ headingItem.name ] = headingItem;
|
||||
}
|
||||
// Use names as object keys to deduplicate if there are multiple comments in a topic.
|
||||
headingsToUpdate[ headingItem.name ] = headingItem;
|
||||
updateSubscriptionStates( $container, headingsToUpdate );
|
||||
}
|
||||
updateSubscriptionStates( $container, headingsToUpdate );
|
||||
}
|
||||
} );
|
||||
|
||||
// Preload page metadata.
|
||||
// TODO: Isn't this too early to load it? We will only need it if the user tries replying...
|
||||
|
|
Loading…
Reference in a new issue