Переделал механизм удаления recent
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user