fix(voice): keep voice activity hooks pure by skipping state update when applicable
This commit is contained in:
parent
c6e8464693
commit
b2adf9ad15
@ -1,4 +1,5 @@
|
||||
import { useEffect } from 'react';
|
||||
import { isEqual } from 'radash';
|
||||
import { makeVar, useReactiveVar } from '@apollo/client';
|
||||
import { VoiceActivityResponse } from '/imports/ui/core/graphql/queries/whoIsTalking';
|
||||
|
||||
@ -34,6 +35,10 @@ const createUseWhoIsTalking = () => {
|
||||
newTalkingUsers[userId] = talking;
|
||||
});
|
||||
|
||||
if (isEqual(getWhoIsTalking(), newTalkingUsers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setWhoIsTalkingState(newTalkingUsers);
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { useEffect } from 'react';
|
||||
import { isEqual } from 'radash';
|
||||
import { makeVar, useReactiveVar } from '@apollo/client';
|
||||
import { VoiceActivityResponse } from '/imports/ui/core/graphql/queries/whoIsTalking';
|
||||
|
||||
@ -34,6 +35,10 @@ const createUseWhoIsUnmuted = () => {
|
||||
newUnmutedUsers[userId] = true;
|
||||
});
|
||||
|
||||
if (isEqual(getWhoIsUnmuted(), newUnmutedUsers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setWhoIsUnmutedState(newUnmutedUsers);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user