Merge pull request #19557 from Snuffleupagus/PDFViewer-cleanupTimeouts

Abort various timeouts, in `PDFViewer`, when closing the document (PR 19128 follow-up)
This commit is contained in:
Jonas Jenwald 2025-02-27 11:17:02 +01:00 committed by GitHub
commit 4a48a7ec0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1173,6 +1173,7 @@ class PDFViewer {
this.#hiddenCopyElement?.remove(); this.#hiddenCopyElement?.remove();
this.#hiddenCopyElement = null; this.#hiddenCopyElement = null;
this.#cleanupTimeouts();
this.#cleanupSwitchAnnotationEditorMode(); this.#cleanupSwitchAnnotationEditorMode();
} }
@ -2340,6 +2341,17 @@ class PDFViewer {
]); ]);
} }
#cleanupTimeouts() {
if (this.#scaleTimeoutId !== null) {
clearTimeout(this.#scaleTimeoutId);
this.#scaleTimeoutId = null;
}
if (this.#scrollTimeoutId !== null) {
clearTimeout(this.#scrollTimeoutId);
this.#scrollTimeoutId = null;
}
}
#cleanupSwitchAnnotationEditorMode() { #cleanupSwitchAnnotationEditorMode() {
this.#switchAnnotationEditorModeAC?.abort(); this.#switchAnnotationEditorModeAC?.abort();
this.#switchAnnotationEditorModeAC = null; this.#switchAnnotationEditorModeAC = null;
@ -2466,14 +2478,8 @@ class PDFViewer {
for (const pageView of this._pages) { for (const pageView of this._pages) {
pageView.update(updateArgs); pageView.update(updateArgs);
} }
if (this.#scaleTimeoutId !== null) { this.#cleanupTimeouts();
clearTimeout(this.#scaleTimeoutId);
this.#scaleTimeoutId = null;
}
if (this.#scrollTimeoutId !== null) {
clearTimeout(this.#scrollTimeoutId);
this.#scrollTimeoutId = null;
}
if (!noUpdate) { if (!noUpdate) {
this.update(); this.update();
} }