From 544a99531281ca6d90b7d509b7b63109a4f30aca Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Mon, 21 Oct 2019 20:07:42 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B1=D0=B0=D0=B3=D0=BE=D0=B2=20=D1=81=D0=B8=D0=BD?= =?UTF-8?q?=D1=85=D1=80=D0=BE=D0=BD=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/Reader.vue | 11 +++++++++-- .../Reader/ServerStorage/ServerStorage.vue | 17 ----------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index 83cdb610..0dd472b3 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -327,7 +327,6 @@ class Reader extends Vue { (async() => { await bookManager.init(this.settings); bookManager.addEventListener(this.bookManagerEvent); - await this.$refs.serverStorage.init(); if (this.$root.rootRoute == '/reader') { if (this.routeParamUrl) { @@ -337,6 +336,7 @@ class Reader extends Vue { } } + await this.$refs.serverStorage.init(); this.checkSetStorageAccessKey(); this.checkActivateDonateHelpPage(); this.loading = false; @@ -510,7 +510,7 @@ class Reader extends Vue { this.debouncedUpdateRoute(); } - async bookManagerEvent(eventName) { + async bookManagerEvent(eventName, value) { if (eventName == 'set-recent' || eventName == 'recent-deleted') { const oldBook = (this.textPage ? this.textPage.lastBook : null); const oldPos = (this.textPage ? this.textPage.bookPos : null); @@ -539,6 +539,13 @@ class Reader extends Vue { if (this.recentBooksActive) { await this.$refs.recentBooksPage.updateTableData(); } + + if (value) { + await utils.sleep(500); + while (!this.$refs.serverStorage.inited) await utils.sleep(100); + + this.$refs.serverStorage.saveRecent(value); + } } } diff --git a/client/components/Reader/ServerStorage/ServerStorage.vue b/client/components/Reader/ServerStorage/ServerStorage.vue index 65746730..41db5989 100644 --- a/client/components/Reader/ServerStorage/ServerStorage.vue +++ b/client/components/Reader/ServerStorage/ServerStorage.vue @@ -49,10 +49,6 @@ class ServerStorage extends Vue { this.saveSettings(); }, 500); - this.debouncedSaveRecent = _.debounce((itemKey) => { - this.saveRecent(itemKey); - }, 1000); - this.debouncedNotifySuccess = _.debounce(() => { this.success('Данные синхронизированы с сервером'); }, 1000); @@ -81,8 +77,6 @@ class ServerStorage extends Vue { } else { await this.serverStorageKeyChanged(); } - - bookManager.addEventListener(this.bookManagerEvent); } finally { this.inited = true; } @@ -103,17 +97,6 @@ class ServerStorage extends Vue { this.cachedRecentMod = value; } - async bookManagerEvent(eventName, itemKey) { - if (!this.serverSyncEnabled) - return; - - if (eventName == 'recent-changed') { - if (itemKey) { - this.debouncedSaveRecent(itemKey); - } - } - } - async generateNewServerStorageKey() { const key = utils.toBase58(utils.randomArray(32)); this.commit('reader/setServerStorageKey', key);