From 7463570e769ccea4bfd00e5ea98161767cfa75e3 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 7 Dec 2025 00:06:42 +0200 Subject: [PATCH] refactor(toast): rename delay to timeout --- apps/client/src/services/branches.ts | 4 ++-- apps/client/src/services/import.ts | 4 ++-- apps/client/src/services/protected_session.ts | 2 +- apps/client/src/services/toast.ts | 14 +++++++------- apps/client/src/widgets/Toast.tsx | 8 ++++---- apps/client/src/widgets/dialogs/export.tsx | 2 +- apps/client/src/widgets/react/hooks.tsx | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/apps/client/src/services/branches.ts b/apps/client/src/services/branches.ts index 05dc5b997..5672fa370 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.ts index c6557c21d..3e54fd4a3 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.ts index 068b63014..e9382a16c 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.ts index a39768144..a7d11988d 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.tsx index 02ed6d397..5d4cbc5a7 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 =