diff --git a/conversations.php b/conversations.php index 4797f6d..de6d0a4 100644 --- a/conversations.php +++ b/conversations.php @@ -712,7 +712,11 @@ const icon = type === 'success' ? '✅' : (type === 'danger' ? '⚠️' : (type === 'warning' ? '⚠' : 'ℹ️')); toast.innerHTML = `${icon}
${message}
`; container.appendChild(toast); - setTimeout(() => { if (toast.parentNode) toast.remove(); }, type === 'success' ? 4000 : 8000); + // Ensure a sensible minimum duration (3s) so very short toasts don't disappear instantly + const _minToastDuration = 3000; + let _dur = (type === 'success') ? 4000 : 8000; + _dur = Math.max(_dur, _minToastDuration); + setTimeout(() => { if (toast.parentNode) toast.remove(); }, _dur); } catch (e) { // fallback to alert if DOM fails try { alert(message); } catch (e2) { /* ignore */ } @@ -839,7 +843,10 @@ container.appendChild(toast); // Auto remove (shorter for compact notifications) - const timeout = notification.cool ? 15000 : 8000; + const _minToastDuration = 3000; + let timeout = notification.duration ? Number(notification.duration) : (notification.cool ? 15000 : 8000); + if (!isFinite(timeout) || timeout <= 0) timeout = (notification.cool ? 15000 : 8000); + timeout = Math.max(timeout, _minToastDuration); setTimeout(() => { if (toast.parentNode) toast.remove(); }, timeout); }