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:
parent
32f1d0de76
commit
d07be1a89b
19
web/app.js
19
web/app.js
@ -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,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user