Merge pull request #8788 from Snuffleupagus/pageMode-followup
Attempt to delay disabling of the attachment view until FileAttachment annotations of the *initial* page has been parsed
This commit is contained in:
commit
8c8d8fa239
@ -35,13 +35,12 @@ class PDFAttachmentViewer {
|
|||||||
* @param {PDFAttachmentViewerOptions} options
|
* @param {PDFAttachmentViewerOptions} options
|
||||||
*/
|
*/
|
||||||
constructor({ container, eventBus, downloadManager, }) {
|
constructor({ container, eventBus, downloadManager, }) {
|
||||||
this.attachments = null;
|
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.downloadManager = downloadManager;
|
this.downloadManager = downloadManager;
|
||||||
|
|
||||||
this._renderedCapability = createPromiseCapability();
|
this.reset();
|
||||||
|
|
||||||
this.eventBus.on('fileattachmentannotation',
|
this.eventBus.on('fileattachmentannotation',
|
||||||
this._appendAttachment.bind(this));
|
this._appendAttachment.bind(this));
|
||||||
}
|
}
|
||||||
@ -63,12 +62,12 @@ class PDFAttachmentViewer {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_dispatchEvent(attachmentsCount) {
|
_dispatchEvent(attachmentsCount) {
|
||||||
|
this._renderedCapability.resolve();
|
||||||
|
|
||||||
this.eventBus.dispatch('attachmentsloaded', {
|
this.eventBus.dispatch('attachmentsloaded', {
|
||||||
source: this,
|
source: this,
|
||||||
attachmentsCount,
|
attachmentsCount,
|
||||||
});
|
});
|
||||||
|
|
||||||
this._renderedCapability.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,12 +36,11 @@ class PDFOutlineViewer {
|
|||||||
* @param {PDFOutlineViewerOptions} options
|
* @param {PDFOutlineViewerOptions} options
|
||||||
*/
|
*/
|
||||||
constructor({ container, linkService, eventBus, }) {
|
constructor({ container, linkService, eventBus, }) {
|
||||||
this.outline = null;
|
|
||||||
this.lastToggleIsShow = true;
|
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.linkService = linkService;
|
this.linkService = linkService;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
@ -420,17 +420,31 @@ class PDFSidebar {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.eventBus.on('attachmentsloaded', (evt) => {
|
this.eventBus.on('attachmentsloaded', (evt) => {
|
||||||
let attachmentsCount = evt.attachmentsCount;
|
if (evt.attachmentsCount) {
|
||||||
|
this.attachmentsButton.disabled = false;
|
||||||
|
|
||||||
this.attachmentsButton.disabled = !attachmentsCount;
|
|
||||||
|
|
||||||
if (attachmentsCount) {
|
|
||||||
this._showUINotification(SidebarView.ATTACHMENTS);
|
this._showUINotification(SidebarView.ATTACHMENTS);
|
||||||
} else if (this.active === SidebarView.ATTACHMENTS) {
|
return;
|
||||||
// If the attachment view was opened during document load, switch away
|
|
||||||
// from it if it turns out that the document has no attachments.
|
|
||||||
this.switchView(SidebarView.THUMBS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to avoid temporarily disabling, and switching away from, the
|
||||||
|
// attachment view for documents that do not contain proper attachments
|
||||||
|
// but *only* FileAttachment annotations. Hence we defer those operations
|
||||||
|
// slightly to allow time for parsing any FileAttachment annotations that
|
||||||
|
// may be present on the *initially* rendered page of the document.
|
||||||
|
Promise.resolve().then(() => {
|
||||||
|
if (this.attachmentsView.hasChildNodes()) {
|
||||||
|
// FileAttachment annotations were appended to the attachment view.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.attachmentsButton.disabled = true;
|
||||||
|
|
||||||
|
if (this.active === SidebarView.ATTACHMENTS) {
|
||||||
|
// If the attachment view was opened during document load, switch away
|
||||||
|
// from it if it turns out that the document has no attachments.
|
||||||
|
this.switchView(SidebarView.THUMBS);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the thumbnailViewer, if visible, when exiting presentation mode.
|
// Update the thumbnailViewer, if visible, when exiting presentation mode.
|
||||||
|
Loading…
Reference in New Issue
Block a user