Browse Source

Properly implemented cleanup of message with contacts and session merge.

pull/48/head
Simon Eisenmann 11 years ago
parent
commit
91521f37eb
  1. 35
      static/js/services/buddylist.js

35
static/js/services/buddylist.js

@ -252,7 +252,9 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
} }
buddyData.set(id, targetScope); buddyData.set(id, targetScope);
delete this.actionElements[id]; delete this.actionElements[id];
return targetScope;
} }
return;
}; };
@ -466,14 +468,16 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
this.updateSubline(display, status.message); this.updateSubline(display, status.message);
} }
// Update display picture. // Update display picture.
display.buddyPicture = status.buddyPicture || null; if (status.buddyPicture) {
this.updateBuddyPicture(display); display.buddyPicture = status.buddyPicture || null;
this.updateBuddyPicture(display);
}
}; };
Buddylist.prototype.updateSubline = function(display, s) { Buddylist.prototype.updateSubline = function(display, s) {
if (!s || s === "__none__") { if (!s || s === "__e") {
display.subline = ""; display.subline = "";
return; return;
} }
@ -497,7 +501,10 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
// Update session. // Update session.
var sessionData = scope.session.update(id, data, _.bind(function(session) { var sessionData = scope.session.update(id, data, _.bind(function(session) {
//console.log("Session is now authenticated", session); //console.log("Session is now authenticated", session);
this.onBuddySessionUserid(scope, session); var newscope = this.onBuddySessionUserid(scope, session);
if (newscope) {
scope = newscope;
}
}, this)); }, this));
if (sessionData) { if (sessionData) {
// onStatus for main session. // onStatus for main session.
@ -519,7 +526,10 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
buddyCount++; buddyCount++;
var sessionData = scope.session.update(id, data, _.bind(function(session) { var sessionData = scope.session.update(id, data, _.bind(function(session) {
//console.log("Session is now authenticated", session); //console.log("Session is now authenticated", session);
this.onBuddySessionUserid(scope, session); var newscope = this.onBuddySessionUserid(scope, session);
if (newscope) {
scope = newscope;
}
}, this)); }, this));
if (sessionData && sessionData.Status) { if (sessionData && sessionData.Status) {
this.setDisplay(id, scope, sessionData, "joined"); this.setDisplay(id, scope, sessionData, "joined");
@ -566,11 +576,17 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
if (sessionData) { if (sessionData) {
this.updateDisplay(sessionData.Id, scope, sessionData, "status"); this.updateDisplay(sessionData.Id, scope, sessionData, "status");
} else if (scope.contact) { } else if (scope.contact) {
var contact = scope.contact;
// Use it with userid as id in tree. // Use it with userid as id in tree.
if (!this.tree.check(session.Userid)) { if (!this.tree.check(contact.Userid)) {
this.tree.add(session.Userid, scope); this.tree.add(contact.Userid, scope);
buddyCount++; buddyCount++;
} }
if (contact.Status !== null && !contact.Status.message) {
// Remove status message.
contact.Status.message = "__e";
}
this.updateDisplay(contact.Userid, scope, contact, "status");
} }
if (!noApply) { if (!noApply) {
scope.$apply(); scope.$apply();
@ -613,6 +629,9 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
if (contact.Status === null && sessionData.Status) { if (contact.Status === null && sessionData.Status) {
// Update contact status with session.Status // Update contact status with session.Status
var status = contact.Status = _.extend({}, sessionData.Status); var status = contact.Status = _.extend({}, sessionData.Status);
// Remove status message.
delete status.message;
// Convert buddy image.
if (status.buddyPicture) { if (status.buddyPicture) {
var img = this.dumpBuddyPictureToString(scope); var img = this.dumpBuddyPictureToString(scope);
if (img) { if (img) {
@ -631,7 +650,7 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
scope = this.onJoined({ scope = this.onJoined({
Id: contact.Userid, Id: contact.Userid,
Userid: contact.Userid, Userid: contact.Userid,
Status: contact.Status Status: _.extend({}, contact.Status)
}); });
scope.contact = contact; scope.contact = contact;
} }

Loading…
Cancel
Save