From a4627a4b6deed7702aab3146872ff0240bfa900e Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Thu, 30 Jun 2011 12:03:20 +0100 Subject: [PATCH] Fixed the author color Bug --- node/PadMessageHandler.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/node/PadMessageHandler.js b/node/PadMessageHandler.js index bd898397..05440c9b 100644 --- a/node/PadMessageHandler.js +++ b/node/PadMessageHandler.js @@ -470,6 +470,7 @@ function handleClientReady(client, message) var authorName; var authorColorId; var pad; + var historicalAuthorData = {}; async.series([ //get all authordata of this new user @@ -511,6 +512,20 @@ function handleClientReady(client, message) }); }, function(callback) + { + var authors = pad.getAllAuthors(); + + //get all author data out of the database + async.forEach(authors, function(authorId, callback) + { + authorManager.getAuthor(authorId, function(err, author) + { + historicalAuthorData[authorId] = author; + callback(err); + }); + }, callback); + }, + function(callback) { //Check if this author is already on the pad, if yes, kick the other sessions! if(pad2sessions[message.padId]) @@ -556,7 +571,7 @@ function handleClientReady(client, message) "clientIp": (client.request && client.request.connection) ? client.request.connection.remoteAddress : "127.0.0.1", //"clientAgent": "Anonymous Agent", "padId": message.padId, - "historicalAuthorData": {}, + "historicalAuthorData": historicalAuthorData, "apool": apool, "rev": pad.getHeadRevisionNumber(), "globalPadId": message.padId @@ -570,7 +585,7 @@ function handleClientReady(client, message) "opts": {}, "chatHistory": { "start": 0, - "historicalAuthorData": {}, + "historicalAuthorData": historicalAuthorData, "end": 0, "lines": [] }, @@ -592,16 +607,6 @@ function handleClientReady(client, message) clientVars.userName = authorName; } - //Add all authors that worked on this pad, to the historicalAuthorData on clientVars - var allAuthors = pad.getAllAuthors(); - for(i in allAuthors) - { - clientVars.collab_client_vars.historicalAuthorData[allAuthors[i]] = {}; - if(authorName != null) - clientVars.collab_client_vars.historicalAuthorData[allAuthors[i]].name = authorName; - clientVars.collab_client_vars.historicalAuthorData[allAuthors[i]].colorId = authorColorId; - } - //Send the clientVars to the Client client.send(clientVars);