From 57e869bfd51ffe531afecc8956b4235424b7ed6c Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Sat, 25 Jul 2020 19:11:31 +0200 Subject: [PATCH] bug fix --- src/pages/Edition.vue | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/pages/Edition.vue b/src/pages/Edition.vue index 04fb31f..1ff9e31 100644 --- a/src/pages/Edition.vue +++ b/src/pages/Edition.vue @@ -37,7 +37,7 @@ @@ -120,6 +120,7 @@ export default { next_loaded: false, center_scrolled: false, inifinite_load_distance: 10, + inifinite_load_id: +new Date(), reftoscrollto: null, // toc: null, @@ -158,6 +159,7 @@ export default { this.pagesOtpions = [] if (newid) { this.getTextContent(newid) + this.inifinite_load_id += 1 } }, textdata (newtxtdata, oldtxtdata) { @@ -193,11 +195,12 @@ export default { console.log('Edition Corpus/setTocs', this.editionid, state.Corpus.editionsbyuuid) this.toc = state.Corpus.editionsbyuuid[this.editionid].toc this.flattoc = state.Corpus.editionsbyuuid[this.editionid].flattoc + this.inifinite_load_id += 1 // if no textid in new route (e.g. edition front) // but we have toc // get the first item // will be replaced by front page of edition - if (!this.textid) { this.textid = this.toc[0].children[1].uuid } + if (!this.textid) { this.textid = this.toc[0].children[0].uuid } } if (mutation.type === 'Corpus/setPaginations') { // console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid) @@ -213,7 +216,7 @@ export default { // but we have toc // get the first item // will be replaced by front page of edition - if (!this.textid) { this.textid = this.toc[0].children[1].uuid } + if (!this.textid) { this.textid = this.toc[0].children[0].uuid } this.pagination = this.editionsbyuuid[this.editionid].pagination } }, @@ -245,6 +248,18 @@ export default { .catch((error) => { console.warn('Issue with getTextContent', error) Promise.reject(error) + // if some item don't load and if we come from infinite loading + // retry with next step + if ($state) { + switch (direction) { + case 'next': + this.nextText($state, 2) + break + case 'prev': + this.prevText($state, 2) + break + } + } // this.$router.replace({ // name: 'notfound', // query: { fullpath: this.$route.path } @@ -258,18 +273,18 @@ export default { } this.indexitem = null }, - nextText ($state) { + nextText ($state, indent = 1) { console.log('infinite loading nextText()') - let indexofnext = this.flattoc.indexOf(this.textsuuids[this.textsuuids.length - 1]) + 1 + let indexofnext = this.flattoc.indexOf(this.textsuuids[this.textsuuids.length - 1]) + indent if (indexofnext < this.flattoc.length) { this.getTextContent(this.flattoc[indexofnext], $state, 'next') } else { $state.complete() } }, - prevText ($state) { + prevText ($state, indent = 1) { console.log('infinite loading prevText()') - let indexofprev = this.flattoc.indexOf(this.textsuuids[0]) - 1 + let indexofprev = this.flattoc.indexOf(this.textsuuids[0]) - indent if (indexofprev >= 0) { this.getTextContent(this.flattoc[indexofprev], $state, 'prev') } else {