Commit a9d5b5ba authored by Jonas Herzig's avatar Jonas Herzig
Browse files

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

parent 80f76637
......@@ -111,16 +111,16 @@
<img class="tb-information" data-bind="click: connectionInfo.show"
rel="information" src="/svg/information_icon.svg">
<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) }"
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) }"
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) }"
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) }"
rel="undeaf" src="/svg/audio-output-deafened.svg">
<img class="tb-record" data-bind="click: function(){}"
......
......@@ -138,6 +138,8 @@ class GlobalBindings {
this.root = ko.observable()
this.messageBox = ko.observable('')
this.selected = ko.observable()
this.selfMute = ko.observable()
this.selfDeaf = ko.observable()
this.select = element => {
this.selected(element)
......@@ -230,6 +232,12 @@ class GlobalBindings {
// Startup audio input processing
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 => {
if (err.type == 4) {
log('Connection error: invalid server password')
......@@ -463,6 +471,9 @@ class GlobalBindings {
}
this.requestMute = user => {
if (user === this.thisUser) {
this.selfMute(true)
}
if (this.connected()) {
if (user === this.thisUser) {
this.client.setSelfMute(true)
......@@ -473,6 +484,10 @@ class GlobalBindings {
}
this.requestDeaf = user => {
if (user === this.thisUser) {
this.selfMute(true)
this.selfDeaf(true)
}
if (this.connected()) {
if (user === this.thisUser) {
this.client.setSelfDeaf(true)
......@@ -483,6 +498,10 @@ class GlobalBindings {
}
this.requestUnmute = user => {
if (user === this.thisUser) {
this.selfMute(false)
this.selfDeaf(false)
}
if (this.connected()) {
if (user === this.thisUser) {
this.client.setSelfMute(false)
......@@ -493,6 +512,9 @@ class GlobalBindings {
}
this.requestUndeaf = user => {
if (user === this.thisUser) {
this.selfDeaf(false)
}
if (this.connected()) {
if (user === this.thisUser) {
this.client.setSelfDeaf(false)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment