From 3a4948755663a00bdbb9b8343cfec4ff21a562ba Mon Sep 17 00:00:00 2001 From: buzzcode2007 <73412182+buzz_lightsnack_2007@users.noreply.github.com> Date: Mon, 8 Apr 2024 20:24:05 +0800 Subject: [PATCH] moved reader to avoid re-importing per function --- gui/scripts/alerts.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/gui/scripts/alerts.js b/gui/scripts/alerts.js index 4ebdbdd..2f48f6e 100644 --- a/gui/scripts/alerts.js +++ b/gui/scripts/alerts.js @@ -2,21 +2,14 @@ Alert management system. */ +const reader = (await import(chrome.runtime.getURL("gui/scripts/read.js"))).default; + export default class alerts { - static confirm_action() { - let user_response = false; + static async confirm(MESSAGE) { + let user_response = confirm( + reader.localized((MESSAGE) ? MESSAGE : `GUI_alert_confirm_action_text`), + ); - (async () => { - // Import the module. - let reader = (await import(chrome.runtime.getURL("gui/scripts/read.js")))[ - `texts` - ]; - - // Get the user response. - user_response = confirm( - reader.localized(`GUI_alert_confirm_action_text`), - ); - })(); // Return the user response. return user_response; }