Keep track of mute/deaf state client-side and across reconnects
This commit is contained in:
parent
80f766379d
commit
a9d5b5ba75
|
@ -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(){}"
|
||||
|
|
22
app/index.js
22
app/index.js
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue