Make toast support preventDuplicates (#31501)

make preventDuplicates default to true, users get a clear UI feedback
and know that "a new message appears".

Fixes: https://github.com/go-gitea/gitea/issues/26651

---------

Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
wxiaoguang 2024-06-27 21:58:38 +08:00 committed by GitHub
parent 9bc5552c11
commit c1fe6fbcc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 86 additions and 39 deletions

View file

@ -306,3 +306,14 @@ export function createElementFromAttrs(tagName, attrs) {
}
return el;
}
export function animateOnce(el, animationClassName) {
return new Promise((resolve) => {
el.addEventListener('animationend', function onAnimationEnd() {
el.classList.remove(animationClassName);
el.removeEventListener('animationend', onAnimationEnd);
resolve();
}, {once: true});
el.classList.add(animationClassName);
});
}