From e626cb6b408e136c9a06cdd5fd380545e492b804 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Mon, 18 Mar 2019 19:38:47 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=BC=D0=B5=D1=85=D0=B0=D0=BD=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20recent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/HistoryPage/HistoryPage.vue | 8 +++++-- client/components/Reader/share/bookManager.js | 21 ++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/client/components/Reader/HistoryPage/HistoryPage.vue b/client/components/Reader/HistoryPage/HistoryPage.vue index a502aa2b..1da95ace 100644 --- a/client/components/Reader/HistoryPage/HistoryPage.vue +++ b/client/components/Reader/HistoryPage/HistoryPage.vue @@ -141,9 +141,11 @@ class HistoryPage extends Vue { let result = []; const sorted = bookManager.getSortedRecent(); - const len = (sorted.length < 100 ? sorted.length : 100); - for (let i = 0; i < len; i++) { + for (let i = 0; i < sorted.length; i++) { const book = sorted[i]; + if (book.deleted) + continue; + let d = new Date(); d.setTime(book.touchTime); const t = formatDate(d).split(' '); @@ -193,6 +195,8 @@ class HistoryPage extends Vue { path: book.path, key: book.key, }); + if (result.length >= 100) + break; } const search = this.search; diff --git a/client/components/Reader/share/bookManager.js b/client/components/Reader/share/bookManager.js index 1bc847f8..4207463b 100644 --- a/client/components/Reader/share/bookManager.js +++ b/client/components/Reader/share/bookManager.js @@ -233,11 +233,20 @@ class BookManager { return utils.stringToHex(url); } - async setRecentBook(value, noTouch) { + async setRecentBook(value) { if (!this.recent) await this.init(); const result = this.metaOnly(value); result.touchTime = Date.now(); + result.deleted = 0; + + if (this.recent[result.key] && this.recent[result.key].deleted) { + //восстановим из небытия пользовательские данные + if (!result.bookPos) + result.bookPos = this.recent[result.key].bookPos; + if (!result.bookPosSeen) + result.bookPosSeen = this.recent[result.key].bookPosSeen; + } this.recent[result.key] = result; @@ -265,8 +274,8 @@ class BookManager { if (!this.recent) await this.init(); - await bmRecentStore.removeItem(value.key); - delete this.recent[value.key]; + this.recent[value.key].deleted = 1; + await bmRecentStore.setItem(value.key, this.recent[value.key].deleted); await bmCacheStore.setItem('recent', this.recent); this.recentChanged1 = true; @@ -289,7 +298,9 @@ class BookManager { } if (found) { - await this.delRecentBook(found); + await bmRecentStore.removeItem(found.key); + delete this.recent[found.key]; + await this.cleanRecentBooks(); } } @@ -304,7 +315,7 @@ class BookManager { let result = null; for (let key in this.recent) { const book = this.recent[key]; - if (book.touchTime > max) { + if (!book.deleted && book.touchTime > max) { max = book.touchTime; result = book; }