From 64b5568ce40ae85473df7968fb3652f25719623f Mon Sep 17 00:00:00 2001 From: Timo Lins Date: Wed, 3 Feb 2021 10:20:47 +0100 Subject: [PATCH 1/2] Allow `-1` duration for persistent toasts --- src/core/use-toaster.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/use-toaster.ts b/src/core/use-toaster.ts index 9534c85..6032be8 100644 --- a/src/core/use-toaster.ts +++ b/src/core/use-toaster.ts @@ -14,6 +14,10 @@ export const useToaster = (toastOptions?: DefaultToastOptions) => { const now = Date.now(); const timeouts = toasts.map((t) => { + if (t.duration === -1) { + return; + } + const durationLeft = (t.duration || 0) + t.pauseDuration - (now - t.createdAt); From a2142712bc4fd078875d415f9331fa872a5e44d0 Mon Sep 17 00:00:00 2001 From: Timo Lins Date: Sat, 13 Feb 2021 22:07:18 +0100 Subject: [PATCH 2/2] Use `Infinity` instead of `-1` for persistant toasts --- src/core/use-toaster.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/use-toaster.ts b/src/core/use-toaster.ts index 6032be8..c4f83dc 100644 --- a/src/core/use-toaster.ts +++ b/src/core/use-toaster.ts @@ -14,7 +14,7 @@ export const useToaster = (toastOptions?: DefaultToastOptions) => { const now = Date.now(); const timeouts = toasts.map((t) => { - if (t.duration === -1) { + if (t.duration === Infinity) { return; }