Fallback to JID when no fullname in vcard.
Also a bugfix: make sure to render the status widget when the user doesn't have any roster contacts.
This commit is contained in:
parent
91bdb56bdb
commit
9913cb6f98
39
converse.js
39
converse.js
@ -492,7 +492,7 @@
|
|||||||
jid,
|
jid,
|
||||||
$.proxy(function (jid, fullname, image, image_type, url) {
|
$.proxy(function (jid, fullname, image, image_type, url) {
|
||||||
this.model.save({
|
this.model.save({
|
||||||
'fullname' : fullname,
|
'fullname' : fullname || jid,
|
||||||
'url': url,
|
'url': url,
|
||||||
'image_type': image_type,
|
'image_type': image_type,
|
||||||
'image': image,
|
'image': image,
|
||||||
@ -1063,7 +1063,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
converse.xmppstatusview = new converse.XMPPStatusView({'model': converse.xmppstatus});
|
converse.xmppstatusview = new converse.XMPPStatusView({'model': converse.xmppstatus})
|
||||||
|
converse.xmppstatusview.render();
|
||||||
this.roomspanel = new converse.RoomsPanel();
|
this.roomspanel = new converse.RoomsPanel();
|
||||||
this.roomspanel.$parent = this.$el;
|
this.roomspanel.$parent = this.$el;
|
||||||
this.roomspanel.render();
|
this.roomspanel.render();
|
||||||
@ -1629,7 +1630,8 @@
|
|||||||
|
|
||||||
messageReceived: function (message) {
|
messageReceived: function (message) {
|
||||||
var partner_jid, $message = $(message),
|
var partner_jid, $message = $(message),
|
||||||
message_from = $message.attr('from');
|
message_from = $message.attr('from'),
|
||||||
|
roster_item, chatbox;
|
||||||
if (message_from == converse.connection.jid) {
|
if (message_from == converse.connection.jid) {
|
||||||
// FIXME: Forwarded messages should be sent to specific resources,
|
// FIXME: Forwarded messages should be sent to specific resources,
|
||||||
// not broadcasted
|
// not broadcasted
|
||||||
@ -1651,26 +1653,16 @@
|
|||||||
resource = Strophe.getResourceFromJid(message_from);
|
resource = Strophe.getResourceFromJid(message_from);
|
||||||
}
|
}
|
||||||
chatbox = this.get(partner_jid);
|
chatbox = this.get(partner_jid);
|
||||||
|
roster_item = converse.roster.get(partner_jid);
|
||||||
if (!chatbox) {
|
if (!chatbox) {
|
||||||
converse.getVCard(
|
chatbox = this.create({
|
||||||
partner_jid,
|
'id': partner_jid,
|
||||||
$.proxy(function (jid, fullname, image, image_type, url) {
|
'jid': partner_jid,
|
||||||
var chatbox = this.create({
|
'fullname': roster_item.get('fullname') || jid,
|
||||||
'id': jid,
|
'image_type': roster_item.get('image_type'),
|
||||||
'jid': jid,
|
'image': roster_item.get('image'),
|
||||||
'fullname': fullname,
|
'url': roster_item.get('url')
|
||||||
'image_type': image_type,
|
|
||||||
'image': image,
|
|
||||||
'url': url
|
|
||||||
});
|
});
|
||||||
chatbox.messageReceived(message);
|
|
||||||
converse.roster.addResource(partner_jid, resource);
|
|
||||||
}, this),
|
|
||||||
$.proxy(function () {
|
|
||||||
// # FIXME
|
|
||||||
console.log("An error occured while fetching vcard");
|
|
||||||
}, this));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
chatbox.messageReceived(message);
|
chatbox.messageReceived(message);
|
||||||
converse.roster.addResource(partner_jid, resource);
|
converse.roster.addResource(partner_jid, resource);
|
||||||
@ -1831,7 +1823,7 @@
|
|||||||
var rosteritem = converse.roster.get(jid);
|
var rosteritem = converse.roster.get(jid);
|
||||||
if (rosteritem) {
|
if (rosteritem) {
|
||||||
rosteritem.save({
|
rosteritem.save({
|
||||||
'fullname': fullname,
|
'fullname': fullname || jid,
|
||||||
'image_type': img_type,
|
'image_type': img_type,
|
||||||
'image': img,
|
'image': img,
|
||||||
'url': url,
|
'url': url,
|
||||||
@ -2194,7 +2186,7 @@
|
|||||||
item.set('sorted', true);
|
item.set('sorted', true);
|
||||||
this.initialSort();
|
this.initialSort();
|
||||||
this.$el.show(function () {
|
this.$el.show(function () {
|
||||||
converse.xmppstatusview.render();
|
converse.xmppstatus.initStatus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2395,7 +2387,6 @@
|
|||||||
$options_target = this.$el.find("#target dd ul").hide();
|
$options_target = this.$el.find("#target dd ul").hide();
|
||||||
$options_target.append(options_list.join(''));
|
$options_target.append(options_list.join(''));
|
||||||
$select.remove();
|
$select.remove();
|
||||||
this.model.initStatus();
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
11
mock.js
11
mock.js
@ -28,9 +28,16 @@
|
|||||||
},
|
},
|
||||||
'vcard': {
|
'vcard': {
|
||||||
'get': function (callback, jid) {
|
'get': function (callback, jid) {
|
||||||
|
var firstname, lastname;
|
||||||
|
if (!jid) {
|
||||||
|
jid = 'dummy@localhost';
|
||||||
|
firstname = 'Max';
|
||||||
|
lastname = 'Mustermann';
|
||||||
|
} else {
|
||||||
var name = jid.split('@')[0].replace('.', ' ').split(' ');
|
var name = jid.split('@')[0].replace('.', ' ').split(' ');
|
||||||
var firstname = name[0].charAt(0).toUpperCase()+name[0].slice(1);
|
firstname = name[0].charAt(0).toUpperCase()+name[0].slice(1);
|
||||||
var lastname = name[1].charAt(0).toUpperCase()+name[1].slice(1);
|
lastname = name[1].charAt(0).toUpperCase()+name[1].slice(1);
|
||||||
|
}
|
||||||
var fullname = firstname+' '+lastname;
|
var fullname = firstname+' '+lastname;
|
||||||
var vcard = $iq().c('vCard').c('FN').t(fullname);
|
var vcard = $iq().c('vCard').c('FN').t(fullname);
|
||||||
callback(vcard.tree());
|
callback(vcard.tree());
|
||||||
|
Loading…
Reference in New Issue
Block a user