Browse Source

Support updating ui when user logs in.

pull/151/head
Evan Theurer 11 years ago
parent
commit
5fa834f95f
  1. 19
      static/js/directives/chat.js

19
static/js/directives/chat.js

@ -218,17 +218,30 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
subscope.p2pstate = false; subscope.p2pstate = false;
subscope.active = false; subscope.active = false;
subscope.pending = 0; subscope.pending = 0;
var handleContactFunctionality = function() { var handleContactFunctionality = function(buddy) {
var buddyId = buddy && buddy.session && buddy.session.Userid; var buddyId = buddy && buddy.session && buddy.session.Userid;
var myId = appData.get().userid; var myId = appData.get().userid;
var isAnotherUser = buddyId && myId !== buddyId; var isAnotherUser = buddyId && myId !== buddyId;
subscope.contact.isContact = !!(buddy && buddy.contact); subscope.contact.isContact = !!(buddy && buddy.contact);
subscope.contact.disableContact = !myId || !isAnotherUser; subscope.contact.disableContact = !myId || !isAnotherUser;
subscope.contact.showContact = !subscope.isgroupchat && buddyId; subscope.contact.showContact = !subscope.isgroupchat && buddyId;
safeApply(subscope);
}; };
handleContactFunctionality(); handleContactFunctionality(buddy);
// Update chatter
appData.e.on('authenticationChanged', function() { appData.e.on('authenticationChanged', function() {
handleContactFunctionality(); handleContactFunctionality(buddy);
});
// Update chattee
mediaStream.api.e.on("received.status", function(event, data) {
if (!id && !data) {
return;
}
// Chattee status changed - logged in
var bd = buddyData.lookup(id);
if ((bd && bd.session.Userid) === data.Userid) {
handleContactFunctionality(buddyData.lookup(data.Id));
}
}); });
if (!subscope.isgroupchat) { if (!subscope.isgroupchat) {
buddyData.push(id); buddyData.push(id);

Loading…
Cancel
Save