From 8d72981c18d350f5fd9f86d62f3e11fbd8b94685 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 7 Dec 2020 17:21:49 +0100 Subject: [PATCH] Move cancelling of idleCallbacks from `PDFViewerApplication.close` and into its own helper method Since the `close` method has become quite large, this small re-factoring shouldn't hurt. --- web/app.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/web/app.js b/web/app.js index ff7aa9fb8..9fa21cd71 100644 --- a/web/app.js +++ b/web/app.js @@ -763,6 +763,19 @@ const PDFViewerApplication = { document.title = title; }, + /** + * @private + */ + _cancelIdleCallbacks() { + if (!this._idleCallbacks.size) { + return; + } + for (const callback of this._idleCallbacks) { + window.cancelIdleCallback(callback); + } + this._idleCallbacks.clear(); + }, + /** * Closes opened PDF document. * @returns {Promise} - Returns the promise, which is resolved when all @@ -799,10 +812,8 @@ const PDFViewerApplication = { this._contentLength = null; this.triggerDelayedFallback = null; this._saveInProgress = false; - for (const callback of this._idleCallbacks) { - window.cancelIdleCallback(callback); - } - this._idleCallbacks.clear(); + + this._cancelIdleCallbacks(); if (this._scriptingInstance) { const { scripting, events } = this._scriptingInstance;