Move the initialization of "metadata" out of PDFViewerApplication.load

Over time, with more and more API-functionality added, the `PDFViewerApplication.load` method has become quite large and complex. In an attempt to improve the current situation somewhat, this patch moves the fetching and initialization of "metadata" out into its own (private) helper method instead.
This commit is contained in:
Jonas Jenwald 2020-04-05 10:26:55 +02:00
parent 32f1d0de76
commit d07be1a89b

View File

@ -1237,10 +1237,22 @@ const PDFViewerApplication = {
});
this._initializePageLabels(pdfDocument);
this._initializeMetadata(pdfDocument);
},
pdfDocument
.getMetadata()
.then(({ info, metadata, contentDispositionFilename }) => {
/**
* @private
*/
async _initializeMetadata(pdfDocument) {
const {
info,
metadata,
contentDispositionFilename,
} = await pdfDocument.getMetadata();
if (pdfDocument !== this.pdfDocument) {
return; // The document was closed while the metadata resolved.
}
this.documentInfo = info;
this.metadata = metadata;
this.contentDispositionFilename = contentDispositionFilename;
@ -1374,7 +1386,6 @@ const PDFViewerApplication = {
formType,
});
}
});
},
/**