Adam Shaw 8 лет назад
Родитель
Сommit
4874ff2eaf
1 измененных файлов с 19 добавлено и 2 удалено
  1. 19 2
      src/common/TaskQueue.js

+ 19 - 2
src/common/TaskQueue.js

@@ -24,7 +24,18 @@ var TaskQueue = Class.extend(EmitterMixin, {
 
 	resume: function() {
 		this.isPaused = false;
-		this.tryStart();
+
+		if (!this.isRunning && !this.q.length) {
+			this.trigger('idle'); // TODO: write tests
+		}
+		else {
+			this.tryStart();
+		}
+	},
+
+
+	getIsIdle: function() {
+		return !this.isRunning && !this.isPaused;
 	},
 
 
@@ -63,7 +74,13 @@ var TaskQueue = Class.extend(EmitterMixin, {
 
 		this.trigger('stop'); // not really a 'stop' ... more of a 'drained'
 		this.isRunning = false;
-		this.tryStart(); // if 'stop' handler added more tasks.... TODO: write test for this
+
+		if (!this.isPaused && !this.q.length) {
+			this.trigger('idle'); // TODO: write tests
+		}
+		else {
+			this.tryStart(); // if 'stop' handler added more tasks.... TODO: write test for this
+		}
 	},