@@ -308,15 +308,40 @@ let MTComp = (function () {
308
308
[ dispatch , isTopBom ]
309
309
) ;
310
310
const [ userIds , setUserIds ] = useState < any > ( [ ] ) ;
311
+ const [ updateVolume , setUpdateVolume ] = useState < any > ( {
312
+ update : false ,
313
+ userid : null ,
314
+ } ) ;
311
315
const [ rtmMessages , setRtmMessages ] = useState < any > ( [ ] ) ;
312
316
313
317
useEffect ( ( ) => {
314
- console . log ( userIds ) ;
315
318
dispatch (
316
319
changeChildAction ( "participants" , getData ( userIds ) . data , false )
317
320
) ;
318
321
} , [ userIds ] ) ;
319
322
323
+ useEffect ( ( ) => {
324
+ if ( updateVolume . userid ) {
325
+ console . log ( "userIds " , props . participants ) ;
326
+ let prevUsers : [ ] = props . participants as [ ] ;
327
+
328
+ const updatedItems = prevUsers . map ( ( userInfo : any ) => {
329
+ if (
330
+ userInfo . user === updateVolume . userid &&
331
+ userInfo . speaking != updateVolume . update
332
+ ) {
333
+ return { ...userInfo , speaking : updateVolume . update } ;
334
+ }
335
+ return userInfo ;
336
+ } ) ;
337
+ console . log ( "updatedItems" , updatedItems ) ;
338
+
339
+ dispatch (
340
+ changeChildAction ( "participants" , getData ( updatedItems ) . data , false )
341
+ ) ;
342
+ }
343
+ } , [ updateVolume ] ) ;
344
+
320
345
useEffect ( ( ) => {
321
346
if ( props . endCall . value ) {
322
347
let newUsers = userIds . filter ( ( item : any ) => item . user !== userId ) ;
@@ -397,16 +422,16 @@ let MTComp = (function () {
397
422
if ( volumeInfos . length == 0 ) return ;
398
423
volumeInfos . map ( ( volumeInfo : any ) => {
399
424
const speaking = volumeInfo . level >= 30 ;
400
- if ( volumeInfo . uid == userId ) {
425
+ if (
426
+ volumeInfo . uid == userId &&
427
+ props . localUser . value . speaking != speaking
428
+ ) {
401
429
props . localUser . onChange ( {
402
430
...props . localUser . value ,
403
431
speaking,
404
432
} ) ;
405
433
} else {
406
- const userInfo = userIds . find (
407
- ( info : any ) => info . user === volumeInfo . uid
408
- ) ;
409
- setUserIds ( [ ...userIds , { ...userInfo , speaking } ] ) ;
434
+ setUpdateVolume ( { update : speaking , userid : volumeInfo . uid } ) ;
410
435
}
411
436
} ) ;
412
437
} ) ;
@@ -582,6 +607,12 @@ MTComp = withMethodExposing(MTComp, [
582
607
} else {
583
608
await turnOnCamera ( value ) ;
584
609
}
610
+ comp . children . localUser . change ( {
611
+ user : userId + "" ,
612
+ streamingVideo : value ,
613
+ audiostatus : false ,
614
+ speaking : false ,
615
+ } ) ;
585
616
comp . children . videoControl . change ( value ) ;
586
617
} ,
587
618
} ,
0 commit comments