mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
ArticleTargetSaver: Fix handling for data.result !== 'success'
The comment here seems to be wrong, as far as I can tell, this
case can only happen when viewing a diff with no changes
(`data.result === 'nochanges'`) or saving an edit and getting
a captcha (`data.result === 'error'`).
The handling here, added in the recent refactor
b0f4b4c94e
, causes both of these
cases to behave wrong (displaying the error message, instead of
empty diff / captcha form).
Change-Id: I305e8ca9ff769c229a93d5fb3307e545a0227f2f
This commit is contained in:
parent
1e890f975f
commit
1dc642ee57
|
@ -1545,11 +1545,14 @@ ve.init.mw.ArticleTarget.prototype.getWikitextDiffPromise = function ( doc ) {
|
|||
oldid: this.revid,
|
||||
etag: this.etag
|
||||
}, 'diff' ).then( function ( data ) {
|
||||
if ( data.result === 'nochanges' ) {
|
||||
return data.diff;
|
||||
}, function ( code, response ) {
|
||||
// ArticleTargetSaver treats this as an error, this is silly
|
||||
if ( response.visualeditoredit && response.visualeditoredit.result === 'nochanges' ) {
|
||||
target.emit( 'noChanges' );
|
||||
return null;
|
||||
}
|
||||
return data.diff;
|
||||
return ve.createDeferred().reject( code, response ).promise();
|
||||
} );
|
||||
this.wikitextDiffPromise
|
||||
.done( this.emit.bind( this, 'showChanges' ) )
|
||||
|
|
|
@ -256,11 +256,11 @@
|
|||
html: 'Invalid response from server'
|
||||
};
|
||||
} else if ( data.result !== 'success' ) {
|
||||
// Note, this could be any of db failure, hookabort, badtoken or even a captcha
|
||||
error = {
|
||||
code: 'failure',
|
||||
html: 'Save failure: ' + mw.html.escape( data.result )
|
||||
};
|
||||
// This can only happen when:
|
||||
// * viewing a diff with no changes (`data.result === 'nochanges'`)
|
||||
// * saving an edit and getting a captcha (`data.result === 'error'`)
|
||||
// It's a silly special case...
|
||||
return $.Deferred().reject( 'no-error-no-success', response ).promise();
|
||||
} else {
|
||||
// paction specific errors
|
||||
switch ( data.paction ) {
|
||||
|
|
Loading…
Reference in a new issue