diff --git a/converse.js b/converse.js index 3ef1736b6..85877a213 100644 --- a/converse.js +++ b/converse.js @@ -93,7 +93,8 @@ xmppchat.ChatBox = Backbone.Model.extend({ initialize: function () { this.set({ 'user_id' : Strophe.getNodeFromJid(this.get('jid')), - 'box_id' : this.hash(this.get('jid')) + 'box_id' : this.hash(this.get('jid')), + 'fullname' : this.get('fullname') }); } @@ -388,7 +389,7 @@ xmppchat.ChatBoxView = Backbone.View.extend({ template: _.template( '
' + - '
<%= user_id %>
' + + '
<%= fullname %>
' + 'X' + '

' + '

' + @@ -457,7 +458,7 @@ xmppchat.ContactsPanel = Backbone.View.extend({ .attr('id', 'found-users-'+obj.id) .append( $('') - .attr('data-recipient', obj.id+'@'+xmppchat.connection.domain) + .attr('data-recipient', Strophe.escapeNode(obj.id)+'@'+xmppchat.connection.domain) .text(obj.fullname) ) ); @@ -467,10 +468,9 @@ xmppchat.ContactsPanel = Backbone.View.extend({ subscribeToContact: function (ev) { ev.preventDefault(); - // FIXME: Need to escape username - var jid = $(ev.target).attr('data-recipient'); - xmppchat.connection.roster.add(jid, '', [], function (iq) { - // XXX: We can set the name here!!! + var jid = $(ev.target).attr('data-recipient'), + name = $(ev.target).text(); + xmppchat.connection.roster.add(jid, name, [], function (iq) { xmppchat.connection.roster.subscribe(jid); }); $(ev.target).parent().remove(); @@ -784,7 +784,8 @@ xmppchat.ChatBoxesView = Backbone.View.extend({ restoreOpenChats: function () { var cookie = jQuery.cookie('chats-open-'+xmppchat.username), - open_chats = []; + open_chats = [], + that = this; jQuery.cookie('chats-open-'+xmppchat.username, null, {path: '/'}); if (cookie) { @@ -792,12 +793,14 @@ xmppchat.ChatBoxesView = Backbone.View.extend({ if (_.indexOf(open_chats, 'online-users-container') != -1) { this.renderChat('online-users-container'); } - for (var i=0; i