Skip to content

Commit 6b79501

Browse files
committed
fix: do not show multiple toasts when socket connection fails
1 parent ad91130 commit 6b79501

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

frontend/src/hooks/useActiveSocketConnection.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ export const useActiveSocketConnection = () => {
1919
console.log("Socket connection failed", socketConnectionCount.current)
2020
// If the socket connection fails more than 2 times, then show an error message
2121
if (socketConnectionCount.current === 2) {
22-
toast.error("Realtime events are not working. Please try refreshing the page.", {
23-
duration: 5000
24-
})
22+
const isToastActive = toast.getToasts().some(toast => toast.id === "socket-connection-error")
23+
if (!isToastActive) {
24+
toast.error("Realtime events are not working. Please try refreshing the page.", {
25+
duration: 5000,
26+
closeButton: true,
27+
id: "socket-connection-error"
28+
})
29+
}
2530
} else {
2631
// Else try to connect to socket
2732
socket?.connect()

0 commit comments

Comments
 (0)