Skip to content

Build your personal knowledge base with Trilium Notes

refactor(toast): get rid of autohide

Elian Doran21335b1b00f9
diff --git a/apps/client/src/services/toast.ts b/apps/client/src/services/toast.ts
index a7d11988d3..1278d1d449 100644
--- a/apps/client/src/services/toast.ts
+++ b/apps/client/src/services/toast.ts
@@ -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
});
}
diff --git a/apps/client/src/widgets/Toast.tsx b/apps/client/src/widgets/Toast.tsx
index 5d4cbc5a74..6026c91714 100644
--- a/apps/client/src/widgets/Toast.tsx
+++ b/apps/client/src/widgets/Toast.tsx
@@ -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}`} />;