- added method to force disable reload

This commit is contained in:
Sören Oesterwind 2023-07-07 14:02:54 +02:00
parent f4d6ed4d8f
commit 90924aa30d

View File

@ -1,5 +1,5 @@
currentToasts = [];
var forceSkipReload = false;
/**
* Generic function to create a new toast
* @param {String} message The message to be displayed
@ -8,7 +8,7 @@ currentToasts = [];
* @param {Boolean} autoReload Should the page reload after the toast is hidden, default is true (for compatibility with old code)
* @returns {String} The id of the created toast, format: toast-<number>
*/
function createNewToast(message, colorSelector, autoHideTime = 3000, autoReload = true) {
function createNewToast(message, colorSelector, autoHideTime = 1500, autoReload = true) {
const targetContainer = document.getElementById('toastMainController');
const masterToast = document.getElementById('masterToast');
const newToast = masterToast.cloneNode(true);
@ -21,7 +21,7 @@ function createNewToast(message, colorSelector, autoHideTime = 3000, autoReload
$(newToast).toast('show');
setTimeout(() => {
destroyToast(newToast.id);
if (autoReload) {
if (autoReload && !forceSkipReload) {
location.reload();
}
}, autoHideTime);