diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index 6a709d73d..5bc1f5829 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -5,9 +5,10 @@ define([ '/common/common-util.js', '/common/common-realtime.js', '/common/common-constants.js', + '/customize/messages.js', '/bower_components/nthen/index.js', -], function (Crypto, Curve, Hash, Util, Realtime, Constants, nThen) { +], function (Crypto, Curve, Hash, Util, Realtime, Constants, Messages, nThen) { 'use strict'; var Msg = { inputs: [], @@ -698,7 +699,9 @@ define([ var msg = [Types.message, proxy.curvePublic, +new Date(), payload]; if (!channel.isFriendChat) { - msg.push(proxy[Constants.displayNameKey]); + var name = proxy[Constants.displayNameKey] || + Messages.anonymous + '#' + proxy.uid.slice(0,5); + msg.push(name); } var msgStr = JSON.stringify(msg); var cryptMsg = channel.encryptor.encrypt(msgStr); diff --git a/www/contacts/messenger-ui.js b/www/contacts/messenger-ui.js index 6770166e4..dfb77b09b 100644 --- a/www/contacts/messenger-ui.js +++ b/www/contacts/messenger-ui.js @@ -169,14 +169,15 @@ define([ markup.message = function (msg) { if (msg.type !== 'MSG') { return; } var curvePublic = msg.author; - var name = typeof msg.name !== "undefined" ? (msg.name || Messages.anonymous) - : contactsData[msg.author].displayName; + var name = typeof msg.name !== "undefined" ? + (msg.name || Messages.anonymous) : + contactsData[msg.author].displayName; var d = msg.time ? new Date(msg.time) : undefined; var day = d ? d.toLocaleDateString() : ''; var hour = d ? d.toLocaleTimeString() : ''; return h('div.cp-app-contacts-message', { //title: time || '?', - 'data-user': curvePublic, + 'data-user': curvePublic || name, 'data-day': day }, [ name? h('div.cp-app-contacts-sender', [ @@ -550,8 +551,9 @@ define([ common.notify(); if (message.type === 'MSG') { - var name = typeof message.name !== "undefined" ? (message.name || Messages.anonymous) - : contactsData[message.author].displayName; + var name = typeof message.name !== "undefined" ? + (message.name || Messages.anonymous) : + contactsData[message.author].displayName; common.notify({title: name, msg: message.text}); } notifyToolbar();