Utente:Daimona Eaytoy/Massblock.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Trovato il problema, dopo correggo
+Hack per attendere tutte le richieste col when, anziché fermarsi al primo fallimento
Riga 6:
* Overwrite values in localMsg below to localize.
*
* @todo docs!!, better i18n, protection counters aren't updated ==> $.when(...) rejects as soon as the first prom is rejected... We need to wait for every promise to be processed, be it resolved or rejected
*/
( function( mw, $ ) {
Riga 126:
var successHandler = function( response ) {
let user = response.block.user,
talkDone, userDone,
talkPage = 'User talk:' + user,
userPage = 'User:' + user;,
// @var {Promise} These track the state for all actions (edit and protect)
// on every page. If everything succeeds, the promise is the result of taken actions.
// Otherwise (i.e. if there's nothing to do or something failed) these are resolved
// promises, so that the final $.when will resolve after all promises
// have been processed, and not after the first rejection.
talkDone = $.when(), userDone, = $.when();
 
blocked++;
Riga 143 ⟶ 148:
.fail( function( e ) {
errorHandler( e, user, "protect-talk" );
// Return so that this counts as resolved
return $.when();
} );
}
Riga 148 ⟶ 155:
.fail( function( e ) {
errorHandler( e, user, "edit-talk" );
// Return so that this counts as resolved
return $.when();
} );
} else if ( wpMassBlockProtectTalk ) {
Riga 163 ⟶ 172:
.fail( function( e ) {
errorHandler( e, user, "protect-talk" );
// Return so that this counts as resolved
return $.when();
} );
} )
.fail( function( e ) {
errorHandler( e, user, "query-talk" );
// Return so that this counts as resolved
return $.when();
} );
}
Riga 181 ⟶ 194:
.fail( function( e ) {
errorHandler( e, user, "protect-user" );
// Return so that this counts as resolved
return $.when();
} );
}
Riga 186 ⟶ 201:
.fail( function( e ) {
errorHandler( e, user, "edit-user" );
// Return so that this counts as resolved
return $.when();
} );
} else if ( wpMassBlockProtectUser ) {
Riga 201 ⟶ 218:
.fail( function( e ) {
errorHandler( e, user, "protect-user" );
// Return so that this counts as resolved
return $.when();
} );
} )
.fail( function( e ) {
errorHandler( e, user, "query-user" );
// Return so that this counts as resolved
return $.when();
} );
}
Riga 224 ⟶ 245:
function( e ) {
errorHandler( e, user, "block" );
// Return so that this counts as resolved and won't leave
// other promises unresolved.
return $.when();
}
)