Skip to content

Commit

Permalink
clarify some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kahkeng committed Jul 15, 2023
1 parent 23626cf commit 778dc14
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/contexts/ChatContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ export const ChatContextProvider = ({ children }: { children: ReactNode }) => {
const queryClient = useQueryClient();

const { status } = useSession();
// shouldConnect allows logged out to view public sessions, but we want to
// shouldConnect can be true for logged out to view public sessions, but we want to
// enforce a disconnect and reconnect when the auth status changes, so
// we use the latest cookie state
// that the websocket will end up use the latest cookie state
const shouldConnect = status == lastAuthStatus;
const backendUrl = getBackendWebsocketUrl();
const {
Expand Down Expand Up @@ -114,6 +114,8 @@ export const ChatContextProvider = ({ children }: { children: ReactNode }) => {
return;
}
let needsReset = false;
// check both changes below in one pass because the hook might not
// fire again if both things change at the same time
if (status != lastAuthStatus) {
setLastAuthStatus(status);
needsReset = true;
Expand Down

0 comments on commit 778dc14

Please sign in to comment.