瀏覽代碼

Рефакторинг

Book Pauk 2 年之前
父節點
當前提交
ed4313b77b
共有 2 個文件被更改,包括 16 次插入20 次删除
  1. 8 10
      client/components/Search/AuthorList/AuthorList.vue
  2. 8 10
      client/components/Search/SeriesList/SeriesList.vue

+ 8 - 10
client/components/Search/AuthorList/AuthorList.vue

@@ -409,18 +409,18 @@ class AuthorList extends BaseList {
             return;
 
         this.refreshing = true;
+
+        (async() => {
+            await utils.sleep(500);
+            if (this.refreshing)
+                this.loadingMessage = 'Поиск серий...';
+        })();
+
         try {
             while (this.queryExecute) {
                 const query = this.queryExecute;
                 this.queryExecute = null;
 
-                let inSearch = true;
-                (async() => {
-                    await utils.sleep(500);
-                    if (inSearch)
-                        this.loadingMessage = 'Поиск авторов...';
-                })();
-
                 try {
                     const result = await this.api.authorSearch(query);
 
@@ -438,13 +438,11 @@ class AuthorList extends BaseList {
                     }
                 } catch (e) {
                     this.$root.stdDialog.alert(e.message, 'Ошибка');
-                } finally {
-                    inSearch = false;
-                    this.loadingMessage = '';
                 }
             }
         } finally {
             this.refreshing = false;
+            this.loadingMessage = '';
         }
     }
 }

+ 8 - 10
client/components/Search/SeriesList/SeriesList.vue

@@ -241,18 +241,18 @@ class SeriesList extends BaseList {
             return;
 
         this.refreshing = true;
+
+        (async() => {
+            await utils.sleep(500);
+            if (this.refreshing)
+                this.loadingMessage = 'Поиск серий...';
+        })();
+
         try {
             while (this.queryExecute) {
                 const query = this.queryExecute;
                 this.queryExecute = null;
 
-                let inSearch = true;
-                (async() => {
-                    await utils.sleep(500);
-                    if (inSearch)
-                        this.loadingMessage = 'Поиск серий...';
-                })();
-
                 try {
                     const result = await this.api.seriesSearch(query);
 
@@ -270,13 +270,11 @@ class SeriesList extends BaseList {
                     }
                 } catch (e) {
                     this.$root.stdDialog.alert(e.message, 'Ошибка');
-                } finally {
-                    inSearch = false;
-                    this.loadingMessage = '';
                 }
             }
         } finally {
             this.refreshing = false;
+            this.loadingMessage = '';
         }
     }
 }