From 9eac0eb2ade35c35641577251da466b3e3deaddf Mon Sep 17 00:00:00 2001 From: harshithpabbati Date: Fri, 8 Apr 2022 13:19:17 +0530 Subject: [PATCH] address suggestions --- custom/live-transcription/pages/index.js | 6 +++++- custom/shared/contexts/CallProvider.js | 14 +++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/custom/live-transcription/pages/index.js b/custom/live-transcription/pages/index.js index 84a3f53..cf46307 100644 --- a/custom/live-transcription/pages/index.js +++ b/custom/live-transcription/pages/index.js @@ -6,7 +6,11 @@ export async function getStaticProps() { // Pass through domain as prop return { - props: defaultProps, + props: { + ...defaultProps, + forceFetchToken: true, + forceOwner: true, + }, }; } diff --git a/custom/shared/contexts/CallProvider.js b/custom/shared/contexts/CallProvider.js index b207cf9..14048b1 100644 --- a/custom/shared/contexts/CallProvider.js +++ b/custom/shared/contexts/CallProvider.js @@ -13,7 +13,7 @@ import React, { useState, } from 'react'; import DailyIframe from '@daily-co/daily-js'; -import { DailyProvider, useDailyEvent } from '@daily-co/daily-react-hooks'; +import { DailyProvider } from '@daily-co/daily-react-hooks'; import Bowser from 'bowser'; import { useRouter } from 'next/router'; import PropTypes from 'prop-types'; @@ -124,11 +124,15 @@ export const CallProvider = ({ setPreJoinNonAuthorized(requiresPermission && !token); }, [state, daily, token]); - const handleOnJoinCleanUp = useCallback(() => { - if (cleanURLOnJoin) router.replace(`/${room}`); - }, [cleanURLOnJoin, room, router]); + useEffect(() => { + if (!daily) return; - useDailyEvent('joined-meeting', handleOnJoinCleanUp); + if (cleanURLOnJoin) { + daily.on('joined-meeting', () => router.replace(`/${room}`)); + } + + return () => daily.off('joined-meeting', () => router.replace(`/${room}`)); + }, [cleanURLOnJoin, daily, room, router]); return (