From: jenkins-bot Date: Sat, 17 Dec 2016 06:55:58 +0000 (+0000) Subject: Merge "mediawiki.api.watch: Use formatversion=2 for API requests" X-Git-Tag: 1.31.0-rc.0~4532 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;ds=sidebyside;h=b8da5c83743ea31c6f73c063508384f114748537;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "mediawiki.api.watch: Use formatversion=2 for API requests" --- b8da5c83743ea31c6f73c063508384f114748537 diff --combined resources/src/mediawiki/api/watch.js index 92722b55e0,84a234f751..f68697ff8d --- a/resources/src/mediawiki/api/watch.js +++ b/resources/src/mediawiki/api/watch.js @@@ -12,13 -12,13 +12,13 @@@ * @param {string|mw.Title|string[]|mw.Title[]} pages Full page name or instance of mw.Title, or an * array thereof. If an array is passed, the return value passed to the promise will also be an * array of appropriate objects. + * @param {Object} [addParams] * @return {jQuery.Promise} * @return {Function} return.done * @return {Object|Object[]} return.done.watch Object or list of objects (depends on the `pages` * parameter) * @return {string} return.done.watch.title Full pagename * @return {boolean} return.done.watch.watched Whether the page is now watched or unwatched - * @return {string} return.done.watch.message Parsed HTML of the confirmational interface message */ function doWatchInternal( pages, addParams ) { // XXX: Parameter addParams is undocumented because we inherit this @@@ -26,6 -26,7 +26,7 @@@ var apiPromise = this.postWithToken( 'watch', $.extend( { + formatversion: 2, action: 'watch', titles: $.isArray( pages ) ? pages.join( '|' ) : String( pages ), uselang: mw.config.get( 'wgUserLanguage' ) diff --combined resources/src/mediawiki/page/watch.js index f880e6a338,f81882b225..5dda7e0d90 --- a/resources/src/mediawiki/page/watch.js +++ b/resources/src/mediawiki/page/watch.js @@@ -132,16 -132,9 +132,16 @@@ api[ action ]( title ) .done( function ( watchResponse ) { - var otherAction = action === 'watch' ? 'unwatch' : 'watch'; + var mwTitle, message, otherAction = action === 'watch' ? 'unwatch' : 'watch'; - mw.notify( $.parseHTML( watchResponse.message ), { + mwTitle = mw.Title.newFromText( title ); + if ( mwTitle && mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1 ) { + message = action === 'watch' ? 'addedwatchtext-talk' : 'removedwatchtext-talk'; + } else { + message = action === 'watch' ? 'addedwatchtext' : 'removedwatchtext'; + } + + mw.notify( mw.message( message, title ).parseDom(), { tag: 'watch-self' } ); @@@ -150,7 -143,7 +150,7 @@@ // Update the "Watch this page" checkbox on action=edit when the // page is watched or unwatched via the tab (bug 12395). - $( '#wpWatchthis' ).prop( 'checked', watchResponse.watched !== undefined ); + $( '#wpWatchthis' ).prop( 'checked', watchResponse.watched === true ); } ) .fail( function () { var cleanTitle, msg, link;