@@ -65,19 +65,21 @@ export default function Playground({
6565
6666 const [ rpcMethod , setRpcMethod ] = useState ( "" ) ;
6767 const [ rpcPayload , setRpcPayload ] = useState ( "" ) ;
68- const [ showRpc , setShowRpc ] = useState ( false ) ;
6968 const [ hasConnected , setHasConnected ] = useState ( false ) ;
7069
71- const [ tokenFetchOptions , setTokenFetchOptions ] =
72- useState < TokenSourceFetchOptions > ( { } ) ;
70+ const [ tokenFetchOptions , setTokenFetchOptions ] = useState < TokenSourceFetchOptions > ( ) ;
7371
7472 // initialize token fetch options from initial values, which can come from config
7573 useEffect ( ( ) => {
74+ // set initial options only if they haven't been set yet
75+ if ( tokenFetchOptions !== undefined || initialAgentOptions === undefined ) {
76+ return ;
77+ }
7678 setTokenFetchOptions ( {
7779 agentName : initialAgentOptions ?. agentName ?? "" ,
7880 agentMetadata : initialAgentOptions ?. metadata ?? "" ,
7981 } ) ;
80- } , [ ] ) ;
82+ } , [ tokenFetchOptions , initialAgentOptions , initialAgentOptions ?. agentName , initialAgentOptions ?. metadata ] ) ;
8183
8284 const session = useSession ( tokenSource , tokenFetchOptions ) ;
8385 const { connectionState } = session ;
@@ -94,13 +96,13 @@ export default function Playground({
9496 }
9597 session . start ( ) ;
9698 setHasConnected ( true ) ;
97- } , [ session , hasConnected , session . isConnected ] ) ;
99+ } , [ session , session . isConnected ] ) ;
98100
99101 useEffect ( ( ) => {
100102 if ( autoConnect && ! hasConnected ) {
101103 startSession ( ) ;
102104 }
103- } , [ autoConnect , hasConnected ] ) ;
105+ } , [ autoConnect , hasConnected , startSession ] ) ;
104106
105107 useEffect ( ( ) => {
106108 if ( connectionState === ConnectionState . Connected ) {
@@ -202,7 +204,6 @@ export default function Playground({
202204 return visualizerContent ;
203205 } , [
204206 agent . microphoneTrack ,
205- config . settings . theme_color ,
206207 connectionState ,
207208 agent . state ,
208209 ] ) ;
@@ -502,9 +503,9 @@ export default function Playground({
502503 </ div >
503504 ) ;
504505 } , [
505- config . description ,
506- config . settings ,
507- config . show_qr ,
506+ config ,
507+ agent . isConnected ,
508+ agentAttributes . attributes ,
508509 session . room . localParticipant ,
509510 session . room . name ,
510511 connectionState ,
@@ -517,8 +518,6 @@ export default function Playground({
517518 rpcMethod ,
518519 rpcPayload ,
519520 handleRpcCall ,
520- showRpc ,
521- setShowRpc ,
522521 tokenFetchOptions ,
523522 setTokenFetchOptions ,
524523 ] ) ;
0 commit comments