Увеличил количество хранимых недавних до 1000

This commit is contained in:
Book Pauk
2019-02-17 13:57:12 +07:00
parent b3cf88aac3
commit 73bfc07082
2 changed files with 19 additions and 3 deletions

View File

@@ -193,7 +193,7 @@ class BookManager {
if (!this.recent)
await this.init();
if (Object.keys(this.recent).length > 100) {
if (Object.keys(this.recent).length > 1000) {
let min = Date.now();
let found = null;
for (let key in this.recent) {
@@ -230,6 +230,20 @@ class BookManager {
return result;
}
getSortedRecent() {
if (!this.recentChanged && this.sortedRecentCached) {
return this.sortedRecentCached;
}
let result = Object.values(this.recent);
result.sort((a, b) => b.touchTime - a.touchTime);
this.sortedRecentCached = result;
return result;
}
}
export default new BookManager();