diff --git a/web/app.js b/web/app.js index 355e36c48..f4489e956 100644 --- a/web/app.js +++ b/web/app.js @@ -694,7 +694,7 @@ const PDFViewerApplication = { async run(config) { await this.initialize(config); - const { appConfig, eventBus, l10n } = this; + const { appConfig, eventBus } = this; let file; if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { const queryString = document.location.search.substring(1); @@ -745,7 +745,7 @@ const PDFViewerApplication = { if (!this.supportsDocumentFonts) { AppOptions.set("disableFontFace", true); - l10n.get("web_fonts_disabled").then(msg => { + this.l10n.get("web_fonts_disabled").then(msg => { console.warn(msg); }); } @@ -775,22 +775,16 @@ const PDFViewerApplication = { true ); - try { - if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { - if (file) { - this.open({ url: file }); - } else { - this._hideViewBookmark(); - } - } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) { - this.initPassiveLoading(file); + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { + if (file) { + this.open({ url: file }); } else { - throw new Error("Not implemented: run"); + this._hideViewBookmark(); } - } catch (reason) { - l10n.get("loading_error").then(msg => { - this._documentError(msg, reason); - }); + } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) { + this.initPassiveLoading(file); + } else { + throw new Error("Not implemented: run"); } }, @@ -1289,13 +1283,13 @@ const PDFViewerApplication = { // Since the `setInitialView` call below depends on this being resolved, // fetch it early to avoid delaying initial rendering of the PDF document. - const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () { + const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => { /* Avoid breaking initial rendering; ignoring errors. */ }); - const pageModePromise = pdfDocument.getPageMode().catch(function () { + const pageModePromise = pdfDocument.getPageMode().catch(() => { /* Avoid breaking initial rendering; ignoring errors. */ }); - const openActionPromise = pdfDocument.getOpenAction().catch(function () { + const openActionPromise = pdfDocument.getOpenAction().catch(() => { /* Avoid breaking initial rendering; ignoring errors. */ }); @@ -1336,7 +1330,6 @@ const PDFViewerApplication = { }) .catch(() => { /* Unable to read from storage; ignoring errors. */ - return Object.create(null); }); firstPagePromise.then(pdfPage => { @@ -1369,7 +1362,7 @@ const PDFViewerApplication = { let scrollMode = AppOptions.get("scrollModeOnLoad"); let spreadMode = AppOptions.get("spreadModeOnLoad"); - if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) { + if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) { hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;