From f8ea83609f8277b15bedeb1549f185dd2f596a75 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 6 Dec 2020 12:30:33 +0100 Subject: [PATCH] Dispatch a `metadataloaded` event once the `PDFViewerApplication._initializeMetadata` method is done This will be useful in the following patch, and note that there's also an old issue (see 5765) which asked for such an event. However, given that the use-case wasn't *clearly* specified, and that we didn't have an internal use for it at the time it wasn't implemented. Also, ensure that all of the metadata-related properties are actually reset when the document is closed. --- web/app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/app.js b/web/app.js index 620c9c239..baacb1b0f 100644 --- a/web/app.js +++ b/web/app.js @@ -248,7 +248,9 @@ const PDFViewerApplication = { url: "", baseUrl: "", externalServices: DefaultExternalServices, - _boundEvents: {}, + _boundEvents: Object.create(null), + documentInfo: null, + metadata: null, contentDispositionFilename: null, triggerDelayedFallback: null, _saveInProgress: false, @@ -789,6 +791,8 @@ const PDFViewerApplication = { this.downloadComplete = false; this.url = ""; this.baseUrl = ""; + this.documentInfo = null; + this.metadata = null; this.contentDispositionFilename = null; this.triggerDelayedFallback = null; this._saveInProgress = false; @@ -1652,6 +1656,8 @@ const PDFViewerApplication = { generator: generatorId, formType, }); + + this.eventBus.dispatch("metadataloaded", { source: this }); }, /**