mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-15 10:59:42 +00:00
Merge "Simplify promise by using .then()"
This commit is contained in:
commit
7356c813a6
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue