Kaynağa Gözat

Улучшение синхронизации

Book Pauk 5 yıl önce
ebeveyn
işleme
309a9ad4fb

+ 1 - 5
client/components/Reader/Reader.vue

@@ -540,13 +540,9 @@ class Reader extends Vue {
                 await this.$refs.recentBooksPage.updateTableData();
             }
 
+            //сохранение в serverStorage
             if (value) {
                 await utils.sleep(500);
-                while (!this.$refs.serverStorage.inited || 
-                    !bookManager.loaded ||
-                    this.$refs.serverStorage.savingRecent)
-                    await utils.sleep(100);
-
                 await this.$refs.serverStorage.saveRecent(value);
             }
         }

+ 7 - 0
client/components/Reader/ServerStorage/ServerStorage.vue

@@ -432,6 +432,9 @@ class ServerStorage extends Vue {
     }
 
     async saveRecent(itemKey, recurse) {
+        while (!this.inited || this.savingRecent)
+            await utils.sleep(100);
+
         if (!this.keyInited || !this.serverSyncEnabled || this.savingRecent)
             return;
 
@@ -474,6 +477,10 @@ class ServerStorage extends Vue {
             //newRecent
             let newRecent = {};
             if (!itemKey || (needSaveRecentPatch && Object.keys(newRecentPatch.data).length > 10)) {
+                //ждем весь bm.recent
+                while (!bookManager.loaded)
+                    await utils.sleep(100);
+
                 newRecent = {rev: this.cachedRecent.rev + 1, data: bm.recent};
                 newRecentPatch = {rev: this.cachedRecentPatch.rev + 1, data: {}};
                 newRecentMod = {rev: this.cachedRecentMod.rev + 1, data: {}};