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);
// Daily CallMachine hook (primarily handles status of the call)
const { daily, leave, join, state } = useCallMachine({
const { daily, leave, state, setRedirectOnLeave } = useCallMachine({
domain,
room,
token,
@ -71,10 +71,10 @@ export const CallProvider = ({
addFakeParticipant,
preJoinNonAuthorized,
leave,
join,
videoQuality,
setVideoQuality,
setBandwidth,
setRedirectOnLeave,
subscribeToTracksAutomatically,
}}
>

View File

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

View File

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