From e8df60cbbe87f6c6b2329cc8bed5cc5d1a431a50 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 1 Dec 2020 00:26:14 +0100 Subject: [PATCH] Move automatic presentation into gotPermissions. Don't attempt to present if we don't have the present permission, don't display the friendly popup if we've selected presentation. --- static/sfu.css | 2 +- static/sfu.html | 4 ++-- static/sfu.js | 58 +++++++++++++++++++++++++++++-------------------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/static/sfu.css b/static/sfu.css index e277ed5..0295ce6 100644 --- a/static/sfu.css +++ b/static/sfu.css @@ -519,7 +519,7 @@ textarea.form-reply { position: absolute; top: 15%; left: 25%; - width: 30em; + width: 35em; padding: 2em; } diff --git a/static/sfu.html b/static/sfu.html index 80b1d59..9031fde 100644 --- a/static/sfu.html +++ b/static/sfu.html @@ -120,9 +120,9 @@ - + - +
diff --git a/static/sfu.js b/static/sfu.js index 39d5940..a6ab55c 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -1404,14 +1404,40 @@ function displayUsername() { document.getElementById('permspan').textContent = text; } +let presentRequested = null; + /** * @param {Object} perms */ -function gotPermissions(perms) { +async function gotPermissions(perms) { displayUsername(); setButtonsVisibility(); - if(serverConnection.permissions.present) - displayMessage("Press Present to enable your camera or microphone"); + + try { + if(serverConnection.permissions.present && !findUpMedia('local')) { + if(presentRequested) { + if(presentRequested === 'mike') + updateSettings({video: ''}); + else if(presentRequested === 'both') + delSetting('video'); + reflectSettings(); + + let button = getButtonElement('presentbutton'); + button.disabled = true; + try { + await addLocalMedia(); + } finally { + button.disabled = false; + } + } else { + displayMessage( + "Press Present to enable your camera or microphone" + ); + } + } + } finally { + presentRequested = null; + } } const urlRegexp = /https?:\/\/[-a-zA-Z0-9@:%/._\\+~#&()=?]+[-a-zA-Z0-9@:%/_\\+~#&()=]/g; @@ -2036,26 +2062,12 @@ document.getElementById('userform').onsubmit = async function(e) { connecting = false; } - let presentboth = getInputElement('presentboth').checked; - let presentmike = getInputElement('presentmike').checked; - - if(presentmike) - updateSettings({video: ''}); - else if(presentboth) - delSetting('video'); - reflectSettings(); - - if(presentboth || presentmike) { - let button = getButtonElement('presentbutton'); - button.disabled = true; - try { - let id = findUpMedia('local'); - if(!id) - await addLocalMedia(); - } finally { - button.disabled = false; - } - } + if(getInputElement('presentboth').checked) + presentRequested = 'both'; + else if(getInputElement('presentmike').checked) + presentRequested = 'mike'; + else + presentRequested = null; getInputElement('presentoff').checked = true; };