Небольшие доделки в связи с оптимизацией загрузки списка недавних

This commit is contained in:
Book Pauk
2020-11-21 13:34:58 +07:00
parent 01e82dca5f
commit 8d2f74daa4
3 changed files with 10 additions and 22 deletions

View File

@@ -112,6 +112,7 @@ class RecentBooksPage extends Vue {
pagination = {}; pagination = {};
created() { created() {
this.firstInit = true;
this.pagination = {rowsPerPage: 0}; this.pagination = {rowsPerPage: 0};
this.columns = [ this.columns = [
@@ -167,26 +168,11 @@ class RecentBooksPage extends Vue {
this.initing = true; this.initing = true;
if (!bookManager.loaded) { if (this.firstInit) {//для отзывчивости
await this.updateTableData(10); await this.updateTableData(20);
//для отзывчивости this.firstInit = false;
await utils.sleep(100);
let i = 0;
let j = 5;
while (i < 500 && !bookManager.loaded) {
if (i % j == 0) {
bookManager.sortedRecentCached = null;
await this.updateTableData(20);
j *= 2;
}
await utils.sleep(100);
i++;
}
} else {
//для отзывчивости
await utils.sleep(100);
} }
await utils.sleep(50);
await this.updateTableData(); await this.updateTableData();
this.initing = false; this.initing = false;
})(); })();

View File

@@ -580,8 +580,8 @@ class ServerStorage extends Vue {
let newRecent = {}; let newRecent = {};
if (!itemKey || (needSaveRecentPatch && Object.keys(newRecentPatch.data).length > 10)) { if (!itemKey || (needSaveRecentPatch && Object.keys(newRecentPatch.data).length > 10)) {
//ждем весь bm.recent //ждем весь bm.recent
while (!bookManager.loaded) /*while (!bookManager.loaded)
await utils.sleep(100); await utils.sleep(100);*/
newRecent = {rev: this.cachedRecent.rev + 1, data: _.cloneDeep(bm.recent)}; newRecent = {rev: this.cachedRecent.rev + 1, data: _.cloneDeep(bm.recent)};
newRecentPatch = {rev: this.cachedRecentPatch.rev + 1, data: {}}; newRecentPatch = {rev: this.cachedRecentPatch.rev + 1, data: {}};

View File

@@ -39,7 +39,7 @@ class BookManager {
this.saveRecentItem = _.debounce(() => { this.saveRecentItem = _.debounce(() => {
bmRecentStoreNew.setItem('recent-item', this.recentItem); bmRecentStoreNew.setItem('recent-item', this.recentItem);
this.recentRev++; this.recentRev = (this.recentRev < 1000 ? this.recentRev + 1 : 1);
bmRecentStoreNew.setItem('rev', this.recentRev); bmRecentStoreNew.setItem('rev', this.recentRev);
}, 200, {maxWait: 300}); }, 200, {maxWait: 300});
@@ -64,6 +64,8 @@ class BookManager {
await this.cleanRecentBooks(); await this.cleanRecentBooks();
if (this.recentRev > 10)
await bmRecentStoreOld.clear();
} else {//TODO: убрать после 06.2021, когда bmRecentStoreOld устареет } else {//TODO: убрать после 06.2021, когда bmRecentStoreOld устареет
this.recentLast = await bmRecentStoreOld.getItem('recent-last'); this.recentLast = await bmRecentStoreOld.getItem('recent-last');
if (this.recentLast) { if (this.recentLast) {