From 9dcc50402e421c6f65cb74996db607cb83c8c4a5 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 2 May 2023 14:16:18 +0200 Subject: [PATCH] Simplify the `PDFSidebar.#forceRendering` method The fallback code-path has never really been used, since the `PDFSidebar` is only used in the default viewer (and has never been exposed in e.g. the COMPONENTS-build). --- web/pdf_sidebar.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/web/pdf_sidebar.js b/web/pdf_sidebar.js index ca38312f3..cc9126b93 100644 --- a/web/pdf_sidebar.js +++ b/web/pdf_sidebar.js @@ -156,7 +156,7 @@ class PDFSidebar { */ switchView(view, forceOpen = false) { const isViewChanged = view !== this.active; - let shouldForceRendering = false; + let forceRendering = false; switch (view) { case SidebarView.NONE: @@ -166,7 +166,7 @@ class PDFSidebar { return; // Closing will trigger rendering and dispatch the event. case SidebarView.THUMBS: if (this.isOpen && isViewChanged) { - shouldForceRendering = true; + forceRendering = true; } break; case SidebarView.OUTLINE: @@ -224,9 +224,9 @@ class PDFSidebar { this.open(); return; // Opening will trigger rendering and dispatch the event. } - if (shouldForceRendering) { + if (forceRendering) { this.#updateThumbnailViewer(); - this.#forceRendering(); + this.onToggled(); } if (isViewChanged) { this.#dispatchEvent(); @@ -246,7 +246,7 @@ class PDFSidebar { if (this.active === SidebarView.THUMBS) { this.#updateThumbnailViewer(); } - this.#forceRendering(); + this.onToggled(); this.#dispatchEvent(); this.#hideUINotification(); @@ -263,7 +263,7 @@ class PDFSidebar { this.outerContainer.classList.add("sidebarMoving"); this.outerContainer.classList.remove("sidebarOpen"); - this.#forceRendering(); + this.onToggled(); this.#dispatchEvent(); } @@ -286,16 +286,6 @@ class PDFSidebar { }); } - #forceRendering() { - if (this.onToggled) { - this.onToggled(); - } else { - // Fallback - this.pdfViewer.forceRendering(); - this.pdfThumbnailViewer.forceRendering(); - } - } - #updateThumbnailViewer() { const { pdfViewer, pdfThumbnailViewer } = this;