Улучшен механизм загрузки обложек
This commit is contained in:
@@ -243,6 +243,7 @@ class RecentBooksPage {
|
|||||||
archive = false;
|
archive = false;
|
||||||
|
|
||||||
covers = {};
|
covers = {};
|
||||||
|
coversLoadFunc = {};
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.commit = this.$store.commit;
|
this.commit = this.$store.commit;
|
||||||
@@ -669,20 +670,36 @@ class RecentBooksPage {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
let loadedCover = this.covers[coverPageUrl];
|
let loadedCover = this.covers[coverPageUrl];
|
||||||
|
|
||||||
|
if (loadedCover == 'error')
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!loadedCover) {
|
if (!loadedCover) {
|
||||||
(async() => {
|
(async() => {
|
||||||
//сначала заглянем в storage
|
if (this.coversLoadFunc[coverPageUrl])
|
||||||
let data = await coversStorage.getData(coverPageUrl);
|
return;
|
||||||
if (data) {
|
|
||||||
this.covers[coverPageUrl] = this.makeCoverHtml(data);
|
this.coversLoadFunc[coverPageUrl] = (async() => {
|
||||||
} else {//иначе идем на сервер
|
//сначала заглянем в storage
|
||||||
try {
|
let data = await coversStorage.getData(coverPageUrl);
|
||||||
data = await readerApi.getUploadedFileBuf(coverPageUrl);
|
if (data) {
|
||||||
await coversStorage.setData(coverPageUrl, data);
|
this.covers[coverPageUrl] = this.makeCoverHtml(data);
|
||||||
this.covers[coverPageUrl] = this.makeCoverHtml(data);
|
} else {//иначе идем на сервер
|
||||||
} catch (e) {
|
try {
|
||||||
console.error(e);
|
data = await readerApi.getUploadedFileBuf(coverPageUrl);
|
||||||
|
await coversStorage.setData(coverPageUrl, data);
|
||||||
|
this.covers[coverPageUrl] = this.makeCoverHtml(data);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
this.covers[coverPageUrl] = 'error';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.coversLoadFunc[coverPageUrl]();
|
||||||
|
} finally {
|
||||||
|
this.coversLoadFunc[coverPageUrl] = null;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user