Merge "Use new isTalkPage/isTalkNamespace methods"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 19 Sep 2018 17:20:53 +0000 (17:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 19 Sep 2018 17:20:53 +0000 (17:20 +0000)
resources/src/mediawiki.page.watch.ajax.js
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.special.watchlist/watchlist.js

index 1b401c7..f7fbeef 100644 (file)
                                .done( function ( watchResponse ) {
                                        var message, otherAction = action === 'watch' ? 'unwatch' : 'watch';
 
-                                       if ( mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1 ) {
+                                       if ( mwTitle.isTalkPage() ) {
                                                message = action === 'watch' ? 'addedwatchtext-talk' : 'removedwatchtext-talk';
                                        } else {
                                                message = action === 'watch' ? 'addedwatchtext' : 'removedwatchtext';
index 13c51aa..7284131 100644 (file)
@@ -75,8 +75,8 @@
                                        label: label || mw.msg( 'blanknamespace' ),
                                        description: '',
                                        identifiers: [
-                                               ( namespaceID < 0 || namespaceID % 2 === 0 ) ?
-                                                       'subject' : 'talk'
+                                               mw.Title.isTalkNamespace( namespaceID ) ?
+                                                       'talk' : 'subject'
                                        ],
                                        cssClass: 'mw-changeslist-ns-' + namespaceID
                                } );
index 715b5a5..b9be51f 100644 (file)
                                        $watchlistLine = $unwatchLink.closest( 'li, table' )
                                                .find( '[data-target-page]' ),
                                        pageTitle = $watchlistLine.data( 'targetPage' ),
-                                       isTalk = mw.Title.newFromText( pageTitle ).getNamespaceId() % 2 === 1;
+                                       isTalk = mw.Title.newFromText( pageTitle ).isTalkPage();
 
                                // Utility function for looping through each watchlist line that matches
                                // a certain page or its associated page (e.g. Talk)
                                function forEachMatchingTitle( title, callback ) {
 
                                        var titleObj = mw.Title.newFromText( title ),
-                                               pageNamespaceId = titleObj.getNamespaceId(),
-                                               isTalk = pageNamespaceId % 2 === 1,
-                                               associatedTitle = mw.Title.makeTitle( isTalk ? pageNamespaceId - 1 : pageNamespaceId + 1,
-                                                       titleObj.getMainText() ).getPrefixedText();
+                                               associatedTitleObj = titleObj.isTalkPage() ? titleObj.getSubjectPage() : titleObj.getTalkPage(),
+                                               associatedTitle = associatedTitleObj.getPrefixedText();
                                        $( '.mw-changeslist-line' ).each( function () {
                                                var $this = $( this ), $row, $unwatchLink;