From bd6ca21e02ff93aae3bd19c6d7093f2a2dc15810 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 28 Nov 2023 23:04:54 +0000 Subject: [PATCH] fix: Toggling really fast throws internal errors (#12580) --- packages/features/calendars/CalendarSwitch.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/features/calendars/CalendarSwitch.tsx b/packages/features/calendars/CalendarSwitch.tsx index 06dcd889ed..996e0fcec9 100644 --- a/packages/features/calendars/CalendarSwitch.tsx +++ b/packages/features/calendars/CalendarSwitch.tsx @@ -67,7 +67,7 @@ const CalendarSwitch = (props: ICalendarSwitchProps) => { }, onError() { setCheckedInternal(false); - showToast(`Something went wrong when toggling "${title}""`, "error"); + showToast(`Something went wrong when toggling "${title}"`, "error"); }, } ); @@ -77,9 +77,10 @@ const CalendarSwitch = (props: ICalendarSwitchProps) => { { + disabled={mutation.isLoading} + onCheckedChange={async (isOn: boolean) => { setCheckedInternal(isOn); - mutation.mutate({ isOn }); + await mutation.mutate({ isOn }); }} />