From b9e0a734459620b753316fa9ce343146ff2b1510 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Sat, 6 Nov 2021 12:02:26 +0100 Subject: [PATCH] [mirotalksfu] - improve peerAction --- public/images/participant.png | Bin 0 -> 1909 bytes public/js/RoomClient.js | 181 ++++++++++++++++++---------------- 2 files changed, 95 insertions(+), 86 deletions(-) create mode 100644 public/images/participant.png diff --git a/public/images/participant.png b/public/images/participant.png new file mode 100644 index 0000000000000000000000000000000000000000..9bb0598de7a24cd472197c2480c0bedfec2ca20b GIT binary patch literal 1909 zcmbVNX*iS%8-CxJ*OKKb25Hm~>a)(2W++Q$tTV#MmTel2eXo>k)gV!pBZ-h>Y@vj* zrEth84%dijkYSi?8T*z{a`w50zexB#Pf8N*i+_kba6%|4X0RSLMA{trm zGHnln{JXvFtXtPEfg#qW20%skVczayYzwI{bh0o{^XWT?YXEQIZkCHVmB4bxyFelWzBBuB3VNFq8tY#R(A|cbVnV zIHC6u9cYMfU`s#B`yrjLR z%tKNl=bM^u{FMFSy%^FxSKIvcdvo>rh<{}h*)*O3nYaAEC8rzRy`=ug1J2LSpTebn zIK(=nMmDNWox4yYb0g)fN#51aP?W20qB)IDHdgKZ=!3~FpZ_d7P;e28(}=BG%cV2$ z^#y0IzN$-v1ra_DiF?(UAW9{DWK`Ip)~>-=RNy$KH7f@t!a-Kp7kMoXL9QxXkv!(dBj?dk&j9DSttvBpoU^V{*1 z=iSMM$kqYg;A-hpZsHJZO{CepH!(p<6QngEDUZQ5RMaaBT;J)+(FrsyczCcTR9O3E zvHih6d-Wv-85P{Zu|!Mf-&iQFSk;7hlriy5p+Jo|U$*Zhu0H2CjVd$!B;x* z6MQ)9B#ZknqH-hG$pY6XSd1_O$jsV3f?Rhh-A47?b5bXD+V4a9Uc5o268U+U zrR-#6H>Pa^sSKtt&WsgC36J|1K?&G>?mjPhrHvhno<-1xs(zHH-d5q~|76`bpbXyp zJBeeoaC;eN4O=4{=~jQ((pW9Y*ST*Ae^~xH+TEnBe`2}y=J2C;zFa(N!Fg{M+3gIwvS@5X*@b^LzD7mhHUtPJJBH*cq3z_|h=ki+y;-}Ihj)p- zsd^G_JJ9LW^6Z>~AW@6y?qWR@s^VaKFsRl~AUZ18P0B~=OJ_Hh z-90{_kVX64>$8lyrOohNnv`K{PM4wV-j^X-P zm+G`*k@8scJ;8*xNi7)sH-+s#s0&ZRq2CLth2T9EeBk*9dIR|qHjPS}Wxhg#&r0hl z;{#XTM2Ct+$n?F_WTu{T=1;rSR-OXViUzg!7kcg+a`Eh~wAljT4(u8 z)WtnVgl)5C{e)Nwt~1D}W#*wSd-hY=SGrEYwt)}70kj_FVJC^H<)?gnfjX1J_~5Dr z`ihgvlb0x3%k_ex<*g&Epwr0vrGcdX&-8)Um!zldTKP!C+NY{j*c&k+kHfdwK$FY{RB^H zVEGu+fuwORRD?F3{c!atb4}HG7Q)uMinYT@6|#yvP_Vg^5_|YZKU}|N5^KMf6sv3) zEYV<|2AmE%<>XXU7fQoLX=OB!UQAjyLg zB%VXf+MqZ-*|rEFXI&${F#{0+ob`Q68nM@m`wSrmvWUjopuDkabmi+ojku=Ff*wuG pNAn?Fa5(DMvHew?|GoPVx%##kfo_?Ax8%K-M>4iFsxWYk`3GbPL;?T+ literal 0 HcmV?d00001 diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index 9999346..c6c9048 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -19,6 +19,7 @@ const image = { mute: '../images/mute.png', hide: '../images/hide.png', users: '../images/participants.png', + user: '../images/participant.png', youtube: '../images/youtube.png', }; @@ -2198,92 +2199,8 @@ class RoomClient { broadcast: broadcast, }; - if (!broadcast) { - if (participantsCount === 1) return; - switch (action) { - case 'eject': - let peer = this.getId(peer_id); - if (peer) { - peer.parentNode.removeChild(peer); - participantsCount--; - refreshParticipantsCount(participantsCount); - } - break; - case 'mute': - let peerAudioButton = this.getId(peer_id + '___pAudio'); - if (peerAudioButton) peerAudioButton.innerHTML = _PEER.audioOff; - break; - case 'hide': - let peerVideoButton = this.getId(peer_id + '___pVideo'); - if (peerVideoButton) peerVideoButton.innerHTML = _PEER.videoOff; - } - this.socket.emit('peerAction', data); - } else { - if (participantsCount === 1) return; - - switch (action) { - case 'eject': - Swal.fire({ - background: swalBackground, - position: 'center', - imageUrl: image.users, - title: 'Eject All participants except yourself?', - showDenyButton: true, - confirmButtonText: `Yes`, - denyButtonText: `No`, - showClass: { - popup: 'animate__animated animate__fadeInDown', - }, - hideClass: { - popup: 'animate__animated animate__fadeOutUp', - }, - }).then((result) => { - if (result.isConfirmed) { - let actionButton = this.getId(action + 'AllButton'); - if (actionButton) actionButton.style.display = 'none'; - participantsCount = 1; - refreshParticipantsCount(participantsCount); - this.socket.emit('peerAction', data); - setTimeout(() => { - getRoomParticipants(true); - }, 6000); - } - }); - break; - case 'mute': - case 'hide': - Swal.fire({ - background: swalBackground, - position: 'center', - imageUrl: action == 'mute' ? image.mute : image.hide, - title: - action == 'mute' ? 'Mute everyone except yourself?' : 'Hide everyone except yourself?', - text: - action == 'mute' - ? "Once muted, you won't be able to unmute them, but they can unmute themselves at any time." - : "Once hided, you won't be able to unhide them, but they can unhide themselves at any time.", - showDenyButton: true, - confirmButtonText: `Yes`, - denyButtonText: `No`, - showClass: { - popup: 'animate__animated animate__fadeInDown', - }, - hideClass: { - popup: 'animate__animated animate__fadeOutUp', - }, - }).then((result) => { - if (result.isConfirmed) { - let actionButton = this.getId(action + 'AllButton'); - if (actionButton) actionButton.style.display = 'none'; - this.socket.emit('peerAction', data); - setTimeout(() => { - getRoomParticipants(true); - }, 2000); - } - }); - break; - } - } + if (participantsCount === 1) return; + this.confirmPeerAction(action, data); } else { switch (action) { case 'eject': @@ -2340,6 +2257,98 @@ class RoomClient { } } + confirmPeerAction(action, data) { + switch (action) { + case 'eject': + let whoEject = data.broadcast ? 'All participants' : 'current participant'; + Swal.fire({ + background: swalBackground, + position: 'center', + imageUrl: data.broadcast ? image.users : image.user, + title: 'Eject ' + whoEject + ' excpect yourself?', + showDenyButton: true, + confirmButtonText: `Yes`, + denyButtonText: `No`, + showClass: { + popup: 'animate__animated animate__fadeInDown', + }, + hideClass: { + popup: 'animate__animated animate__fadeOutUp', + }, + }).then((result) => { + if (result.isConfirmed) { + if (!data.broadcast) { + let peer = this.getId(data.peer_id); + if (peer) { + peer.parentNode.removeChild(peer); + participantsCount--; + refreshParticipantsCount(participantsCount); + this.socket.emit('peerAction', data); + } + } else { + let actionButton = this.getId(action + 'AllButton'); + if (actionButton) actionButton.style.display = 'none'; + participantsCount = 1; + refreshParticipantsCount(participantsCount); + this.socket.emit('peerAction', data); + setTimeout(() => { + getRoomParticipants(true); + }, 6000); + } + } + }); + break; + case 'mute': + case 'hide': + let whoMuteHide = data.broadcast ? 'everyone' : 'current participant'; + Swal.fire({ + background: swalBackground, + position: 'center', + imageUrl: action == 'mute' ? image.mute : image.hide, + title: + action == 'mute' + ? 'Mute ' + whoMuteHide + ' excpect yourself?' + : 'Hide ' + whoMuteHide + ' except yourself?', + text: + action == 'mute' + ? "Once muted, you won't be able to unmute them, but they can unmute themselves at any time." + : "Once hided, you won't be able to unhide them, but they can unhide themselves at any time.", + showDenyButton: true, + confirmButtonText: `Yes`, + denyButtonText: `No`, + showClass: { + popup: 'animate__animated animate__fadeInDown', + }, + hideClass: { + popup: 'animate__animated animate__fadeOutUp', + }, + }).then((result) => { + if (result.isConfirmed) { + if (!data.broadcast) { + switch (action) { + case 'mute': + let peerAudioButton = this.getId(data.peer_id + '___pAudio'); + if (peerAudioButton) peerAudioButton.innerHTML = _PEER.audioOff; + break; + case 'hide': + let peerVideoButton = this.getId(data.peer_id + '___pVideo'); + if (peerVideoButton) peerVideoButton.innerHTML = _PEER.videoOff; + } + this.socket.emit('peerAction', data); + } else { + let actionButton = this.getId(action + 'AllButton'); + if (actionButton) actionButton.style.display = 'none'; + this.socket.emit('peerAction', data); + setTimeout(() => { + getRoomParticipants(true); + }, 2000); + } + } + }); + break; + } + } + // #################################################### // UPDATE PEER INFO // ####################################################