Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Toggling really fast throws internal errors (#12580)

Alex van Andelbd6ca21e02ff
diff --git a/packages/features/calendars/CalendarSwitch.tsx b/packages/features/calendars/CalendarSwitch.tsx
index 06dcd889ed9..996e0fcec91 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) => {
<Switch
id={externalId}
checked={checkedInternal}
- onCheckedChange={(isOn: boolean) => {
+ disabled={mutation.isLoading}
+ onCheckedChange={async (isOn: boolean) => {
setCheckedInternal(isOn);
- mutation.mutate({ isOn });
+ await mutation.mutate({ isOn });
}}
/>
</div>