Browse Source

Fixed loosing buddies in the buddy list when they there pushed before.

pull/3/head
Simon Eisenmann 12 years ago
parent
commit
63d0de1344
  1. 6
      static/js/services/buddydata.js
  2. 17
      static/js/services/buddylist.js

6
static/js/services/buddydata.js

@ -61,7 +61,7 @@ define(['underscore'], function(underscore) { @@ -61,7 +61,7 @@ define(['underscore'], function(underscore) {
get: function(id, createInParent, afterCreateCallback) {
if (scopes.hasOwnProperty(id)) {
return scopes[id];
} else if (pushed.hasOwnProperty(id)) {
} else if (!createInParent && pushed.hasOwnProperty(id)) {
return pushed[id].scope;
} else {
if (createInParent) {
@ -69,6 +69,10 @@ define(['underscore'], function(underscore) { @@ -69,6 +69,10 @@ define(['underscore'], function(underscore) {
var scope = scopes[id] = createInParent.$new();
scope.buddyIndex = ++count;
scope.buddyIndexSortable = ("0000000" + scope.buddyIndex).slice(-7);
if (pushed.hasOwnProperty(id)) {
// Refresh pushed scope reference.
pushed[id].scope = scope;
}
if (afterCreateCallback) {
afterCreateCallback(scope);
}

17
static/js/services/buddylist.js

@ -190,6 +190,10 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -190,6 +190,10 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
}
return scope.doCall(id);
};
scope.$on("$destroy", function() {
scope.element = null;
scope.killed = true;
});
};
@ -220,10 +224,9 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -220,10 +224,9 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
// Cleanup lefts.
var lefts = this.lefts;
if (!_.isEmpty(lefts)) {
_.each(lefts, function(v, k) {
if (v.element) {
v.element.remove();
v.element = null;
_.each(lefts, function(element, k) {
if (element) {
element.remove();
}
});
this.lefts = {};
@ -367,7 +370,7 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -367,7 +370,7 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
//console.log("Left", user);
var id = user.Id;
this.tree.remove(id);
var scope = buddyData.del(id);
var scope = buddyData.get(id);
if (!scope) {
//console.warn("Trying to remove buddy with no registered scope", user);
return;
@ -375,11 +378,11 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -375,11 +378,11 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
if (buddyCount>0) {
buddyCount--;
}
scope.killed = true;
if (scope.element) {
this.lefts[id] = scope;
this.lefts[id] = scope.element;
this.playSoundLeft = true;
}
buddyData.del(id);
delete this.actionElements[id];
};

Loading…
Cancel
Save