Skip to content

Commit 49cecdf

Browse files
committed
fix poblem with 'login as' and current user
1 parent 801d95b commit 49cecdf

File tree

2 files changed

+40
-15
lines changed

2 files changed

+40
-15
lines changed

samples/webrtc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ <h4>Call from <strong class="j-ic_initiator"></strong></h4>
244244

245245
<script type="text/template" id="p2p_call_stop">
246246
<%=name%> has <%=reason%>. Call is stopped.&emsp;
247-
Login&nbsp;in&nbsp;as&nbsp;<%=name%>
247+
Login&nbsp;in&nbsp;as&nbsp;<%=currentName%>
248248
<button class='fw-link j-logout'>Logout</button>
249249
</script>
250250

samples/webrtc/js/app.js

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113

114114
ui.createUsers(QBUsers, ui.$usersList);
115115
ui.$usersTitle.text(MESSAGES.title_login);
116-
116+
117117
if(!params.withoutUpdMsg || params.msg) {
118118
qbApp.MsgBoard.update(params.msg);
119119
}
@@ -365,7 +365,7 @@
365365
if( app.currentSession.peerConnections[userID].stream && !_.isEmpty( $that.attr('src')) ) {
366366
if( $that.hasClass('active') ) {
367367
$that.removeClass('active');
368-
368+
369369
app.currentSession.detachMediaStream('main_video');
370370
ui.changeFilter('#main_video', 'no');
371371
app.mainVideo = 0;
@@ -479,11 +479,19 @@
479479
console.log('Session: ' + session);
480480
console.groupEnd();
481481

482-
var userInfo = _.findWhere(QBUsers, {id: +userId});
482+
var userInfo = _.findWhere(QBUsers, {id: +userId}),
483+
currentUserInfo = _.findWhere(QBUsers, {id: app.currentSession.currentUserID});
483484

484485
/** It's for p2p call */
485486
if(session.opponentsIDs.length === 1) {
486-
qbApp.MsgBoard.update('p2p_call_stop', {name: userInfo.full_name, reason: 'not answered'});
487+
qbApp.MsgBoard.update(
488+
'p2p_call_stop',
489+
{
490+
name: userInfo.full_name,
491+
currentName: currentUserInfo.full_name,
492+
reason: 'not answered'
493+
}
494+
);
487495
}
488496

489497
/** It's for groups call */
@@ -540,7 +548,7 @@
540548

541549
/** update list of callee who take call */
542550
takedCallCallee.push(userInfo);
543-
551+
544552
if(app.currentSession.currentUserID === app.currentSession.initiatorID) {
545553
qbApp.MsgBoard.update('accept_call', {users: takedCallCallee});
546554
}
@@ -553,11 +561,19 @@
553561
console.log('Extension: ' + JSON.stringify(extension));
554562
console.groupEnd();
555563

556-
var userInfo = _.findWhere(QBUsers, {id: userId});
564+
var userInfo = _.findWhere(QBUsers, {id: userId}),
565+
currentUserInfo = _.findWhere(QBUsers, {id: app.currentSession.currentUserID});
557566

558567
/** It's for p2p call */
559568
if(session.opponentsIDs.length === 1) {
560-
qbApp.MsgBoard.update('p2p_call_stop', {name: userInfo.full_name, reason: 'rejected the call'});
569+
qbApp.MsgBoard.update(
570+
'p2p_call_stop',
571+
{
572+
name: userInfo.full_name,
573+
currentName: currentUserInfo.full_name,
574+
reason: 'rejected the call'
575+
}
576+
);
561577
}
562578

563579
/** It's for groups call */
@@ -571,11 +587,20 @@
571587
console.log('Extension: ' + JSON.stringify(extension));
572588
console.groupEnd();
573589

574-
var userInfo = _.findWhere(QBUsers, {id: userId});
590+
/** It's for p2p call */
591+
var userInfo = _.findWhere(QBUsers, {id: userId}),
592+
currentUserInfo = _.findWhere(QBUsers, {id: app.currentSession.currentUserID});
575593

576594
/** It's for p2p call */
577595
if(session.opponentsIDs.length === 1) {
578-
qbApp.MsgBoard.update('p2p_call_stop', {name: userInfo.full_name, reason: 'hung up the call'});
596+
qbApp.MsgBoard.update(
597+
'p2p_call_stop',
598+
{
599+
name: userInfo.full_name,
600+
currentName: currentUserInfo.full_name,
601+
reason: 'hung up the call'
602+
}
603+
);
579604
}
580605

581606
/** It's for groups call */
@@ -590,10 +615,10 @@
590615
app.currentSession.peerConnections[userID].stream = stream;
591616

592617
app.currentSession.attachMediaStream('remote_video_' + userID, stream);
593-
618+
594619
if( remoteStreamCounter === 0) {
595620
$('#remote_video_' + userID).click();
596-
621+
597622
app.mainVideo = userID;
598623
++remoteStreamCounter;
599624
}
@@ -636,7 +661,7 @@
636661
if(connectionState === QB.webrtc.SessionConnectionState.CLOSED){
637662
ui.toggleRemoteVideoView(userID, 'clear');
638663
document.getElementById(ui.sounds.rington).pause();
639-
664+
640665
if(app.mainVideo === userID) {
641666
$('#remote_video_' + userID).removeClass('active');
642667

@@ -673,7 +698,7 @@
673698
if( _.isEmpty(app.currentSession) || isCallEnded ) {
674699
if(callTimer) {
675700
$('#timer').addClass('hidden');
676-
701+
677702
clearInterval(callTimer);
678703
callTimer = null;
679704
ui.callTime = 0;
@@ -683,4 +708,4 @@
683708
};
684709
}
685710
});
686-
}(window, jQuery));
711+
}(window, jQuery));

0 commit comments

Comments
 (0)