ソースを参照

fix: update script list without debounce on load

Gerald 8 年 前
コミット
4dc17497db
1 ファイル変更8 行追加3 行削除
  1. 8 3
      src/options/views/tab-installed.vue

+ 8 - 3
src/options/views/tab-installed.vue

@@ -59,7 +59,9 @@ export default {
     };
   },
   watch: {
-    search: 'onUpdate',
+    search() {
+      this.debouncedUpdate();
+    },
     'store.scripts': 'onUpdate',
   },
   computed: {
@@ -76,13 +78,13 @@ export default {
     },
   },
   methods: {
-    onUpdate: debounce(function onUpdate() {
+    onUpdate() {
       const { search } = this;
       const { scripts } = this.store;
       this.scripts = search
         ? scripts.filter(script => (script._search || '').includes(search.toLowerCase()))
         : scripts;
-    }, 200),
+    },
     newScript() {
       sendMessage({ cmd: 'NewScript' })
       .then((script) => {
@@ -153,6 +155,9 @@ export default {
       });
     },
   },
+  created() {
+    this.debouncedUpdate = debounce(this.onUpdate, 200);
+  },
 };
 </script>