From ae412f2a57d3659abbc26956c457c1c1e061bbd9 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 31 May 2024 16:32:38 -0500 Subject: [PATCH] Fix:PDF reader flickering & disable request progress indicator for ebook progress update events #2279 --- client/components/readers/ComicReader.vue | 4 +-- client/components/readers/EpubReader.vue | 2 +- client/components/readers/PdfReader.vue | 31 ++++++++++++----------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/client/components/readers/ComicReader.vue b/client/components/readers/ComicReader.vue index 49e9b093..5cd6b283 100644 --- a/client/components/readers/ComicReader.vue +++ b/client/components/readers/ComicReader.vue @@ -179,7 +179,7 @@ export default { ebookLocation: this.page, ebookProgress: Math.max(0, Math.min(1, (Number(this.page) - 1) / Number(this.numPages))) } - this.$axios.$patch(`/api/me/progress/${this.libraryItemId}`, payload).catch((error) => { + this.$axios.$patch(`/api/me/progress/${this.libraryItemId}`, payload, { progress: false }).catch((error) => { console.error('ComicReader.updateProgress failed:', error) }) }, @@ -386,4 +386,4 @@ export default { .pagemenu { max-height: calc(100% - 48px); } - \ No newline at end of file + diff --git a/client/components/readers/EpubReader.vue b/client/components/readers/EpubReader.vue index 819f5beb..de31a8d5 100644 --- a/client/components/readers/EpubReader.vue +++ b/client/components/readers/EpubReader.vue @@ -195,7 +195,7 @@ export default { */ updateProgress(payload) { if (!this.keepProgress) return - this.$axios.$patch(`/api/me/progress/${this.libraryItemId}`, payload).catch((error) => { + this.$axios.$patch(`/api/me/progress/${this.libraryItemId}`, payload, { progress: false }).catch((error) => { console.error('EpubReader.updateProgress failed:', error) }) }, diff --git a/client/components/readers/PdfReader.vue b/client/components/readers/PdfReader.vue index 3100f907..dd4c26e2 100644 --- a/client/components/readers/PdfReader.vue +++ b/client/components/readers/PdfReader.vue @@ -23,13 +23,10 @@
{{ Math.floor(loadedRatio * 100) }}%
- +
- @@ -57,7 +54,8 @@ export default { rotate: 0, loadedRatio: 0, page: 1, - numPages: 0 + numPages: 0, + pdfDocInitParams: null } }, computed: { @@ -108,14 +106,6 @@ export default { return `/api/items/${this.libraryItemId}/ebook/${this.fileId}` } return `/api/items/${this.libraryItemId}/ebook` - }, - pdfDocInitParams() { - return { - url: this.ebookUrl, - httpHeaders: { - Authorization: `Bearer ${this.userToken}` - } - } } }, methods: { @@ -136,7 +126,7 @@ export default { ebookLocation: this.page, ebookProgress: Math.max(0, Math.min(1, (Number(this.page) - 1) / Number(this.numPages))) } - this.$axios.$patch(`/api/me/progress/${this.libraryItemId}`, payload).catch((error) => { + this.$axios.$patch(`/api/me/progress/${this.libraryItemId}`, payload, { progress: false }).catch((error) => { console.error('EpubReader.updateProgress failed:', error) }) }, @@ -149,6 +139,7 @@ export default { this.loadedRatio = progress }, numPagesLoaded(e) { + if (!e) return this.numPages = e }, prev() { @@ -167,15 +158,25 @@ export default { resize() { this.windowWidth = window.innerWidth this.windowHeight = window.innerHeight + }, + init() { + this.pdfDocInitParams = { + url: this.ebookUrl, + httpHeaders: { + Authorization: `Bearer ${this.userToken}` + } + } } }, mounted() { this.windowWidth = window.innerWidth this.windowHeight = window.innerHeight window.addEventListener('resize', this.resize) + + this.init() }, beforeDestroy() { window.removeEventListener('resize', this.resize) } } - \ No newline at end of file +