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

This commit is contained in:
Alex van Andel
2023-11-28 23:04:54 +00:00
committed by GitHub
parent f19a1926b4
commit bd6ca21e02
@@ -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>