Skip to content

Commit

Permalink
[frontend] Fix to connect socket only when currentUser can be obtained
Browse files Browse the repository at this point in the history
  • Loading branch information
lim396 committed Mar 5, 2024
1 parent 6737e8c commit ad184ae
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/app/lib/client-socket-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ export default function SocketProvider() {
showNotificationToast(data);
}
};
chatSocket.onAny(handler);
chatSocket.connect();
if (currentUser) {
chatSocket.onAny(handler);
chatSocket.connect();
}
return () => {
chatSocket.offAny(handler);
chatSocket.disconnect();
Expand Down

0 comments on commit ad184ae

Please sign in to comment.