Browse Source

fixed bug with setting auto refresh status option to false via refreshOptions

Dustin Utecht 4 years ago
parent
commit
1620098c96
1 changed files with 11 additions and 6 deletions
  1. 11 6
      src/extensions/auto-refresh/bootstrap-table-auto-refresh.js

+ 11 - 6
src/extensions/auto-refresh/bootstrap-table-auto-refresh.js

@@ -35,9 +35,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
     super.init(...args)
     super.init(...args)
 
 
     if (this.options.autoRefresh && this.options.autoRefreshStatus) {
     if (this.options.autoRefresh && this.options.autoRefreshStatus) {
-      this.options.autoRefreshFunction = setInterval(() => {
-        this.refresh({ silent: this.options.autoRefreshSilent })
-      }, this.options.autoRefreshInterval * 1000)
+      this.setupRefreshInterval()
     }
     }
   }
   }
 
 
@@ -68,9 +66,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
         this.$toolbar.find('>.columns .auto-refresh')
         this.$toolbar.find('>.columns .auto-refresh')
           .removeClass(this.constants.classes.buttonActive)
           .removeClass(this.constants.classes.buttonActive)
       } else {
       } else {
-        this.options.autoRefreshFunction = setInterval(() => {
-          this.refresh({ silent: this.options.autoRefreshSilent })
-        }, this.options.autoRefreshInterval * 1000)
+        this.setupRefreshInterval()
         this.$toolbar.find('>.columns .auto-refresh')
         this.$toolbar.find('>.columns .auto-refresh')
           .addClass(this.constants.classes.buttonActive)
           .addClass(this.constants.classes.buttonActive)
       }
       }
@@ -85,4 +81,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
 
     super.destroy()
     super.destroy()
   }
   }
+
+  setupRefreshInterval () {
+    this.options.autoRefreshFunction = setInterval(() => {
+      if (!this.options.autoRefresh || !this.options.autoRefreshStatus) {
+        return
+      }
+      this.refresh({ silent: this.options.autoRefreshSilent })
+    }, this.options.autoRefreshInterval * 1000)
+  }
 }
 }