diff --git a/web/app.js b/web/app.js index 3f024ceab82a2..7ac0a383061ee 100644 --- a/web/app.js +++ b/web/app.js @@ -151,7 +151,6 @@ const PDFViewerApplication = { /** @type {AnnotationEditorParams} */ annotationEditorParams: null, isInitialViewSet: false, - downloadComplete: false, isViewerEmbedded: window.parent !== window, url: "", baseUrl: "", @@ -940,7 +939,6 @@ const PDFViewerApplication = { this.pdfLinkService.externalLinkEnabled = true; this.store = null; this.isInitialViewSet = false; - this.downloadComplete = false; this.url = ""; this.baseUrl = ""; this._downloadUrl = ""; @@ -1070,12 +1068,9 @@ const PDFViewerApplication = { async download(options = {}) { let data; try { - if (this.downloadComplete) { - data = await this.pdfDocument.getData(); - } + data = await this.pdfDocument.getData(); } catch { - // When the PDF document isn't ready, or the PDF file is still - // downloading, simply download using the URL. + // When the PDF document isn't ready, simply download using the URL. } this.downloadManager.download( data, @@ -1186,17 +1181,12 @@ const PDFViewerApplication = { }, progress(level) { - if (!this.loadingBar || this.downloadComplete) { - // Don't accidentally show the loading bar again when the entire file has - // already been fetched (only an issue when disableAutoFetch is enabled). - return; - } const percent = Math.round(level * 100); // When we transition from full request to range requests, it's possible // that we discard some of the loaded data. This can cause the loading // bar to move backwards. So prevent this by only updating the bar if it // increases. - if (percent <= this.loadingBar.percent) { + if (!this.loadingBar || percent <= this.loadingBar.percent) { return; } this.loadingBar.percent = percent; @@ -1219,7 +1209,6 @@ const PDFViewerApplication = { pdfDocument.getDownloadInfo().then(({ length }) => { this._contentLength = length; // Ensure that the correct length is used. - this.downloadComplete = true; this.loadingBar?.hide(); firstPagePromise.then(() => { diff --git a/web/ui_utils.js b/web/ui_utils.js index 1ed7e5a3dd7b9..08455659cf959 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -740,7 +740,7 @@ class ProgressBar { } setDisableAutoFetch(delay = /* ms = */ 5000) { - if (isNaN(this.#percent)) { + if (this.#percent === 100 || isNaN(this.#percent)) { return; } if (this.#disableAutoFetchTimeout) {