فهرست منبع

[spark] Avoid rapid consecutive execution of snippets

Enrico Berti 10 سال پیش
والد
کامیت
ae91b36
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      apps/spark/src/spark/static/spark/js/spark.ko.js

+ 5 - 1
apps/spark/src/spark/static/spark/js/spark.ko.js

@@ -351,11 +351,15 @@ var Snippet = function (vm, notebook, snippet) {
     }
   };
 
+  self.lastExecuted = 0;
+
   self.execute = function () {
-    if (self.status() == 'running' || self.status() == 'loading') {
+    var now = (new Date()).getTime(); // we don't allow fast clicks
+    if (self.status() == 'running' || self.status() == 'loading' || now - self.lastExecuted < 1000) {
       return;
     }
     $(document).trigger("executeStarted", self);
+    self.lastExecuted = now;
     $(".jHueNotify").hide();
     logGA('/execute/' + self.type());