From 112200ae329997296e82d2f11ccbfcfc12bba1fb Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 20 Aug 2024 00:08:36 +0300 Subject: [PATCH] Prevent duplicate toasts --- public/scripts/extensions.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/scripts/extensions.js b/public/scripts/extensions.js index ab7bb6582..eaf08809a 100644 --- a/public/scripts/extensions.js +++ b/public/scripts/extensions.js @@ -660,6 +660,8 @@ async function showExtensionsDetails() { await oldPopup.complete(POPUP_RESULT.CANCELLED); } + let waitingForSave = false; + const popup = new Popup(html, POPUP_TYPE.TEXT, '', { okButton: 'Close', wide: true, @@ -667,9 +669,14 @@ async function showExtensionsDetails() { customButtons: [updateAllButton], allowVerticalScrolling: true, onClosing: async () => { + if (waitingForSave) { + return false; + } if (stateChanged) { - toastr.info('The page will be reloaded shortly...', 'Extensions state changed'); + waitingForSave = true; + const toast = toastr.info('The page will be reloaded shortly...', 'Extensions state changed'); await saveSettings(); + toastr.clear(toast); } return true; },