jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/405380 )

Change subject: revthank: Embed gender of thanks recipients in the page
......................................................................


revthank: Embed gender of thanks recipients in the page

That way we don't have to do an API request to get the gender,
and we'll also be able to use gender-sensitive messages in the
confirmation step.

Bug: T159302
Change-Id: I9097bd976f8da1632577a3f4438b9f1186baca88
---
M Thanks.hooks.php
M modules/ext.thanks.revthank.js
2 files changed, 8 insertions(+), 15 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/Thanks.hooks.php b/Thanks.hooks.php
index a55c7fb..e325d98 100644
--- a/Thanks.hooks.php
+++ b/Thanks.hooks.php
@@ -113,6 +113,7 @@
                                'href' => SpecialPage::getTitleFor( 'Thanks', 
$rev->getId() )->getFullURL(),
                                'title' => $tooltip,
                                'data-revision-id' => $rev->getId(),
+                               'data-recipient-gender' => 
$recipient->getOption( 'gender' ) ?: 'unknown',
                        ],
                        wfMessage( 'thanks-thank', $wgUser, 
$recipient->getName() )->text()
                );
diff --git a/modules/ext.thanks.revthank.js b/modules/ext.thanks.revthank.js
index 872703d..e577d28 100644
--- a/modules/ext.thanks.revthank.js
+++ b/modules/ext.thanks.revthank.js
@@ -36,11 +36,9 @@
                        .then(
                                // Success
                                function () {
-                                       var username = $thankLink.closest(
-                                               source === 'history' ? 'li' : 
'td'
-                                       ).find( 'a.mw-userlink' ).text();
-                                       // Get the user who was thanked (for 
gender purposes)
-                                       return mw.thanks.getUserGender( 
username );
+                                       $thankElement.before( mw.message( 
'thanks-thanked', mw.user, $thankLink.data( 'recipient-gender' ) ).escaped() );
+                                       $thankElement.remove();
+                                       mw.thanks.thanked.push( $thankLink );
                                },
                                // Fail
                                function ( errorCode ) {
@@ -57,31 +55,25 @@
                                                        OO.ui.alert( mw.msg( 
'thanks-error-undefined', errorCode ) );
                                        }
                                }
-                       )
-                       .then( function ( recipientGender ) {
-                               $thankElement.before( mw.message( 
'thanks-thanked', mw.user, recipientGender ).escaped() );
-                               $thankElement.remove();
-                               mw.thanks.thanked.push( $thankLink );
-                       } );
+                       );
        }
 
        function addActionToLinks( $content ) {
+               var $thankLink = $content.find( 'a.mw-thanks-thank-link' );
                if ( mw.config.get( 'thanks-confirmation-required' ) ) {
-                       $content.find( 'a.mw-thanks-thank-link' ).confirmable( {
+                       $thankLink.confirmable( {
                                i18n: {
                                        confirm: mw.msg( 
'thanks-confirmation2', mw.user ),
                                        noTitle: mw.msg( 
'thanks-thank-tooltip-no', mw.user ),
                                        yesTitle: mw.msg( 
'thanks-thank-tooltip-yes', mw.user )
                                },
                                handler: function ( e ) {
-                                       var $thankLink = $( this );
                                        e.preventDefault();
                                        sendThanks( $thankLink, 
$thankLink.closest( '.jquery-confirmable-wrapper' ) );
                                }
                        } );
                } else {
-                       $content.find( 'a.mw-thanks-thank-link' ).click( 
function ( e ) {
-                               var $thankLink = $( this );
+                       $thankLink.click( function ( e ) {
                                e.preventDefault();
                                sendThanks( $thankLink, $thankLink );
                        } );

-- 
To view, visit https://gerrit.wikimedia.org/r/405380
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9097bd976f8da1632577a3f4438b9f1186baca88
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Thanks
Gerrit-Branch: master
Gerrit-Owner: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to