mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
Pause polling for new replies while saving
Also fix stopPoll() not really stopping the polling if a request was in progress while it was called. Bug: T333576 Change-Id: Ie8f6f006c6fd23971e53586e6219992db23f48fc
This commit is contained in:
parent
f76e47a3ef
commit
890cec73b6
|
@ -232,6 +232,7 @@ CommentController.prototype.startPoll = function ( nextDelay ) {
|
|||
|
||||
const threadItemId = this.threadItem.id;
|
||||
const subscribableHeadingId = this.threadItem.getSubscribableHeading().id;
|
||||
let aborted = false;
|
||||
|
||||
this.pollApiRequest = controller.getApi().get( {
|
||||
action: 'discussiontoolscompare',
|
||||
|
@ -266,11 +267,15 @@ CommentController.prototype.startPoll = function ( nextDelay ) {
|
|||
|
||||
this.oldId = result.torevid;
|
||||
nextDelay = 5000;
|
||||
}, () => {
|
||||
}, ( code, data ) => {
|
||||
if ( code === 'http' && data.textStatus === 'abort' ) {
|
||||
aborted = true;
|
||||
} else {
|
||||
// Wait longer next time in case of error
|
||||
nextDelay = nextDelay * 1.5;
|
||||
}
|
||||
} ).always( () => {
|
||||
if ( this.isTornDown ) {
|
||||
if ( this.isTornDown || aborted ) {
|
||||
return;
|
||||
}
|
||||
// Stop polling after too many errors
|
||||
|
@ -498,6 +503,8 @@ CommentController.prototype.onReplySubmit = function ( extraParams ) {
|
|||
* @param {Object} data Error data
|
||||
*/
|
||||
CommentController.prototype.saveFail = function ( code, data ) {
|
||||
this.startPoll();
|
||||
|
||||
const captchaData = OO.getProp( data, 'discussiontoolsedit', 'edit', 'captcha' );
|
||||
|
||||
if ( captchaData ) {
|
||||
|
@ -550,6 +557,8 @@ CommentController.prototype.saveFail = function ( code, data ) {
|
|||
* @return {jQuery.Promise} Promise which resolves when the save is complete
|
||||
*/
|
||||
CommentController.prototype.save = function ( pageName, extraParams ) {
|
||||
this.stopPoll();
|
||||
|
||||
const replyWidget = this.replyWidget,
|
||||
threadItem = this.getThreadItem();
|
||||
|
||||
|
|
Loading…
Reference in a new issue