|
@@ -243,6 +243,7 @@ class RecentBooksPage {
|
|
|
archive = false;
|
|
|
|
|
|
covers = {};
|
|
|
+ coversLoadFunc = {};
|
|
|
|
|
|
created() {
|
|
|
this.commit = this.$store.commit;
|
|
@@ -669,20 +670,36 @@ class RecentBooksPage {
|
|
|
return false;
|
|
|
|
|
|
let loadedCover = this.covers[coverPageUrl];
|
|
|
+
|
|
|
+ if (loadedCover == 'error')
|
|
|
+ return false;
|
|
|
+
|
|
|
if (!loadedCover) {
|
|
|
(async() => {
|
|
|
- //сначала заглянем в storage
|
|
|
- let data = await coversStorage.getData(coverPageUrl);
|
|
|
- if (data) {
|
|
|
- this.covers[coverPageUrl] = this.makeCoverHtml(data);
|
|
|
- } else {//иначе идем на сервер
|
|
|
- try {
|
|
|
- data = await readerApi.getUploadedFileBuf(coverPageUrl);
|
|
|
- await coversStorage.setData(coverPageUrl, data);
|
|
|
- this.covers[coverPageUrl] = this.makeCoverHtml(data);
|
|
|
- } catch (e) {
|
|
|
- console.error(e);
|
|
|
+ if (this.coversLoadFunc[coverPageUrl])
|
|
|
+ return;
|
|
|
+
|
|
|
+ this.coversLoadFunc[coverPageUrl] = (async() => {
|
|
|
+ //сначала заглянем в storage
|
|
|
+ let data = await coversStorage.getData(coverPageUrl);
|
|
|
+ if (data) {
|
|
|
+ this.covers[coverPageUrl] = this.makeCoverHtml(data);
|
|
|
+ } else {//иначе идем на сервер
|
|
|
+ try {
|
|
|
+ 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;
|
|
|
}
|
|
|
})();
|
|
|
}
|