Use optional chaining to simplify PDFViewerApplication.store
accesses in various event handlers
This way we no longer need the intermediate variables.
This commit is contained in:
parent
d6e8b8fbc1
commit
292a715c1c
35
web/app.js
35
web/app.js
@ -2413,28 +2413,29 @@ function webViewerSidebarViewChanged(evt) {
|
|||||||
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled =
|
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled =
|
||||||
PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
|
PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
|
||||||
|
|
||||||
const store = PDFViewerApplication.store;
|
if (PDFViewerApplication.isInitialViewSet) {
|
||||||
if (store && PDFViewerApplication.isInitialViewSet) {
|
|
||||||
// Only update the storage when the document has been loaded *and* rendered.
|
// Only update the storage when the document has been loaded *and* rendered.
|
||||||
store.set("sidebarView", evt.view).catch(function () {});
|
PDFViewerApplication.store?.set("sidebarView", evt.view).catch(() => {
|
||||||
|
// Unable to write to storage.
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerUpdateViewarea(evt) {
|
function webViewerUpdateViewarea(evt) {
|
||||||
const location = evt.location,
|
const location = evt.location;
|
||||||
store = PDFViewerApplication.store;
|
|
||||||
|
|
||||||
if (store && PDFViewerApplication.isInitialViewSet) {
|
if (PDFViewerApplication.isInitialViewSet) {
|
||||||
store
|
// Only update the storage when the document has been loaded *and* rendered.
|
||||||
.setMultiple({
|
PDFViewerApplication.store
|
||||||
|
?.setMultiple({
|
||||||
page: location.pageNumber,
|
page: location.pageNumber,
|
||||||
zoom: location.scale,
|
zoom: location.scale,
|
||||||
scrollLeft: location.left,
|
scrollLeft: location.left,
|
||||||
scrollTop: location.top,
|
scrollTop: location.top,
|
||||||
rotation: location.rotation,
|
rotation: location.rotation,
|
||||||
})
|
})
|
||||||
.catch(function () {
|
.catch(() => {
|
||||||
/* unable to write to storage */
|
// Unable to write to storage.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(
|
const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(
|
||||||
@ -2453,18 +2454,20 @@ function webViewerUpdateViewarea(evt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function webViewerScrollModeChanged(evt) {
|
function webViewerScrollModeChanged(evt) {
|
||||||
const store = PDFViewerApplication.store;
|
if (PDFViewerApplication.isInitialViewSet) {
|
||||||
if (store && PDFViewerApplication.isInitialViewSet) {
|
|
||||||
// Only update the storage when the document has been loaded *and* rendered.
|
// Only update the storage when the document has been loaded *and* rendered.
|
||||||
store.set("scrollMode", evt.mode).catch(function () {});
|
PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {
|
||||||
|
// Unable to write to storage.
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerSpreadModeChanged(evt) {
|
function webViewerSpreadModeChanged(evt) {
|
||||||
const store = PDFViewerApplication.store;
|
if (PDFViewerApplication.isInitialViewSet) {
|
||||||
if (store && PDFViewerApplication.isInitialViewSet) {
|
|
||||||
// Only update the storage when the document has been loaded *and* rendered.
|
// Only update the storage when the document has been loaded *and* rendered.
|
||||||
store.set("spreadMode", evt.mode).catch(function () {});
|
PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {
|
||||||
|
// Unable to write to storage.
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user