mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-11 05:45:26 -06:00
refactor(toast): get rid of autohide
This commit is contained in:
parent
7463570e76
commit
21335b1b00
@ -8,7 +8,6 @@ export interface ToastOptions {
|
||||
title?: string;
|
||||
message: string;
|
||||
timeout?: number;
|
||||
autohide?: boolean;
|
||||
progress?: number;
|
||||
}
|
||||
|
||||
@ -19,7 +18,6 @@ function showPersistent(options: ToastOptionsWithRequiredId) {
|
||||
if (existingToast) {
|
||||
updateToast(options.id, options);
|
||||
} else {
|
||||
options.autohide = false;
|
||||
addToast(options);
|
||||
}
|
||||
}
|
||||
@ -34,7 +32,6 @@ function showMessage(message: string, timeout = 2000, icon = "bx bx-check") {
|
||||
addToast({
|
||||
icon,
|
||||
message,
|
||||
autohide: true,
|
||||
timeout
|
||||
});
|
||||
}
|
||||
@ -45,7 +42,6 @@ export function showError(message: string, timeout = 10000) {
|
||||
addToast({
|
||||
icon: "bx bx-error-circle",
|
||||
message,
|
||||
autohide: true,
|
||||
timeout
|
||||
})
|
||||
}
|
||||
@ -57,7 +53,6 @@ function showErrorTitleAndMessage(title: string, message: string, timeout = 1000
|
||||
title,
|
||||
icon: "bx bx-error-circle",
|
||||
message,
|
||||
autohide: true,
|
||||
timeout
|
||||
});
|
||||
}
|
||||
|
||||
@ -17,13 +17,12 @@ export default function ToastContainer() {
|
||||
)
|
||||
}
|
||||
|
||||
function Toast({ id, title, autohide, timeout, progress, message, icon }: ToastOptionsWithRequiredId) {
|
||||
function Toast({ id, title, timeout, progress, message, icon }: ToastOptionsWithRequiredId) {
|
||||
// Autohide.
|
||||
useEffect(() => {
|
||||
if (!autohide || !id) return;
|
||||
const timerId = setTimeout(() => removeToastFromStore(id), timeout || DEFAULT_DELAY);
|
||||
return () => clearTimeout(timerId);
|
||||
}, [ autohide, id, timeout ]);
|
||||
}, [ id, timeout ]);
|
||||
|
||||
const closeButton = <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close" />;
|
||||
const toastIcon = <Icon icon={icon.startsWith("bx ") ? icon : `bx bx-${icon}`} />;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user