Cleanup the URL after joining
This commit is contained in:
parent
d4b50c011c
commit
e84f7d3919
|
|
@ -10,7 +10,7 @@ import { useRouter } from 'next/router';
|
||||||
import App from '../components/App';
|
import App from '../components/App';
|
||||||
import NotConfigured from '../components/Prejoin/NotConfigured';
|
import NotConfigured from '../components/Prejoin/NotConfigured';
|
||||||
|
|
||||||
const Slug = ({
|
const Room = ({
|
||||||
domain,
|
domain,
|
||||||
isConfigured = false,
|
isConfigured = false,
|
||||||
subscribeToTracksAutomatically = true,
|
subscribeToTracksAutomatically = true,
|
||||||
|
|
@ -20,7 +20,7 @@ const Slug = ({
|
||||||
customAppComponent,
|
customAppComponent,
|
||||||
}) => {
|
}) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { slug, t } = router.query;
|
const { room, t } = router.query;
|
||||||
|
|
||||||
if (!isConfigured) return <NotConfigured />;
|
if (!isConfigured) return <NotConfigured />;
|
||||||
return (
|
return (
|
||||||
|
|
@ -31,9 +31,10 @@ const Slug = ({
|
||||||
>
|
>
|
||||||
<CallProvider
|
<CallProvider
|
||||||
domain={domain}
|
domain={domain}
|
||||||
room={slug}
|
room={room}
|
||||||
token={t}
|
token={t}
|
||||||
subscribeToTracksAutomatically={subscribeToTracksAutomatically}
|
subscribeToTracksAutomatically={subscribeToTracksAutomatically}
|
||||||
|
cleanURLOnJoin
|
||||||
>
|
>
|
||||||
<ParticipantsProvider>
|
<ParticipantsProvider>
|
||||||
<TracksProvider>
|
<TracksProvider>
|
||||||
|
|
@ -49,7 +50,7 @@ const Slug = ({
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Slug;
|
export default Room;
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
const defaultProps = getDemoProps();
|
const defaultProps = getDemoProps();
|
||||||
|
|
@ -14,6 +14,7 @@ import React, {
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import DailyIframe from '@daily-co/daily-js';
|
import DailyIframe from '@daily-co/daily-js';
|
||||||
import Bowser from 'bowser';
|
import Bowser from 'bowser';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import {
|
||||||
ACCESS_STATE_LOBBY,
|
ACCESS_STATE_LOBBY,
|
||||||
|
|
@ -31,7 +32,9 @@ export const CallProvider = ({
|
||||||
room,
|
room,
|
||||||
token = '',
|
token = '',
|
||||||
subscribeToTracksAutomatically = true,
|
subscribeToTracksAutomatically = true,
|
||||||
|
cleanURLOnJoin = false,
|
||||||
}) => {
|
}) => {
|
||||||
|
const router = useRouter();
|
||||||
const [roomInfo, setRoomInfo] = useState(null);
|
const [roomInfo, setRoomInfo] = useState(null);
|
||||||
const [enableScreenShare, setEnableScreenShare] = useState(false);
|
const [enableScreenShare, setEnableScreenShare] = useState(false);
|
||||||
const [videoQuality, setVideoQuality] = useState(VIDEO_QUALITY_AUTO);
|
const [videoQuality, setVideoQuality] = useState(VIDEO_QUALITY_AUTO);
|
||||||
|
|
@ -119,6 +122,15 @@ export const CallProvider = ({
|
||||||
setPreJoinNonAuthorized(requiresPermission && !token);
|
setPreJoinNonAuthorized(requiresPermission && !token);
|
||||||
}, [state, daily, token]);
|
}, [state, daily, token]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!daily) return;
|
||||||
|
|
||||||
|
if (cleanURLOnJoin)
|
||||||
|
daily.on('joined-meeting', () => router.replace(`/${room}`));
|
||||||
|
|
||||||
|
return () => daily.off('joined-meeting', () => router.replace(`/${room}`));
|
||||||
|
}, [cleanURLOnJoin, daily, room, router]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CallContext.Provider
|
<CallContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue