Merge pull request #13220 from Snuffleupagus/currentOutlineItemPromise-isPagesLoaded

Ensure that `currentOutlineButton` enabling/disabling won't depend on the exact timing of the "pagesloaded" event (PR 13212 follow-up)
This commit is contained in:
Tim van der Meij 2021-04-11 18:30:17 +02:00 committed by GitHub
commit daf4cd0f78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,13 +54,15 @@ class PDFOutlineViewer extends BaseTreeViewer {
this.eventBus._on("pagesloaded", evt => {
this._isPagesLoaded = !!evt.pagesCount;
// If the capability is still pending, note the `_dispatchEvent`-method,
// we know that the `currentOutlineItem`-button should be enabled here.
// If the capability is still pending, see the `_dispatchEvent`-method,
// we know that the `currentOutlineItem`-button can be enabled here.
if (
this._currentOutlineItemCapability &&
!this._currentOutlineItemCapability.settled
) {
this._currentOutlineItemCapability.resolve(/* enabled = */ true);
this._currentOutlineItemCapability.resolve(
/* enabled = */ this._isPagesLoaded
);
}
});
this.eventBus._on("sidebarviewchanged", evt => {
@ -95,6 +97,8 @@ class PDFOutlineViewer extends BaseTreeViewer {
this._pdfDocument?.loadingParams.disableAutoFetch
) {
this._currentOutlineItemCapability.resolve(/* enabled = */ false);
} else if (this._isPagesLoaded) {
this._currentOutlineItemCapability.resolve(/* enabled = */ true);
}
this.eventBus.dispatch("outlineloaded", {