Skip to content

Ensure that currentOutlineButton enabling/disabling won't depend on the exact timing of the "pagesloaded" event (PR 13212 follow-up) #13220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions web/pdf_outline_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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", {
Expand Down