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

Change subject: Change how addSelf function works
......................................................................


Change how addSelf function works

Before, I had it do an API lookup to get a URL. This added a lot
of complication to the process and it turns out I can synthesize
the URL myself using the page ID. So I got rid of all that and
made the process a lot more efficient.

Bug: T163410
Change-Id: I146caa1f9574ea1e2f04d1e8315fed4c331565fc
---
M modules/ext.CollaborationKit.list.members.js
1 file changed, 11 insertions(+), 20 deletions(-)

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



diff --git a/modules/ext.CollaborationKit.list.members.js 
b/modules/ext.CollaborationKit.list.members.js
index 67cc895..9dd1bf3 100644
--- a/modules/ext.CollaborationKit.list.members.js
+++ b/modules/ext.CollaborationKit.list.members.js
@@ -53,9 +53,8 @@
         * One-click project-joining button
         *
         * @param {number} destinationPage Page ID of member list, if different 
from current page
-        * @param {string} destinationUrl Full URL of member list, if different 
from current page
         */
-       addSelf = function ( destinationPage, destinationUrl ) {
+       addSelf = function ( destinationPage ) {
                if ( destinationPage === undefined ) {
                        destinationPage = mw.config.get( 'wgArticleId' );
                }
@@ -84,37 +83,29 @@
                        res.content.columns[ 0 ].items[ index ] = itemToAdd;
                        res.summary = mw.msg( 
'collaborationkit-list-add-self-summary', itemToAdd.title );
                        LE.saveJson( res, function () {
-                               if ( destinationUrl === undefined ) {
-                                       location.reload();
-                               } else {
-                                       window.location = destinationUrl;
-                               }
+                               window.location.href = mw.config.get( 
'wgScriptPath' ) + '?curid=' + destinationPage;
                        } );
                } );
 
        };
 
        $( function () {
-               var memberListPage, list;
+               var memberListPage, memberListUrl, list;
                // Workflow assumes existence of username, so we filter against 
it
                // However, since !curUserIsInList, the button will still 
render. It will just use no-JS
                // behavior instead.
                if ( mw.config.get( 'wgCollaborationKitAssociatedMemberList' ) 
&& !mw.user.isAnon() ) {
                        memberListPage = mw.config.get( 
'wgCollaborationKitAssociatedMemberList' );
                        curUserIsInList( memberListPage ); // removes Join 
button if user already is member
-                       new mw.Api().get( {
-                               action: 'query',
-                               prop: 'info',
-                               inprop: 'url',
-                               pageids: memberListPage
-                       } ).done( function ( data ) {
-                               var memberListUrl = data.query.pages[ 
memberListPage ].fullurl;
-                               $( '.mw-ck-members-join a' )
-                                       .attr( 'href', memberListUrl );
 
-                               $( '.mw-ck-members-join' ).on( 'click', 
function () {
-                                       addSelf( memberListPage, memberListUrl 
);
-                               } );
+                       memberListUrl = mw.config.get( 'wgScriptPath' ) + 
'?curid=' + memberListPage;
+
+                       $( '.mw-ck-members-join a' )
+                               .attr( 'href', memberListUrl );
+
+                       $( '.mw-ck-members-join' ).on( 'click', function () {
+                               event.preventDefault();
+                               addSelf( memberListPage );
                        } );
                }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I146caa1f9574ea1e2f04d1e8315fed4c331565fc
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/CollaborationKit
Gerrit-Branch: master
Gerrit-Owner: Harej <jamesmh...@gmail.com>
Gerrit-Reviewer: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: Isarra <zhoris...@gmail.com>
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