From ba4773a61e6a406dcea92a7251c17709b97dcfdc Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 2 May 2024 17:51:39 +0000 Subject: add some deduplication --- view/js/main.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/view/js/main.js b/view/js/main.js index 5d273ee39..4280284ae 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1820,11 +1820,16 @@ function toggleAside() { function toast(string, severity) { let container = document.getElementById('toast-container'); - let toast = document.createElement('div'); - toast.innerHTML = '
' + string + '
'; - toast.classList.add('toast', 'p-2', 'bg-' + severity + '-subtle', 'text-' + severity + '-emphasis', 'border-' + severity); - container.prepend(toast); + let toast = document.getElementById(btoa(string)); + + if (!toast) { + toast = document.createElement('div'); + toast.setAttribute('id', btoa(string)); + toast.innerHTML = '
' + string + '
'; + toast.classList.add('toast', 'p-2', 'bg-' + severity + '-subtle', 'text-' + severity + '-emphasis', 'border-' + severity); + container.prepend(toast); + } let toastInstance = bootstrap.Toast.getOrCreateInstance(toast); -- cgit v1.2.3