@@ -226,13 +226,13 @@ Dialog.prototype.renderMessages = function (dialogId) {
226226 self . sidebar . classList . add ( 'active' ) ;
227227 } . bind ( self ) ) ;
228228
229- self . quitLink . addEventListener ( 'click' , function ( e ) {
230- e . preventDefault ( ) ;
229+ messageModule . init ( ) ;
230+
231+ self . quitLink . addEventListener ( 'click' , function ( e ) {
232+ e . preventDefault ( ) ;
231233 if ( dialog . type === CONSTANTS . DIALOG_TYPES . PUBLICCHAT ) return ;
232- self . quitFromTheDialog ( dialogId )
234+ self . quitFromTheDialog ( this . dataset . dialog ) ;
233235 } ) ;
234-
235- messageModule . init ( ) ;
236236 } else {
237237 if ( self . prevDialogId ) {
238238 messageModule . sendStopTypingStatus ( self . prevDialogId ) ;
@@ -252,9 +252,11 @@ Dialog.prototype.renderMessages = function (dialogId) {
252252 }
253253 }
254254
255+ self . editLink . href = '#!/dialog/' + self . dialogId + '/edit' ;
256+ self . quitLink . dataset . dialog = dialogId ;
257+
255258 if ( dialog . type === CONSTANTS . DIALOG_TYPES . GROUPCHAT ) {
256259 self . editLink . classList . remove ( 'hidden' ) ;
257- self . editLink . href = '#!/dialog/' + self . dialogId + '/edit' ;
258260 } else {
259261 self . editLink . classList . add ( 'hidden' ) ;
260262 }
@@ -329,14 +331,19 @@ Dialog.prototype.createDialog = function (params) {
329331 if ( err ) {
330332 console . error ( err ) ;
331333 } else {
332- var id = createdDialog . _id ;
333- var occupants = createdDialog . occupants_ids ,
334+ var occupants_names = [ ] ,
335+ id = createdDialog . _id ,
336+ occupants = createdDialog . occupants_ids ,
334337 message_body = ( app . user . name || app . user . login ) + ' created new dialog with: ' ;
335338
336339 _ . each ( occupants , function ( occupantId ) {
337- message_body += ( userModule . _cache [ occupantId ] . name || userModule . _cache [ occupantId ] . login ) + " " ;
340+ var occupant_name = userModule . _cache [ occupantId ] . name || userModule . _cache [ occupantId ] . login ;
341+
342+ occupants_names . push ( occupant_name ) ;
338343 } ) ;
339344
345+ message_body += occupants_names . join ( ', ' ) ;
346+
340347 var systemMessage = {
341348 extension : {
342349 notification_type : 1 ,
@@ -461,7 +468,7 @@ Dialog.prototype.updateDialog = function (updates) {
461468 if ( updates . title !== dialog . name ) {
462469 toUpdateParams . name = updates . title ;
463470 updatedMsg . extension . dialog_name = updates . title ;
464- updatedMsg . body = app . user . name + ' changed the conversation name to "' + updates . title + '".'
471+ updatedMsg . body = app . user . name + ' changed the conversation name to "' + updates . title + '".' ;
465472 }
466473 }
467474
@@ -479,7 +486,7 @@ Dialog.prototype.updateDialog = function (updates) {
479486
480487 self . _cache [ dialogId ] . users = self . _cache [ dialogId ] . users . concat ( newUsers ) ;
481488
482- updatedMsg . body = app . user . name + ' adds ' + usernames . join ( ',' ) + ' to the conversation.' ;
489+ updatedMsg . body = app . user . name + ' adds ' + usernames . join ( ', ' ) + ' to the conversation.' ;
483490 updatedMsg . extension . occupants_ids_added = newUsers . join ( ',' ) ;
484491 } else {
485492 router . navigate ( '/dialog/' + dialogId ) ;
@@ -531,7 +538,7 @@ Dialog.prototype.updateDialog = function (updates) {
531538
532539 _ . each ( users , function ( user ) {
533540 QB . chat . sendSystemMessage ( + user , msg ) ;
534- } )
541+ } ) ;
535542 }
536543} ;
537544
0 commit comments