Merge "Simplify promise by using .then()"

This commit is contained in:
jenkins-bot 2018-02-05 19:27:17 +00:00 committed by Gerrit Code Review
commit 7356c813a6

View file

@ -8,16 +8,13 @@
* @return {Promise} The thank operation's status.
*/
function thankUser( name, revision, recipientGender ) {
var d = $.Deferred();
( new mw.Api() ).postWithToken( 'csrf', {
return ( new mw.Api() ).postWithToken( 'csrf', {
action: 'thank',
rev: revision,
source: 'mobilediff'
} ).done( function () {
} ).then( function () {
mw.notify( mw.msg( 'thanks-thanked-notice', name, recipientGender, mw.user ) );
d.resolve();
} )
.fail( function ( errorCode ) {
}, function ( errorCode ) {
// FIXME: What is "popup" and where is it defined?
/* eslint-disable no-undef */
switch ( errorCode ) {
@ -31,9 +28,7 @@
popup.show( mw.msg( 'thanks-error-undefined', errorCode ) );
}
/* eslint-enable no-undef */
d.reject();
} );
return d;
}
/**