fixed exitredirect issue

This commit is contained in:
Jon 2021-06-16 11:06:10 +01:00
parent 3031884e52
commit 9d8c64d7c4
3 changed files with 13 additions and 8 deletions

View File

@ -33,7 +33,7 @@ export const CallProvider = ({
const [preJoinNonAuthorized, setPreJoinNonAuthorized] = useState(false); const [preJoinNonAuthorized, setPreJoinNonAuthorized] = useState(false);
// Daily CallMachine hook (primarily handles status of the call) // Daily CallMachine hook (primarily handles status of the call)
const { daily, leave, join, state } = useCallMachine({ const { daily, leave, state, setRedirectOnLeave } = useCallMachine({
domain, domain,
room, room,
token, token,
@ -71,10 +71,10 @@ export const CallProvider = ({
addFakeParticipant, addFakeParticipant,
preJoinNonAuthorized, preJoinNonAuthorized,
leave, leave,
join,
videoQuality, videoQuality,
setVideoQuality, setVideoQuality,
setBandwidth, setBandwidth,
setRedirectOnLeave,
subscribeToTracksAutomatically, subscribeToTracksAutomatically,
}} }}
> >

View File

@ -38,7 +38,7 @@ export const useCallMachine = ({
}) => { }) => {
const [daily, setDaily] = useState(null); const [daily, setDaily] = useState(null);
const [state, setState] = useState(CALL_STATE_READY); const [state, setState] = useState(CALL_STATE_READY);
const [redirectOnLeave, setRedirectOnLeave] = useState(true); const [redirectOnLeave, setRedirectOnLeave] = useState(false);
const url = useMemo( const url = useMemo(
() => (domain && room ? `https://${domain}.daily.co/${room}` : null), () => (domain && room ? `https://${domain}.daily.co/${room}` : null),
@ -245,8 +245,9 @@ export const useCallMachine = ({
break; break;
case 'left-meeting': case 'left-meeting':
daily.destroy(); daily.destroy();
if (!redirectOnLeave) return; setState(
setState(CALL_STATE_REDIRECTING); !redirectOnLeave ? CALL_STATE_ENDED : CALL_STATE_REDIRECTING
);
break; break;
case 'error': case 'error':
switch (ev?.error?.type) { switch (ev?.error?.type) {

View File

@ -48,15 +48,19 @@ export const useCallUI = ({
); );
case CALL_STATE_LOBBY: case CALL_STATE_LOBBY:
return haircheck ? haircheck() : <HairCheck />; return haircheck ? haircheck() : <HairCheck />;
case CALL_STATE_REDIRECTING:
window.location = redirectUrl;
break;
case CALL_STATE_JOINED: case CALL_STATE_JOINED:
return room ? ( return room ? (
room() room()
) : ( ) : (
<MessageCard error header="No room component declared" /> <MessageCard error header="No room component declared" />
); );
case CALL_STATE_REDIRECTING:
if (!redirectUrl) {
break;
}
window.location = redirectUrl;
break;
case CALL_STATE_ENDED: case CALL_STATE_ENDED:
return callEnded ? ( return callEnded ? (
callEnded() callEnded()