Simplify handling of any ViewHistory
errors during document loading in the viewer
We can use modern JavaScript features, in this case optional chaining, to (ever so slightly) simplify how `ViewHistory` errors are handled. Also, use arrow functions when handling a few other (very rare) errors during loading since that's a tiny bit shorter.
This commit is contained in:
parent
82faae26c0
commit
ecf95e552f
@ -1289,13 +1289,13 @@ const PDFViewerApplication = {
|
|||||||
|
|
||||||
// Since the `setInitialView` call below depends on this being resolved,
|
// Since the `setInitialView` call below depends on this being resolved,
|
||||||
// fetch it early to avoid delaying initial rendering of the PDF document.
|
// 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. */
|
/* Avoid breaking initial rendering; ignoring errors. */
|
||||||
});
|
});
|
||||||
const pageModePromise = pdfDocument.getPageMode().catch(function () {
|
const pageModePromise = pdfDocument.getPageMode().catch(() => {
|
||||||
/* Avoid breaking initial rendering; ignoring errors. */
|
/* Avoid breaking initial rendering; ignoring errors. */
|
||||||
});
|
});
|
||||||
const openActionPromise = pdfDocument.getOpenAction().catch(function () {
|
const openActionPromise = pdfDocument.getOpenAction().catch(() => {
|
||||||
/* Avoid breaking initial rendering; ignoring errors. */
|
/* Avoid breaking initial rendering; ignoring errors. */
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1336,7 +1336,6 @@ const PDFViewerApplication = {
|
|||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
/* Unable to read from storage; ignoring errors. */
|
/* Unable to read from storage; ignoring errors. */
|
||||||
return Object.create(null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
firstPagePromise.then(pdfPage => {
|
firstPagePromise.then(pdfPage => {
|
||||||
@ -1369,7 +1368,7 @@ const PDFViewerApplication = {
|
|||||||
let scrollMode = AppOptions.get("scrollModeOnLoad");
|
let scrollMode = AppOptions.get("scrollModeOnLoad");
|
||||||
let spreadMode = AppOptions.get("spreadModeOnLoad");
|
let spreadMode = AppOptions.get("spreadModeOnLoad");
|
||||||
|
|
||||||
if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
|
if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
|
||||||
hash =
|
hash =
|
||||||
`page=${stored.page}&zoom=${zoom || stored.zoom},` +
|
`page=${stored.page}&zoom=${zoom || stored.zoom},` +
|
||||||
`${stored.scrollLeft},${stored.scrollTop}`;
|
`${stored.scrollLeft},${stored.scrollTop}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user