Merge "Invert logic on empty talk page"

This commit is contained in:
jenkins-bot 2024-08-15 20:56:39 +00:00 committed by Gerrit Code Review
commit 2a6100b294
3 changed files with 6 additions and 6 deletions

View file

@ -410,8 +410,8 @@ class CommentFormatter {
->addTrackingCategory( $pout, 'discussiontools-comments-before-first-heading-category', $title );
}
if ( count( $threadItems ) === 0 ) {
$pout->setExtensionData( 'DiscussionTools-isEmptyTalkPage', true );
if ( count( $threadItems ) > 0 ) {
$pout->setExtensionData( 'DiscussionTools-isNotEmptyTalkPage', true );
}
$threadsJSON = array_map( static function ( ContentThreadItem $item ) {
@ -918,7 +918,7 @@ class CommentFormatter {
* Check if the talk page had no comments or headings.
*/
public static function isEmptyTalkPage( ParserOutput $pout ): bool {
return $pout->getExtensionData( 'DiscussionTools-isEmptyTalkPage' ) === true;
return $pout->getExtensionData( 'DiscussionTools-isNotEmptyTalkPage' ) !== true;
}
/**

View file

@ -72,7 +72,7 @@ class ParserHooks implements
if ( $isPreview ) {
$html = CommentFormatter::removeInteractiveTools( $html );
// Suppress the empty state
$pout->setExtensionData( 'DiscussionTools-isEmptyTalkPage', null );
$pout->setExtensionData( 'DiscussionTools-isNotEmptyTalkPage', true );
}
$pout->addModuleStyles( [ 'ext.discussionTools.init.styles' ] );

View file

@ -95,8 +95,8 @@ class CommentFormatterTest extends IntegrationTestCase {
"hasLedeContent\n" : '' ) .
( $pout->getExtensionData( 'DiscussionTools-hasCommentsInLedeContent' ) ?
"hasCommentsInLedeContent\n" : '' ) .
( $pout->getExtensionData( 'DiscussionTools-isEmptyTalkPage' ) ?
"isEmptyTalkPage\n" : '' ) .
( $pout->getExtensionData( 'DiscussionTools-isNotEmptyTalkPage' ) ?
'' : "isEmptyTalkPage\n" ) .
FormatJson::encode( $pout->getJsConfigVars(), "\t", FormatJson::ALL_OK ) .
"\n</pre>";