feat: remove duplicates from the toast

This commit is contained in:
2024-08-30 11:17:32 +03:00
parent aaf7adbac1
commit 65fac09d8d
2 changed files with 6 additions and 1 deletions

View File

@ -1,8 +1,12 @@
<script>
const alertPlaceholder = $("#alert-placeholder");
function createAlert(title, message, clz, action) {
function createAlert(title, message, clz, action, id) {
if (!id) id = $.md5(title + message); // MD5 id from the content
if (alertPlaceholder.find(`#${id}`).length > 0) return; // check if there are duplicates
const wrapper = document.createElement("div");
wrapper.id = id;
wrapper.classList.add("toast", clz);
wrapper.role = "alert";
wrapper.ariaLive = "assertive";