From 863ea9089a32ad7d820decd7425a8800e9f6e41e Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 28 Feb 2019 14:58:48 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=20=D0=BA=D0=B5=D1=88=D0=B5=D0=BC=20=D0=B8=20=D1=87=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/share/bookManager.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/client/components/Reader/share/bookManager.js b/client/components/Reader/share/bookManager.js index bc954965..69067f59 100644 --- a/client/components/Reader/share/bookManager.js +++ b/client/components/Reader/share/bookManager.js @@ -25,11 +25,15 @@ class BookManager { async init(settings) { this.settings = settings; - //this.booksCached нужен только для ускорения загрузки читалки + //bmCacheStore нужен только для ускорения загрузки читалки this.booksCached = await bmCacheStore.getItem('books'); if (!this.booksCached) this.booksCached = {}; this.recent = await bmCacheStore.getItem('recent'); + this.recentLast = await bmCacheStore.getItem('recent-last'); + if (this.recentLast) + this.recent[this.recentLast.key] = this.recentLast; + this.books = Object.assign({}, this.booksCached); this.recentChanged1 = true; @@ -69,12 +73,14 @@ class BookManager { } await this.cleanBooks(); + await this.cleanRecentBooks(); this.booksCached = {}; for (const key in this.books) { this.booksCached[key] = this.metaOnly(this.books[key]); } await bmCacheStore.setItem('books', this.booksCached); + await bmCacheStore.setItem('recent', this.recent); } async cleanBooks() { @@ -205,8 +211,13 @@ class BookManager { this.recent[result.key] = result; await bmRecentStore.setItem(result.key, result); - await this.cleanRecentBooks(); - await bmCacheStore.setItem('recent', this.recent); + + //кэшируем, аккуратно + if (!(this.recentLast && this.recentLast.key == result.key)) { + await bmCacheStore.setItem('recent', this.recent); + } + this.recentLast = result; + await bmCacheStore.setItem('recent-last', this.recentLast); this.recentChanged1 = true; this.recentChanged2 = true;