Browse Source

refactor(dashboard): do not retry getting the device list when manually canceling the request

Casper Dai 3 năm trước cách đây
mục cha
commit
47ddc4de2c
1 tập tin đã thay đổi với 11 bổ sung8 xóa
  1. 11 8
      src/views/dashboard/index.vue

+ 11 - 8
src/views/dashboard/index.vue

@@ -164,7 +164,7 @@ export default {
     ], this.onMessage)
   },
   beforeDestroy () {
-    this.monitor.loading = true
+    this.monitor = { loading: true }
     unsubscribe([
       '+/+/online',
       '+/+/offline',
@@ -260,14 +260,17 @@ export default {
         pageSize: total,
         productId: this.product,
         activate: 2
-      }, { custom: true }).then(({ data }) => {
-        options.list = data.sort(this.sort)
-        options.loaded = true
-      }, () => {
-        if (!this.monitor.loading) {
-          this._getDevices(total)
+      }, { custom: true }).then(
+        ({ data }) => {
+          options.list = data.sort(this.sort)
+          options.loaded = true
+        },
+        ({ isCancel }) => {
+          if (!isCancel && !this.monitor.loading) {
+            this._getDevices(total)
+          }
         }
-      })
+      )
     }
   }
 }