diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 71a1ed8af..5c2431efd 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -41,6 +41,10 @@ define([ return e; }; + UI.getDisplayName = function (name) { + return (typeof(name) === 'string'? name: "").trim() || Messages.anonymous; + }; + // FIXME almost everywhere this is used would also be // a good candidate for sframe-common's getMediatagFromHref UI.mediaTag = function (src, key) { diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js index 65f05961e..4a3eb2a91 100644 --- a/www/common/common-messaging.js +++ b/www/common/common-messaging.js @@ -17,7 +17,8 @@ define([ edPublic: proxy.edPublic, curvePublic: proxy.curvePublic, notifications: Util.find(proxy, ['mailboxes', 'notifications', 'channel']), - avatar: proxy.profile && proxy.profile.avatar + avatar: proxy.profile && proxy.profile.avatar, + uid: proxy.uid, }; if (hash === false) { delete data.channel; } return data; diff --git a/www/common/messenger-ui.js b/www/common/messenger-ui.js index 76a756a11..494001624 100644 --- a/www/common/messenger-ui.js +++ b/www/common/messenger-ui.js @@ -190,9 +190,11 @@ define([ markup.message = function (msg) { if (msg.type !== 'MSG') { return; } var curvePublic = msg.author; + // FIXME this assignment looks like it has some holes in its logic + // but I'm scared to touch it because it looks like it was hacked to fix some bugs var name = (typeof msg.name !== "undefined" || !contactsData[msg.author]) ? (msg.name || Messages.anonymous) : - contactsData[msg.author].displayName; + contactsData[msg.author].displayName || Messages.anonymous; var d = msg.time ? new Date(msg.time) : undefined; var day = d ? d.toLocaleDateString() : ''; var hour = d ? d.toLocaleTimeString() : ''; @@ -239,7 +241,7 @@ define([ }); var chan = state.channels[id]; - var displayName = chan.name; + var displayName = UI.getDisplayName(chan.name || chan.displayName); var fetching = false; var $moreHistory = $(moreHistory).click(function () { @@ -364,7 +366,7 @@ define([ avatars[friend.avatar] = $img[0].outerHTML; } $(rightCol).insertAfter($avatar); - }); + }, friend.uid); } var sending = false; @@ -544,7 +546,7 @@ define([ title: Messages.contacts_online }); var rightCol = h('span.cp-app-contacts-right-col', [ - h('span.cp-app-contacts-name', [room.name]), + h('span.cp-app-contacts-name', [room.isFriendChat? UI.getDisplayName(room.name): room.name]), h('span.cp-app-contacts-icons', [ room.isFriendChat ? mute : undefined, room.isFriendChat ? unmute : undefined, @@ -609,7 +611,7 @@ define([ avatars[friendData.avatar] = $img[0].outerHTML; } $room.append(rightCol); - }); + }, friendData.uid); } $room.append(status); return $room; @@ -631,9 +633,9 @@ define([ var el_message = markup.message(message); if (message.type === 'MSG') { - var name = typeof message.name !== "undefined" ? - (message.name || Messages.anonymous) : - contactsData[message.author].displayName; + var name = UI.getDisplayName(typeof message.name !== "undefined" ? + message.name: + contactsData[message.author].displayName); common.notify({ title: name, msg: message.text, @@ -826,6 +828,11 @@ define([ } }; +/* The following block is for a disabled feature which allows users to switch + between pad chat (when in the context of a pad) and direct chats with their + contacts. +*/ +/* common.getMetadataMgr().onTitleChange(function () { var padChat = common.getPadChat(); var md = common.getMetadataMgr().getMetadata(); @@ -839,11 +846,14 @@ define([ $lAvatar.find('.cp-avatar-default, media-tag').remove(); var $div = $('