From 4d28335a01a34e9f68c00646b3cfd0f6d307aa29 Mon Sep 17 00:00:00 2001
From: david
Date: Tue, 8 Jun 2021 18:19:04 +0200
Subject: [PATCH] modification to disable join button after click to avoid
duplicate media
---
openvidu-js-node/public/app.js | 15 ++++++++++++++-
openvidu-js-node/public/index.html | 2 +-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/openvidu-js-node/public/app.js b/openvidu-js-node/public/app.js
index a45ace77..097367d7 100644
--- a/openvidu-js-node/public/app.js
+++ b/openvidu-js-node/public/app.js
@@ -8,6 +8,10 @@ var token; // Token retrieved from OpenVidu Server
/* OPENVIDU METHODS */
function joinSession() {
+
+ document.getElementById("join-btn").disabled = true;
+ document.getElementById("join-btn").innerHTML = "Joining...";
+
getToken((token) => {
// --- 1) Get an OpenVidu object ---
@@ -106,6 +110,7 @@ function joinSession() {
})
.catch(error => {
console.warn('There was an error connecting to the session:', error.code, error.message);
+ enableBtn();
});
});
@@ -124,11 +129,17 @@ function leaveSession() {
$('#join').show();
$('#session').hide();
+
+ // eneble button
+ enableBtn();
}
/* OPENVIDU METHODS */
-
+function enableBtn (){
+ document.getElementById("join-btn").disabled = false;
+ document.getElementById("join-btn").innerHTML = "Join!";
+}
/* APPLICATION REST METHODS */
@@ -161,6 +172,8 @@ function logOut() {
$("#logged").hide();
}
);
+
+ enableBtn();
}
function getToken(callback) {
diff --git a/openvidu-js-node/public/index.html b/openvidu-js-node/public/index.html
index 6043a772..1ed0f1fd 100644
--- a/openvidu-js-node/public/index.html
+++ b/openvidu-js-node/public/index.html
@@ -92,7 +92,7 @@
-
+