Skip to content

Commit

Permalink
[mirotalksfu] - #169 fix private messaging when new peer joins the room
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Oct 17, 2024
1 parent f230b4e commit d177bbb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dev dependencies: {
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.5.87
* @version 1.5.88
*
*/

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirotalksfu",
"version": "1.5.87",
"version": "1.5.88",
"description": "WebRTC SFU browser-based video calls",
"main": "Server.js",
"scripts": {
Expand Down
18 changes: 12 additions & 6 deletions public/js/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.5.87
* @version 1.5.88
*
*/

Expand Down Expand Up @@ -3932,12 +3932,14 @@ function getParticipantsList(peers) {

// CHAT-GPT
if (chatGPT) {
const chatgpt_active = rc.chatPeerName === 'ChatGPT' ? ' active' : '';

li = `
<li
id="ChatGPT"
data-to-id="ChatGPT"
data-to-name="ChatGPT"
class="clearfix"
class="clearfix${chatgpt_active}"
onclick="rc.showPeerAboutAndMessages(this.id, 'ChatGPT', event)"
>
<img
Expand All @@ -3951,12 +3953,14 @@ function getParticipantsList(peers) {
</li>`;
}

const public_chat_active = rc.chatPeerName === 'all' ? ' active' : '';

// ALL
li += `
<li id="all"
data-to-id="all"
data-to-name="all"
class="clearfix active"
class="clearfix${public_chat_active}"
onclick="rc.showPeerAboutAndMessages(this.id, 'all', event)"
>
<img
Expand Down Expand Up @@ -4032,6 +4036,8 @@ function getParticipantsList(peers) {
const peer_id = peer_info.peer_id;
const avatarImg = getParticipantAvatar(peer_name);

const peer_chat_active = rc.chatPeerId === peer_id ? ' active' : '';

// NOT ME
if (socket.id !== peer_id) {
// PRESENTER HAS MORE OPTIONS
Expand All @@ -4041,7 +4047,7 @@ function getParticipantsList(peers) {
id='${peer_id}'
data-to-id="${peer_id}"
data-to-name="${peer_name}"
class="clearfix"
class="clearfix${peer_chat_active}"
onclick="rc.showPeerAboutAndMessages(this.id, '${peer_name}', event)"
>
<img
Expand Down Expand Up @@ -4117,7 +4123,7 @@ function getParticipantsList(peers) {
id='${peer_id}'
data-to-id="${peer_id}"
data-to-name="${peer_name}"
class="clearfix"
class="clearfix${peer_chat_active}"
onclick="rc.showPeerAboutAndMessages(this.id, '${peer_name}', event)"
>
<img
Expand Down Expand Up @@ -4494,7 +4500,7 @@ function showAbout() {
imageUrl: image.about,
customClass: { image: 'img-about' },
position: 'center',
title: 'WebRTC SFU v1.5.87',
title: 'WebRTC SFU v1.5.88',
html: `
<br />
<div id="about">
Expand Down
9 changes: 7 additions & 2 deletions public/js/RoomClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.5.87
* @version 1.5.88
*
*/

Expand Down Expand Up @@ -235,6 +235,8 @@ class RoomClient {
this.chatMessageNotifyDelay = 10000; // ms
this.chatMessageSpamCount = 0;
this.chatMessageSpamCountToBan = 10;
this.chatPeerId = 'all';
this.chatPeerName = 'all';

// HeyGen Video AI
this.videoAIContainer = null;
Expand Down Expand Up @@ -3704,7 +3706,7 @@ class RoomClient {
}
this.chatCenter();
this.sound('open');
this.showPeerAboutAndMessages('all', 'all');
this.showPeerAboutAndMessages(this.chatPeerId, this.chatPeerName);
}
isParticipantsListOpen = !isParticipantsListOpen;
this.isChatOpen = !this.isChatOpen;
Expand Down Expand Up @@ -7442,6 +7444,9 @@ class RoomClient {
showPeerAboutAndMessages(peer_id, peer_name, event = null) {
this.hidePeerMessages();

this.chatPeerId = peer_id;
this.chatPeerName = peer_name;

const chatAbout = this.getId('chatAbout');
const participant = this.getId(peer_id);
const participantsList = this.getId('participantsList');
Expand Down

0 comments on commit d177bbb

Please sign in to comment.