Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(toast): rename delay to timeout
Elian Doran7463570e769c
diff --git a/apps/client/src/services/branches.ts b/apps/client/src/services/branches.tsindex 05dc5b9970..5672fa3701 100644--- a/apps/client/src/services/branches.ts+++ b/apps/client/src/services/branches.ts@@ -216,7 +216,7 @@ ws.subscribeToMessages(async (message) => {toastService.showPersistent(makeToast(message.taskId, t("branches.delete-notes-in-progress", { count: message.progressCount })));} else if (message.type === "taskSucceeded") {const toast = makeToast(message.taskId, t("branches.delete-finished-successfully"));- toast.delay = 5000;+ toast.timeout = 5000;toastService.showPersistent(toast);}@@ -234,7 +234,7 @@ ws.subscribeToMessages(async (message) => {toastService.showPersistent(makeToast(message.taskId, t("branches.undeleting-notes-in-progress", { count: message.progressCount })));} else if (message.type === "taskSucceeded") {const toast = makeToast(message.taskId, t("branches.undeleting-notes-finished-successfully"));- toast.delay = 5000;+ toast.timeout = 5000;toastService.showPersistent(toast);}diff --git a/apps/client/src/services/import.ts b/apps/client/src/services/import.tsindex c6557c21df..3e54fd4a38 100644--- a/apps/client/src/services/import.ts+++ b/apps/client/src/services/import.ts@@ -78,7 +78,7 @@ ws.subscribeToMessages(async (message) => {toastService.showPersistent(makeToast(message.taskId, t("import.in-progress", { progress: message.progressCount })));} else if (message.type === "taskSucceeded") {const toast = makeToast(message.taskId, t("import.successful"));- toast.delay = 5000;+ toast.timeout = 5000;toastService.showPersistent(toast);@@ -100,7 +100,7 @@ ws.subscribeToMessages(async (message: WebSocketMessage) => {toastService.showPersistent(makeToast(message.taskId, t("import.in-progress", { progress: message.progressCount })));} else if (message.type === "taskSucceeded") {const toast = makeToast(message.taskId, t("import.successful"));- toast.delay = 5000;+ toast.timeout = 5000;toastService.showPersistent(toast);diff --git a/apps/client/src/services/protected_session.ts b/apps/client/src/services/protected_session.tsindex 068b630141..e9382a16cd 100644--- a/apps/client/src/services/protected_session.ts+++ b/apps/client/src/services/protected_session.ts@@ -124,7 +124,7 @@ ws.subscribeToMessages(async (message) => {} else if (message.type === "taskSucceeded") {const text = isProtecting ? t("protected_session.protecting-finished-successfully") : t("protected_session.unprotecting-finished-successfully");const toast = makeToast(message, title, text);- toast.delay = 3000;+ toast.timeout = 3000;toastService.showPersistent(toast);}diff --git a/apps/client/src/services/toast.ts b/apps/client/src/services/toast.tsindex a397681449..a7d11988d3 100644--- a/apps/client/src/services/toast.ts+++ b/apps/client/src/services/toast.ts@@ -7,7 +7,7 @@ export interface ToastOptions {icon: string;title?: string;message: string;- delay?: number;+ timeout?: number;autohide?: boolean;progress?: number;}@@ -28,29 +28,29 @@ function closePersistent(id: string) {removeToastFromStore(id);}-function showMessage(message: string, delay = 2000, icon = "bx bx-check") {+function showMessage(message: string, timeout = 2000, icon = "bx bx-check") {console.debug(utils.now(), "message:", message);addToast({icon,message,autohide: true,- delay+ timeout});}-export function showError(message: string, delay = 10000) {+export function showError(message: string, timeout = 10000) {console.log(utils.now(), "error: ", message);addToast({icon: "bx bx-error-circle",message,autohide: true,- delay+ timeout})}-function showErrorTitleAndMessage(title: string, message: string, delay = 10000) {+function showErrorTitleAndMessage(title: string, message: string, timeout = 10000) {console.log(utils.now(), "error: ", message);addToast({@@ -58,7 +58,7 @@ function showErrorTitleAndMessage(title: string, message: string, delay = 10000)icon: "bx bx-error-circle",message,autohide: true,- delay+ timeout});}diff --git a/apps/client/src/widgets/Toast.tsx b/apps/client/src/widgets/Toast.tsxindex 02ed6d3971..5d4cbc5a74 100644--- a/apps/client/src/widgets/Toast.tsx+++ b/apps/client/src/widgets/Toast.tsx@@ -17,13 +17,13 @@ export default function ToastContainer() {)}-function Toast({ id, title, autohide, delay, progress, message, icon }: ToastOptionsWithRequiredId) {+function Toast({ id, title, autohide, timeout, progress, message, icon }: ToastOptionsWithRequiredId) {// Autohide.useEffect(() => {if (!autohide || !id) return;- const timeout = setTimeout(() => removeToastFromStore(id), delay || DEFAULT_DELAY);- return () => clearTimeout(timeout);- }, [ autohide, id, delay ]);+ const timerId = setTimeout(() => removeToastFromStore(id), timeout || DEFAULT_DELAY);+ return () => clearTimeout(timerId);+ }, [ autohide, 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}`} />;diff --git a/apps/client/src/widgets/dialogs/export.tsx b/apps/client/src/widgets/dialogs/export.tsxindex aaad8ab311..a8682df80b 100644--- a/apps/client/src/widgets/dialogs/export.tsx+++ b/apps/client/src/widgets/dialogs/export.tsx@@ -152,7 +152,7 @@ ws.subscribeToMessages(async (message) => {toastService.showPersistent(makeToast(message.taskId, t("export.export_in_progress", { progressCount: message.progressCount })));} else if (message.type === "taskSucceeded") {const toast = makeToast(message.taskId, t("export.export_finished_successfully"));- toast.delay = 5000;+ toast.timeout = 5000;toastService.showPersistent(toast);}diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex 720acfdcdb..9796a6d4f9 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -737,7 +737,7 @@ export function useNoteTreeDrag(containerRef: MutableRef<HTMLElement | null | untoast.showPersistent({...dragNotEnabledMessage,id: "drag-not-enabled",- delay: 5000+ timeout: 5000});}}