updated alerting methods

Use both toasts and console.
This commit is contained in:
buzz-lightsnack-2007 2024-03-31 15:41:55 +08:00
parent 794f75ecb7
commit 6a1ea8eb7d

View file

@ -2,16 +2,36 @@
Alert management system.
*/
export function confirm_action() {
let user_response = false;
export default class alerts {
static confirm_action() {
let user_response = false;
(async () => {
// Import the module.
let reader = await import(chrome.runtime.getURL("gui/scripts/read.js"));
(async () => {
// Import the module.
let reader = (await import(chrome.runtime.getURL("gui/scripts/read.js")))[
`texts`
];
// Get the user response.
user_response = confirm(reader.read(`GUI_alert_confirm_action_text`));
})();
// Return the user response.
return user_response;
// Get the user response.
user_response = confirm(
reader.localized(`GUI_alert_confirm_action_text`),
);
})();
// Return the user response.
return user_response;
}
static log(message) {
console.log(message);
try {
M.toast({ text: message });
} catch (err) {}
}
static warn(message) {
console.warn(message);
try {
M.toast({ text: message });
} catch (err) {}
}
}