From c38eb6588e7be10e27891a87ebc7854a5ecad00a Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 12 Sep 2018 11:55:26 +0200 Subject: [PATCH] Fix small issues with the messenger --- customize.dist/src/less2/include/toolbar.less | 4 +++- customize.dist/translations/messages.js | 6 ++++++ www/code/app-code.less | 10 +++++++--- www/common/common-messenger.js | 11 ++++++----- www/common/toolbar3.js | 9 +++++---- www/contacts/messenger-ui.js | 10 ++++------ 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index 9f5da11e8..a155431ac 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -147,6 +147,7 @@ box-sizing: border-box; position: relative; order: -2; + resize: horizontal; #cp-app-contacts-container { height: 100%; } @@ -991,7 +992,8 @@ height: @toolbar_line-height; } - #cp-toolbar-userlist-drawer-open { order: 1; } + #cp-toolbar-userlist-drawer-open { order: 0; } + #cp-toolbar-chat-drawer-open { order: 1; } .cp-toolbar-share-button { order: 2; } .cp-toolbar-spinner { order: 3; } diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index f88f211e3..01d075f9d 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -136,6 +136,8 @@ define(function () { out.userListButton = "User list"; + out.chatButton = "Chat"; + out.userAccountButton = "Your account"; out.newButton = 'New'; @@ -376,6 +378,10 @@ define(function () { out.contacts_removeHistoryServerError = 'There was an error while removing your chat history. Try again later'; out.contacts_fetchHistory = "Retrieve older history"; + out.contacts_friends = "Friends"; + out.contacts_rooms = "Rooms"; + out.contacts_leaveRoom = "Leave this room"; + // File manager out.fm_rootName = "Documents"; diff --git a/www/code/app-code.less b/www/code/app-code.less index 37a18b4ee..b2b3a1a64 100644 --- a/www/code/app-code.less +++ b/www/code/app-code.less @@ -19,17 +19,16 @@ flex-flow: column; height: 100%; min-height: 100%; - width: 50%; min-width: 20%; max-width: 80%; resize: horizontal; overflow: hidden; + width: 50%; &.cp-app-code-fullpage { max-width: 100%; resize: none; flex: 1; } - } .CodeMirror { flex: 1; @@ -51,9 +50,13 @@ #cp-app-code-container { display: none; } #cp-app-code-preview { border: 0; } } + &.cp-chat-visible { + #cp-app-code-container { + width: 35%; + } + } } #cp-app-code-preview { - flex: 1; padding: 5px 20px; overflow: auto; display: inline-block; @@ -63,6 +66,7 @@ font-family: Calibri,Ubuntu,sans-serif; word-wrap: break-word; position: relative; + flex: 1; media-tag { * { max-width:100%; diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index fb6bebf69..51279718e 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -54,7 +54,7 @@ define([ var msgAlreadyKnown = function (channel, sig) { return channel.messages.some(function (message) { - return message[0] === sig; + return message.sig === sig; }); }; @@ -291,9 +291,9 @@ define([ }; var pushMsg = function (channel, cryptMsg) { - var msg = channel.encryptor.decrypt(cryptMsg); var sig = cryptMsg.slice(0, 64); if (msgAlreadyKnown(channel, sig)) { return; } + var msg = channel.encryptor.decrypt(cryptMsg); var parsedMsg = JSON.parse(msg); var curvePublic; @@ -435,7 +435,8 @@ define([ return null; } }).filter(function (decrypted) { - if (decrypted.d && decrypted.d[0] !== Types.message) { return; } + if (!decrypted.d || decrypted.d[0] !== Types.message) { return; } + if (msgAlreadyKnown(channel, decrypted.sig)) { return; } return decrypted; }).map(function (O) { return { @@ -803,8 +804,6 @@ define([ }); // TODO load rooms }).nThen(function () { - // TODO send event chat ready - // Remove spinner in chatbox ready = true; eachHandler('event', function (f) { f('READY'); @@ -850,6 +849,8 @@ define([ name = friend.displayName; lastKnownHash = friend.lastKnownHash; curvePublic = friend.curvePublic; + } else if (r.isPadChat) { + return; } else { // TODO room get metadata (name) && lastKnownHash } diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index f04b74c41..a9fab999f 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -7,7 +7,7 @@ define([ '/common/common-hash.js', '/common/common-feedback.js', '/common/sframe-messenger-inner.js', - '/contacts/messenger-ui.js', + '/contacts/messenger-ui.js?'+ +new Date(), '/customize/messages.js', ], function ($, Config, ApiConfig, UIElements, UI, Hash, Feedback, Messenger, MessengerUI, Messages) { @@ -437,9 +437,9 @@ Messenger, MessengerUI, Messages) { toolbar.chatContent = $content; - var $container = $('', {id: 'cp-toolbar-chat-drawer-open', title: Messages.chatButton || 'CHAT'}); //XXX + var $container = $('', {id: 'cp-toolbar-chat-drawer-open', title: Messages.chatButton}); - var $button = $('