Skip to content
Snippets Groups Projects
Unverified Commit e5740b18 authored by Anton Georgiev's avatar Anton Georgiev Committed by GitHub
Browse files

Merge pull request #10334 from pedrobmarin/v2.2.x-mute-button-status

Include voice user's upsert to changes observer
parents 1bb70a62 0971edfc
No related branches found
No related tags found
No related merge requests found
......@@ -281,6 +281,22 @@ class AudioManager {
return this.bridge.transferCall(this.onAudioJoin.bind(this));
}
onVoiceUserChanges(fields) {
if (fields.muted !== undefined && fields.muted !== this.isMuted) {
this.isMuted = fields.muted;
const muteState = this.isMuted ? 'selfMuted' : 'selfUnmuted';
window.parent.postMessage({ response: muteState }, '*');
}
if (fields.talking !== undefined && fields.talking !== this.isTalking) {
this.isTalking = fields.talking;
}
if (this.isMuted) {
this.isTalking = false;
}
}
onAudioJoin() {
this.isConnecting = false;
this.isConnected = true;
......@@ -289,21 +305,8 @@ class AudioManager {
if (!this.muteHandle) {
const query = VoiceUsers.find({ intId: Auth.userID }, { fields: { muted: 1, talking: 1 } });
this.muteHandle = query.observeChanges({
changed: (id, fields) => {
if (fields.muted !== undefined && fields.muted !== this.isMuted) {
this.isMuted = fields.muted;
const muteState = this.isMuted ? 'selfMuted' : 'selfUnmuted';
window.parent.postMessage({ response: muteState }, '*');
}
if (fields.talking !== undefined && fields.talking !== this.isTalking) {
this.isTalking = fields.talking;
}
if (this.isMuted) {
this.isTalking = false;
}
},
added: (id, fields) => this.onVoiceUserChanges(fields),
changed: (id, fields) => this.onVoiceUserChanges(fields),
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment