1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Implement remote mute.

This commit is contained in:
Juliusz Chroboczek 2020-11-30 14:22:36 +01:00
parent 6040d1943c
commit f9e0573654

View file

@ -403,8 +403,9 @@ function setButtonsVisibility() {
/** /**
* @param {boolean} mute * @param {boolean} mute
* @param {boolean} [reflect]
*/ */
function setLocalMute(mute) { function setLocalMute(mute, reflect) {
muteLocalTracks(mute); muteLocalTracks(mute);
let button = document.getElementById('mutebutton'); let button = document.getElementById('mutebutton');
let icon = button.querySelector("span .fas"); let icon = button.querySelector("span .fas");
@ -417,6 +418,8 @@ function setLocalMute(mute) {
icon.classList.add('fa-microphone'); icon.classList.add('fa-microphone');
button.classList.remove('muted'); button.classList.remove('muted');
} }
if(reflect)
updateSettings({localMute: mute});
} }
getSelectElement('videoselect').onchange = function(e) { getSelectElement('videoselect').onchange = function(e) {
@ -447,8 +450,7 @@ document.getElementById('mutebutton').onclick = function(e) {
e.preventDefault(); e.preventDefault();
let localMute = getSettings().localMute; let localMute = getSettings().localMute;
localMute = !localMute; localMute = !localMute;
updateSettings({localMute: localMute}) setLocalMute(localMute, true);
setLocalMute(localMute);
} }
document.getElementById('sharebutton').onclick = function(e) { document.getElementById('sharebutton').onclick = function(e) {
@ -896,8 +898,7 @@ async function addFileMedia(file) {
let presenting = !!findUpMedia('local'); let presenting = !!findUpMedia('local');
let muted = getSettings().localMute; let muted = getSettings().localMute;
if(presenting && !muted) { if(presenting && !muted) {
setLocalMute(true); setLocalMute(true, true);
updateSettings({localMute: true});
displayWarning('You have been muted'); displayWarning('You have been muted');
} }
} }
@ -1775,6 +1776,15 @@ function userCommand(c, r) {
serverConnection.userAction(c, id, p[1]); serverConnection.userAction(c, id, p[1]);
} }
function userMessage(c, r) {
let p = parseCommand(r);
if(!p[0])
throw new Error(`/${c} requires parameters`);
let id = findUserId(p[0]);
if(!id)
throw new Error(`Unknown user ${p[0]}`);
serverConnection.userMessage(c, id, p[1]);
}
commands.kick = { commands.kick = {
parameters: 'user [message]', parameters: 'user [message]',
@ -1811,6 +1821,13 @@ commands.unpresent = {
f: userCommand, f: userCommand,
}; };
commands.mute = {
parameters: 'user',
description: 'mute a remote user',
predicate: operatorPredicate,
f: userMessage,
};
function handleInput() { function handleInput() {
let input = /** @type {HTMLTextAreaElement} */ let input = /** @type {HTMLTextAreaElement} */
(document.getElementById('input')); (document.getElementById('input'));
@ -2101,6 +2118,16 @@ async function serverConnect() {
else else
console.error(`Got unpriviledged message of kind ${kind}`); console.error(`Got unpriviledged message of kind ${kind}`);
break; break;
case 'mute':
console.log(id, dest, username);
if(priviledged) {
setLocalMute(true, true);
let by = username ? ' by ' + username : '';
displayWarning(`You have been muted${by}`);
} else {
console.error(`Got unpriviledged message of kind ${kind}`);
}
break;
default: default:
console.warn(`Got unknown user message ${kind}`); console.warn(`Got unknown user message ${kind}`);
break; break;