diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue index f7ed8d8d..e96ad2c0 100644 --- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue +++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue @@ -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; } })(); }