mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-14 09:43:22 -03:00
feat(delete): shorten undo window to 20s and make undo toast dismissible
This commit is contained in:
@@ -236,11 +236,11 @@ export function showToast(key, params = {}, type = 'info', fallback = null) {
|
||||
* @param {Object} [options]
|
||||
* @param {string} [options.actionText] - Label for the action button (button omitted when empty)
|
||||
* @param {Function} [options.onAction] - Callback invoked at most once on button click
|
||||
* @param {number} [options.durationMs=30000] - How long the toast stays visible
|
||||
* @param {number} [options.durationMs=20000] - How long the toast stays visible
|
||||
* @param {boolean} [options.countdown=true] - Show a ticking `(N)s` countdown
|
||||
*/
|
||||
export function showActionToast(key, params = {}, type = 'info', options = {}) {
|
||||
const { actionText, onAction, durationMs = 30000, countdown = true } = options;
|
||||
const { actionText, onAction, durationMs = 20000, countdown = true } = options;
|
||||
|
||||
const isPlainMessage = typeof key === 'string' && /\s/.test(key);
|
||||
const message = isPlainMessage ? key : translate(key, params);
|
||||
@@ -295,6 +295,20 @@ export function showActionToast(key, params = {}, type = 'info', options = {}) {
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// Manual close button: hides the toast early without firing onAction. The
|
||||
// backend undo window keeps running and the batch is purged when it expires.
|
||||
const closeBtn = document.createElement('button');
|
||||
closeBtn.type = 'button';
|
||||
closeBtn.className = 'toast-close-btn';
|
||||
closeBtn.textContent = '×';
|
||||
closeBtn.setAttribute('aria-label', translate('common.actions.close'));
|
||||
closeBtn.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
clearCountdown();
|
||||
dismiss();
|
||||
});
|
||||
toast.append(closeBtn);
|
||||
}
|
||||
|
||||
export function restoreFolderFilter() {
|
||||
|
||||
Reference in New Issue
Block a user