Browse Source

Fixed session vs. user confusion in buddylist component.

pull/28/head
Simon Eisenmann 11 years ago
parent
commit
8757689516
  1. 37
      static/js/services/buddylist.js
  2. 6
      static/partials/buddy.html
  3. 2
      static/partials/buddyactions.html
  4. 2
      static/partials/buddyactionsforaudiomixer.html

37
static/js/services/buddylist.js

@ -31,7 +31,7 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
BuddyTree.prototype.create = function(id, scope) { BuddyTree.prototype.create = function(id, scope) {
var sort = scope.displayName ? scope.displayName : "user "+scope.buddyIndexSortable+" "+id; var sort = scope.displayName ? scope.displayName : "session "+scope.buddyIndexSortable+" "+id;
var data = { var data = {
id: id, id: id,
sort: sort + "z" + id sort: sort + "z" + id
@ -138,13 +138,17 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
$element.on("mouseenter mouseleave", ".buddy", _.bind(function(event) { $element.on("mouseenter mouseleave", ".buddy", _.bind(function(event) {
// Hover handler for on Buddy actions. // Hover handler for on Buddy actions.
var buddyElement = $(event.currentTarget); var buddyElement = $(event.currentTarget);
this.hover(buddyElement, event.type === "mouseenter" ? true : false, buddyElement.scope().user.Id); this.hover(buddyElement, event.type === "mouseenter" ? true : false, buddyElement.scope().session.Id);
}, this));
$element.on("click", ".buddy", _.bind(function(event) {
var buddyElement = $(event.currentTarget);
buddyElement.scope().doDefault();
}, this)); }, this));
$element.attr("data-xthreshold", "10"); $element.attr("data-xthreshold", "10");
$element.on("swipeleft", ".buddy", _.bind(function(event) { $element.on("swipeleft", ".buddy", _.bind(function(event) {
event.preventDefault(); event.preventDefault();
var buddyElement = $(event.currentTarget); var buddyElement = $(event.currentTarget);
this.hover(buddyElement, !buddyElement.hasClass("hovered"), buddyElement.scope().user.Id); this.hover(buddyElement, !buddyElement.hasClass("hovered"), buddyElement.scope().session.Id);
}, this)); }, this));
$window.setInterval(_.bind(this.soundLoop, this), 500); $window.setInterval(_.bind(this.soundLoop, this), 500);
@ -184,7 +188,8 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
Buddylist.prototype.onBuddyScope = function(scope) { Buddylist.prototype.onBuddyScope = function(scope) {
scope.element = null; scope.element = null;
scope.doDefault = function(id) { scope.doDefault = function() {
var id = scope.session.Id;
if (scope.status.isMixer) { if (scope.status.isMixer) {
return scope.doAudioConference(id); return scope.doAudioConference(id);
} }
@ -355,18 +360,18 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
}; };
Buddylist.prototype.onJoined = function(user) { Buddylist.prototype.onJoined = function(session) {
//console.log("Joined", user); //console.log("Joined", session);
var id = user.Id; var id = session.Id;
var scope = buddyData.get(id, this.$scope, _.bind(this.onBuddyScope, this)); var scope = buddyData.get(id, this.$scope, _.bind(this.onBuddyScope, this));
scope.user = user; scope.session = session;
buddyCount++; buddyCount++;
if (user.Status) { if (session.Status) {
if (scope.status && scope.status.Rev >= user.Status.Rev) { if (scope.status && scope.status.Rev >= session.Status.Rev) {
console.warn("Received old status update in join", user.Status.Rev, scope.status.Rev); console.warn("Received old status update in join", session.Status.Rev, scope.status.Rev);
} else { } else {
scope.status = user.Status; scope.status = session.Status;
scope.displayName = scope.status.displayName; scope.displayName = scope.status.displayName;
this.updateBuddyPicture(scope.status); this.updateBuddyPicture(scope.status);
} }
@ -380,14 +385,14 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
}; };
Buddylist.prototype.onLeft = function(user) { Buddylist.prototype.onLeft = function(session) {
//console.log("Left", user); //console.log("Left", session);
var id = user.Id; var id = session.Id;
this.tree.remove(id); this.tree.remove(id);
var scope = buddyData.get(id); var scope = buddyData.get(id);
if (!scope) { if (!scope) {
//console.warn("Trying to remove buddy with no registered scope", user); //console.warn("Trying to remove buddy with no registered scope", session);
return; return;
} }
if (buddyCount>0) { if (buddyCount>0) {

6
static/partials/buddy.html

@ -1,5 +1,5 @@
<div class="buddy withSubline" ng-click="doDefault(user.Id)"> <div class="buddy withSubline">
<div class="buddyimage"><i class="fa fa-user fa-3x"/><img ng-show="status.buddyPicture" alt ng-src="{{status.buddyPicture}}" width="46" height="46"/></div> <div class="buddyimage"><i class="fa fa-user fa-3x"/><img ng-show="status.buddyPicture" alt ng-src="{{status.buddyPicture}}" width="46" height="46"/></div>
<div class="buddy1">{{user.Id|displayName}}</div> <div class="buddy1">{{session.Id|displayName}}</div>
<div class="buddy2">{{user.Ua}}</div> <div class="buddy2">{{session.Ua}}</div>
</div> </div>

2
static/partials/buddyactions.html

@ -1,4 +1,4 @@
<div class="buddyactions active"> <div class="buddyactions active">
<a class="btn btn-info" title="{{_('Start video call')}}"><i class="fa fa-eye"></i></a> <a class="btn btn-info" title="{{_('Start video call')}}"><i class="fa fa-eye"></i></a>
<a class="btn btn-info" title="{{_('Start chat')}}" ng-click="doChat(user.Id); $event.stopPropagation()"><i class="fa fa-comments-o"></i></a> <a class="btn btn-info" title="{{_('Start chat')}}" ng-click="doChat(session.Id); $event.stopPropagation()"><i class="fa fa-comments-o"></i></a>
</div> </div>

2
static/partials/buddyactionsforaudiomixer.html

@ -1,3 +1,3 @@
<div class="buddyactions active"> <div class="buddyactions active">
<a class="btn btn-info" title="{{_('Start audio conference')}}" ng-click="doAudioConference(user.Id); ; $event.stopPropagation()"><i class="fa fa-users"></i></a> <a class="btn btn-info" title="{{_('Start audio conference')}}" ng-click="doAudioConference(session.Id); ; $event.stopPropagation()"><i class="fa fa-users"></i></a>
</div> </div>

Loading…
Cancel
Save