Add early returns to a couple of PDFLinkService methods, when there's no active PDF document

All of these methods will, in one way or another, cause e.g. scrolling or zooming to occur and consequently they don't really make sense unless there's an active PDF document. Especially since all of these methods end up calling into a `BaseViewer`-instance, which already contains similar early returns in essentially all of it's methods and setters.
This commit is contained in:
Jonas Jenwald 2020-10-31 09:54:00 +01:00
parent 47b3b39a88
commit 4eaa058c16

View File

@ -182,6 +182,9 @@ class PDFLinkService {
* @param {string|Array} dest - The named, or explicit, PDF destination. * @param {string|Array} dest - The named, or explicit, PDF destination.
*/ */
async goToDestination(dest) { async goToDestination(dest) {
if (!this.pdfDocument) {
return;
}
let namedDest, explicitDest; let namedDest, explicitDest;
if (typeof dest === "string") { if (typeof dest === "string") {
namedDest = dest; namedDest = dest;
@ -206,6 +209,9 @@ class PDFLinkService {
* @param {number} pageNumber - The page number. * @param {number} pageNumber - The page number.
*/ */
goToPage(pageNumber) { goToPage(pageNumber) {
if (!this.pdfDocument) {
return;
}
if ( if (
!( !(
Number.isInteger(pageNumber) && Number.isInteger(pageNumber) &&
@ -261,6 +267,9 @@ class PDFLinkService {
* @param {string} hash * @param {string} hash
*/ */
setHash(hash) { setHash(hash) {
if (!this.pdfDocument) {
return;
}
let pageNumber, dest; let pageNumber, dest;
if (hash.includes("=")) { if (hash.includes("=")) {
const params = parseQueryString(hash); const params = parseQueryString(hash);