Переделал механизм удаления recent
This commit is contained in:
@@ -141,9 +141,11 @@ class HistoryPage extends Vue {
|
|||||||
let result = [];
|
let result = [];
|
||||||
|
|
||||||
const sorted = bookManager.getSortedRecent();
|
const sorted = bookManager.getSortedRecent();
|
||||||
const len = (sorted.length < 100 ? sorted.length : 100);
|
for (let i = 0; i < sorted.length; i++) {
|
||||||
for (let i = 0; i < len; i++) {
|
|
||||||
const book = sorted[i];
|
const book = sorted[i];
|
||||||
|
if (book.deleted)
|
||||||
|
continue;
|
||||||
|
|
||||||
let d = new Date();
|
let d = new Date();
|
||||||
d.setTime(book.touchTime);
|
d.setTime(book.touchTime);
|
||||||
const t = formatDate(d).split(' ');
|
const t = formatDate(d).split(' ');
|
||||||
@@ -193,6 +195,8 @@ class HistoryPage extends Vue {
|
|||||||
path: book.path,
|
path: book.path,
|
||||||
key: book.key,
|
key: book.key,
|
||||||
});
|
});
|
||||||
|
if (result.length >= 100)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const search = this.search;
|
const search = this.search;
|
||||||
|
|||||||
@@ -233,11 +233,20 @@ class BookManager {
|
|||||||
return utils.stringToHex(url);
|
return utils.stringToHex(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setRecentBook(value, noTouch) {
|
async setRecentBook(value) {
|
||||||
if (!this.recent)
|
if (!this.recent)
|
||||||
await this.init();
|
await this.init();
|
||||||
const result = this.metaOnly(value);
|
const result = this.metaOnly(value);
|
||||||
result.touchTime = Date.now();
|
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;
|
this.recent[result.key] = result;
|
||||||
|
|
||||||
@@ -265,8 +274,8 @@ class BookManager {
|
|||||||
if (!this.recent)
|
if (!this.recent)
|
||||||
await this.init();
|
await this.init();
|
||||||
|
|
||||||
await bmRecentStore.removeItem(value.key);
|
this.recent[value.key].deleted = 1;
|
||||||
delete this.recent[value.key];
|
await bmRecentStore.setItem(value.key, this.recent[value.key].deleted);
|
||||||
await bmCacheStore.setItem('recent', this.recent);
|
await bmCacheStore.setItem('recent', this.recent);
|
||||||
|
|
||||||
this.recentChanged1 = true;
|
this.recentChanged1 = true;
|
||||||
@@ -289,7 +298,9 @@ class BookManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
await this.delRecentBook(found);
|
await bmRecentStore.removeItem(found.key);
|
||||||
|
delete this.recent[found.key];
|
||||||
|
|
||||||
await this.cleanRecentBooks();
|
await this.cleanRecentBooks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,7 +315,7 @@ class BookManager {
|
|||||||
let result = null;
|
let result = null;
|
||||||
for (let key in this.recent) {
|
for (let key in this.recent) {
|
||||||
const book = this.recent[key];
|
const book = this.recent[key];
|
||||||
if (book.touchTime > max) {
|
if (!book.deleted && book.touchTime > max) {
|
||||||
max = book.touchTime;
|
max = book.touchTime;
|
||||||
result = book;
|
result = book;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user