11/**
2- * This code is mostly from the old Etherpad. Please help us to comment this code.
2+ * This code is mostly from the old Etherpad. Please help us to comment this code.
33 * This helps other people to understand this code better and helps them to improve it.
44 * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
55 */
@@ -351,7 +351,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
351351 msg . userInfo . colorId = initialUserInfo . globalUserColor ;
352352 }
353353
354-
354+
355355 if ( userSet [ id ] )
356356 {
357357 userSet [ id ] = userInfo ;
@@ -405,7 +405,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
405405 $ ( "#chatloadmessagesball" ) . css ( "display" , "none" ) ;
406406
407407 // there are less than 100 messages or we reached the top
408- if ( chat . historyPointer <= 0 )
408+ if ( chat . historyPointer <= 0 )
409409 $ ( "#chatloadmessagesbutton" ) . css ( "display" , "none" ) ;
410410 else // there are still more messages, re-show the load-button
411411 $ ( "#chatloadmessagesbutton" ) . css ( "display" , "block" ) ;
@@ -414,6 +414,12 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
414414 {
415415 callbacks . onServerMessage ( msg . payload ) ;
416416 }
417+
418+ //HACKISH: User messages do not have "payload" but "userInfo", so that all "handleClientMessage_USER_" hooks would work, populate payload
419+ //FIXME: USER_* messages to have "payload" property instead of "userInfo", seems like a quite a big work
420+ if ( msg . type . indexOf ( "USER_" ) > - 1 ) {
421+ msg . payload = msg . userInfo ;
422+ }
417423 hooks . callAll ( 'handleClientMessage_' + msg . type , { payload : msg . payload } ) ;
418424 }
419425
@@ -441,7 +447,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
441447 {
442448 colorId = clientVars . colorPalette [ colorId ] ;
443449 }
444-
450+
445451 var cssColor = colorId ;
446452 if ( inactive )
447453 {
0 commit comments