From aab71864865b28d3b141153d3d52d8625cf18289 Mon Sep 17 00:00:00 2001 From: Mikk Andresen Date: Thu, 31 Dec 2015 14:19:23 +0200 Subject: [PATCH] Fix handleClientMessage_USER_* payloads not containing user info --- src/static/js/collab_client.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index ad4935289..fd0d9d446 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -1,5 +1,5 @@ /** - * This code is mostly from the old Etherpad. Please help us to comment this code. + * This code is mostly from the old Etherpad. Please help us to comment this code. * This helps other people to understand this code better and helps them to improve it. * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED */ @@ -351,7 +351,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) msg.userInfo.colorId = initialUserInfo.globalUserColor; } - + if (userSet[id]) { userSet[id] = userInfo; @@ -405,7 +405,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) $("#chatloadmessagesball").css("display", "none"); // there are less than 100 messages or we reached the top - if(chat.historyPointer <= 0) + if(chat.historyPointer <= 0) $("#chatloadmessagesbutton").css("display", "none"); else // there are still more messages, re-show the load-button $("#chatloadmessagesbutton").css("display", "block"); @@ -414,6 +414,12 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) { callbacks.onServerMessage(msg.payload); } + + //HACKISH: User messages do not have "payload" but "userInfo", so that all "handleClientMessage_USER_" hooks would work, populate payload + //FIXME: USER_* messages to have "payload" property instead of "userInfo", seems like a quite a big work + if(msg.type.indexOf("USER_") > -1) { + msg.payload = msg.userInfo; + } hooks.callAll('handleClientMessage_' + msg.type, {payload: msg.payload}); } @@ -441,7 +447,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) { colorId = clientVars.colorPalette[colorId]; } - + var cssColor = colorId; if (inactive) {