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.
*/
async goToDestination(dest) {
if (!this.pdfDocument) {
return;
}
let namedDest, explicitDest;
if (typeof dest === "string") {
namedDest = dest;
@ -206,6 +209,9 @@ class PDFLinkService {
* @param {number} pageNumber - The page number.
*/
goToPage(pageNumber) {
if (!this.pdfDocument) {
return;
}
if (
!(
Number.isInteger(pageNumber) &&
@ -261,6 +267,9 @@ class PDFLinkService {
* @param {string} hash
*/
setHash(hash) {
if (!this.pdfDocument) {
return;
}
let pageNumber, dest;
if (hash.includes("=")) {
const params = parseQueryString(hash);