Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/81223


Change subject: Make ve.dm.Surface.{start,stop}HistoryTracking idempotent.
......................................................................

Make ve.dm.Surface.{start,stop}HistoryTracking idempotent.

Add a little robustness, guaranteeing that we don't end up with multiple
history tracking tasks running, leaking one, or try to clear a non-running
interval.

Change-Id: I41db2d6fefc7f45f150aa14ecefc648760ad6200
---
M modules/ve/dm/ve.dm.Surface.js
1 file changed, 7 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/23/81223/1

diff --git a/modules/ve/dm/ve.dm.Surface.js b/modules/ve/dm/ve.dm.Surface.js
index c8dfc1d..3d08154 100644
--- a/modules/ve/dm/ve.dm.Surface.js
+++ b/modules/ve/dm/ve.dm.Surface.js
@@ -101,7 +101,9 @@
        if ( !this.enabled ) {
                return;
        }
-       this.historyTrackingInterval = setInterval( ve.bind( this.breakpoint, 
this ), 750 );
+       if ( this.historyTrackingInterval === null) {
+               this.historyTrackingInterval = setInterval( ve.bind( 
this.breakpoint, this ), 750 );
+       }
 };
 
 /**
@@ -113,7 +115,10 @@
        if ( !this.enabled ) {
                return;
        }
-       clearInterval( this.historyTrackingInterval );
+       if ( this.historyTrackingInterval !== null ) {
+               clearInterval( this.historyTrackingInterval );
+               this.historyTrackingInterval = null;
+       }
 };
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/81223
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I41db2d6fefc7f45f150aa14ecefc648760ad6200
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Cscott <canan...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to