Skip to content

Commit

Permalink
use switch in realtime switch
Browse files Browse the repository at this point in the history
  • Loading branch information
aabassiouni committed Oct 22, 2024
1 parent 42c3263 commit 9bc290a
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions apps/web/src/components/realtime-switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,27 @@ export function RealtimeSwitch() {
checked={enabled}
className="dark:data-[state=checked]:bg-primary"
onCheckedChange={(checked) => {
if (checked) {
router.refresh();
resetRealtimeCount();
reconnect();
toast.toast({
title: "Realtime Enabled",
description: "Your signups will be updated as they come in.",
});
} else {
if (ws) {
switch (checked) {
case true:
router.refresh();
resetRealtimeCount();
ws.close();
reconnect();
toast.toast({
title: "Realtime Disabled",
description: "Signups will no longer update in real-time. Refresh the page to see new signups.",
title: "Realtime Enabled",
description: "Your signups will be updated as they come in.",
});
}
break;
case false:
if (ws) {
router.refresh();
resetRealtimeCount();
ws.close();
toast.toast({
title: "Realtime Disabled",
description: "Signups will no longer update in real-time. Refresh the page to see new signups.",
});
}
break;
}
setEnabled(!enabled);
}}
Expand Down

0 comments on commit 9bc290a

Please sign in to comment.