Skip to content

Commit

Permalink
fix: expose call and client objects for anon and guest users (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlaz authored Oct 26, 2023
1 parent 5c2d9d9 commit 7da1cae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ export const CallRecordingsPage = ({
});
setVideoClient(_client);

// @ts-ignore - for debugging
window.client = _client;

return () => {
_client
.disconnectUser()
.catch((e) => console.error(`Couldn't disconnect user`, e));
setVideoClient(undefined);
};
}, []);
}, [apiKey, user, userToken]);

if (!videoClient) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default function GuestCallRoom(props: GuestCallRoomProps) {
const guestUserId = (router.query['guest_user_id'] as string) || 'Guest';

const [client, setClient] = useState<StreamVideoClient>();

useEffect(() => {
const userToConnect: User =
mode === 'anon'
Expand All @@ -51,20 +50,25 @@ export default function GuestCallRoom(props: GuestCallRoomProps) {
});
setClient(_client);

// @ts-ignore - for debugging
window.client = _client;

return () => {
_client
.disconnectUser()
.catch((e) => console.error('Failed to disconnect user', e));
setClient(undefined);
};
}, []);
}, [apiKey, guestUserId, mode, token]);

const [call, setCall] = useState<Call>();

useEffect(() => {
const _call = client?.call(callType, callId);
setCall(_call);

// @ts-ignore - for debugging
window.call = _call;

return () => {
if (_call?.state.callingState !== CallingState.LEFT) {
_call?.leave();
Expand Down

0 comments on commit 7da1cae

Please sign in to comment.