bug fix
This commit is contained in:
+23
-8
@@ -37,7 +37,7 @@
|
|||||||
<template v-if="texts.length">
|
<template v-if="texts.length">
|
||||||
<infinite-loading
|
<infinite-loading
|
||||||
v-if="flattoc && center_scrolled"
|
v-if="flattoc && center_scrolled"
|
||||||
:identifier="textid"
|
:identifier="inifinite_load_id"
|
||||||
direction="top"
|
direction="top"
|
||||||
:distance="inifinite_load_distance"
|
:distance="inifinite_load_distance"
|
||||||
@infinite="prevText"
|
@infinite="prevText"
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
/>
|
/>
|
||||||
<infinite-loading
|
<infinite-loading
|
||||||
v-if="flattoc"
|
v-if="flattoc"
|
||||||
:identifier="textid"
|
:identifier="inifinite_load_id"
|
||||||
@infinite="nextText"
|
@infinite="nextText"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -120,6 +120,7 @@ export default {
|
|||||||
next_loaded: false,
|
next_loaded: false,
|
||||||
center_scrolled: false,
|
center_scrolled: false,
|
||||||
inifinite_load_distance: 10,
|
inifinite_load_distance: 10,
|
||||||
|
inifinite_load_id: +new Date(),
|
||||||
reftoscrollto: null,
|
reftoscrollto: null,
|
||||||
//
|
//
|
||||||
toc: null,
|
toc: null,
|
||||||
@@ -158,6 +159,7 @@ export default {
|
|||||||
this.pagesOtpions = []
|
this.pagesOtpions = []
|
||||||
if (newid) {
|
if (newid) {
|
||||||
this.getTextContent(newid)
|
this.getTextContent(newid)
|
||||||
|
this.inifinite_load_id += 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
textdata (newtxtdata, oldtxtdata) {
|
textdata (newtxtdata, oldtxtdata) {
|
||||||
@@ -193,11 +195,12 @@ export default {
|
|||||||
console.log('Edition Corpus/setTocs', this.editionid, state.Corpus.editionsbyuuid)
|
console.log('Edition Corpus/setTocs', this.editionid, state.Corpus.editionsbyuuid)
|
||||||
this.toc = state.Corpus.editionsbyuuid[this.editionid].toc
|
this.toc = state.Corpus.editionsbyuuid[this.editionid].toc
|
||||||
this.flattoc = state.Corpus.editionsbyuuid[this.editionid].flattoc
|
this.flattoc = state.Corpus.editionsbyuuid[this.editionid].flattoc
|
||||||
|
this.inifinite_load_id += 1
|
||||||
// if no textid in new route (e.g. edition front)
|
// if no textid in new route (e.g. edition front)
|
||||||
// but we have toc
|
// but we have toc
|
||||||
// get the first item
|
// get the first item
|
||||||
// will be replaced by front page of edition
|
// 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') {
|
if (mutation.type === 'Corpus/setPaginations') {
|
||||||
// console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid)
|
// console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid)
|
||||||
@@ -213,7 +216,7 @@ export default {
|
|||||||
// but we have toc
|
// but we have toc
|
||||||
// get the first item
|
// get the first item
|
||||||
// will be replaced by front page of edition
|
// 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
|
this.pagination = this.editionsbyuuid[this.editionid].pagination
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -245,6 +248,18 @@ export default {
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.warn('Issue with getTextContent', error)
|
console.warn('Issue with getTextContent', error)
|
||||||
Promise.reject(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({
|
// this.$router.replace({
|
||||||
// name: 'notfound',
|
// name: 'notfound',
|
||||||
// query: { fullpath: this.$route.path }
|
// query: { fullpath: this.$route.path }
|
||||||
@@ -258,18 +273,18 @@ export default {
|
|||||||
}
|
}
|
||||||
this.indexitem = null
|
this.indexitem = null
|
||||||
},
|
},
|
||||||
nextText ($state) {
|
nextText ($state, indent = 1) {
|
||||||
console.log('infinite loading nextText()')
|
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) {
|
if (indexofnext < this.flattoc.length) {
|
||||||
this.getTextContent(this.flattoc[indexofnext], $state, 'next')
|
this.getTextContent(this.flattoc[indexofnext], $state, 'next')
|
||||||
} else {
|
} else {
|
||||||
$state.complete()
|
$state.complete()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
prevText ($state) {
|
prevText ($state, indent = 1) {
|
||||||
console.log('infinite loading prevText()')
|
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) {
|
if (indexofprev >= 0) {
|
||||||
this.getTextContent(this.flattoc[indexofprev], $state, 'prev')
|
this.getTextContent(this.flattoc[indexofprev], $state, 'prev')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user