Keep track of mute/deaf state client-side and across reconnects

This commit is contained in:
Jonas Herzig 2017-09-20 16:51:30 +02:00
parent 80f766379d
commit a9d5b5ba75
2 changed files with 26 additions and 4 deletions

View file

@ -111,16 +111,16 @@
<img class="tb-information" data-bind="click: connectionInfo.show" <img class="tb-information" data-bind="click: connectionInfo.show"
rel="information" src="/svg/information_icon.svg"> rel="information" src="/svg/information_icon.svg">
<div class="divider"></div> <div class="divider"></div>
<img class="tb-mute" data-bind="visible: !thisUser() || !thisUser().selfMute(), <img class="tb-mute" data-bind="visible: !selfMute(),
click: function () { requestMute(thisUser) }" click: function () { requestMute(thisUser) }"
rel="mute" src="/svg/audio-input-microphone.svg"> rel="mute" src="/svg/audio-input-microphone.svg">
<img class="tb-unmute tb-active" data-bind="visible: thisUser() && thisUser().selfMute(), <img class="tb-unmute tb-active" data-bind="visible: selfMute,
click: function () { requestUnmute(thisUser) }" click: function () { requestUnmute(thisUser) }"
rel="unmute" src="/svg/audio-input-microphone-muted.svg"> rel="unmute" src="/svg/audio-input-microphone-muted.svg">
<img class="tb-deaf" data-bind="visible: !thisUser() || !thisUser().selfDeaf(), <img class="tb-deaf" data-bind="visible: !selfDeaf(),
click: function () { requestDeaf(thisUser) }" click: function () { requestDeaf(thisUser) }"
rel="deaf" src="/svg/audio-output.svg"> rel="deaf" src="/svg/audio-output.svg">
<img class="tb-undeaf tb-active" data-bind="visible: thisUser() && thisUser().selfDeaf(), <img class="tb-undeaf tb-active" data-bind="visible: selfDeaf,
click: function () { requestUndeaf(thisUser) }" click: function () { requestUndeaf(thisUser) }"
rel="undeaf" src="/svg/audio-output-deafened.svg"> rel="undeaf" src="/svg/audio-output-deafened.svg">
<img class="tb-record" data-bind="click: function(){}" <img class="tb-record" data-bind="click: function(){}"

View file

@ -138,6 +138,8 @@ class GlobalBindings {
this.root = ko.observable() this.root = ko.observable()
this.messageBox = ko.observable('') this.messageBox = ko.observable('')
this.selected = ko.observable() this.selected = ko.observable()
this.selfMute = ko.observable()
this.selfDeaf = ko.observable()
this.select = element => { this.select = element => {
this.selected(element) this.selected(element)
@ -230,6 +232,12 @@ class GlobalBindings {
// Startup audio input processing // Startup audio input processing
this._updateVoiceHandler() this._updateVoiceHandler()
// Tell server our mute/deaf state (if necessary)
if (this.selfDeaf()) {
this.client.setSelfDeaf(true)
} else if (this.selfMute()) {
this.client.setSelfMute(true)
}
}, err => { }, err => {
if (err.type == 4) { if (err.type == 4) {
log('Connection error: invalid server password') log('Connection error: invalid server password')
@ -463,6 +471,9 @@ class GlobalBindings {
} }
this.requestMute = user => { this.requestMute = user => {
if (user === this.thisUser) {
this.selfMute(true)
}
if (this.connected()) { if (this.connected()) {
if (user === this.thisUser) { if (user === this.thisUser) {
this.client.setSelfMute(true) this.client.setSelfMute(true)
@ -473,6 +484,10 @@ class GlobalBindings {
} }
this.requestDeaf = user => { this.requestDeaf = user => {
if (user === this.thisUser) {
this.selfMute(true)
this.selfDeaf(true)
}
if (this.connected()) { if (this.connected()) {
if (user === this.thisUser) { if (user === this.thisUser) {
this.client.setSelfDeaf(true) this.client.setSelfDeaf(true)
@ -483,6 +498,10 @@ class GlobalBindings {
} }
this.requestUnmute = user => { this.requestUnmute = user => {
if (user === this.thisUser) {
this.selfMute(false)
this.selfDeaf(false)
}
if (this.connected()) { if (this.connected()) {
if (user === this.thisUser) { if (user === this.thisUser) {
this.client.setSelfMute(false) this.client.setSelfMute(false)
@ -493,6 +512,9 @@ class GlobalBindings {
} }
this.requestUndeaf = user => { this.requestUndeaf = user => {
if (user === this.thisUser) {
this.selfDeaf(false)
}
if (this.connected()) { if (this.connected()) {
if (user === this.thisUser) { if (user === this.thisUser) {
this.client.setSelfDeaf(false) this.client.setSelfDeaf(false)