fix import method to support service worker
This commit is contained in:
parent
cd0384c3d1
commit
7eb0b86640
3 changed files with 77 additions and 60 deletions
|
@ -2,12 +2,11 @@
|
|||
Alert management system.
|
||||
*/
|
||||
|
||||
const reader = (await import(chrome.runtime.getURL("gui/scripts/read.js"))).default;
|
||||
|
||||
import texts from "/gui/scripts/read.js";
|
||||
export default class alerts {
|
||||
static async confirm(MESSAGE) {
|
||||
let user_response = confirm(
|
||||
reader.localized((MESSAGE) ? MESSAGE : `GUI_alert_confirm_action_text`),
|
||||
texts.localized((MESSAGE) ? MESSAGE : `GUI_alert_confirm_action_text`),
|
||||
);
|
||||
|
||||
// Return the user response.
|
||||
|
@ -46,13 +45,13 @@ export default class alerts {
|
|||
*/
|
||||
static warn(message, critical = false) {
|
||||
console.warn(message);
|
||||
if (critical) {
|
||||
alert(message);
|
||||
} else {
|
||||
try {
|
||||
M.toast({ text: message });
|
||||
} catch (err) {}
|
||||
}
|
||||
if (critical) {
|
||||
alert(message);
|
||||
} else {
|
||||
try {
|
||||
M.toast({ text: message });
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -62,20 +61,18 @@ export default class alerts {
|
|||
@param {number} ERROR_MESSAGE the custom error message
|
||||
@param {boolean} critical the critical nature
|
||||
*/
|
||||
static error(ERROR_CODE, ERROR_MESSAGE, ERROR_STACK, critical = true) {
|
||||
(async () => {
|
||||
// Import the templating.
|
||||
const texts = (await import(chrome.runtime.getURL("gui/scripts/read.js"))).default;
|
||||
static async error(ERROR_CODE, ERROR_MESSAGE, ERROR_STACK, critical = true) {
|
||||
// Import the templating.
|
||||
const texts = (await import(chrome.runtime.getURL("gui/scripts/read.js"))).default;
|
||||
|
||||
// Display the error message.
|
||||
console.error(texts.localized(`error_msg`, false, [ERROR_CODE, ERROR_MESSAGE, ERROR_STACK]));
|
||||
if (critical) {
|
||||
alert(texts.localized(`error_msg_GUI`, false, [String(ERROR_CODE), ERROR_MESSAGE]));
|
||||
} else {
|
||||
try {
|
||||
M.toast({ text: ERROR_MESSAGE });
|
||||
} catch (err) {};
|
||||
};
|
||||
})();
|
||||
// Display the error message.
|
||||
console.error(texts.localized(`error_msg`, false, [ERROR_CODE, ERROR_MESSAGE, ERROR_STACK]));
|
||||
if (critical) {
|
||||
alert(texts.localized(`error_msg_GUI`, false, [String(ERROR_CODE), ERROR_MESSAGE]));
|
||||
} else {
|
||||
try {
|
||||
M.toast({ text: ERROR_MESSAGE });
|
||||
} catch (err) {};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue