@@ -152,7 +152,6 @@ export class ChatsComponent implements OnInit {
152152 } ) ;
153153
154154 this . connection . on ( 'PrivateChatDeletedAsync' , ( chatId : string ) => {
155- console . log ( `Private chat deleted: ${ chatId } ` ) ;
156155 const chatIndex = this . chats . findIndex ( ( x ) => x . chatId === chatId ) ;
157156
158157 if ( chatIndex === - 1 ) return ;
@@ -194,7 +193,6 @@ export class ChatsComponent implements OnInit {
194193
195194 this . connection . invoke ( 'JoinGroup' , this . activeChat . chatId ) . then ( ( ) => {
196195 this . realTimeConnections . push ( this . activeChat . chatId ) ;
197- console . log ( `SignalR JoinGroup: ${ this . activeChat . chatId } ` ) ;
198196 } ) ;
199197 }
200198
@@ -262,26 +260,34 @@ export class ChatsComponent implements OnInit {
262260
263261 this . messages . push ( newMessage ) ;
264262
263+ this . pushChatToTop ( this . activeChatId ) ;
264+
265265 this . _replyStateService . setReplyNull ( ) ;
266266
267+ this . scrollToEnd ( ) ;
268+
267269 const sendMessage$ = this . _messagesService . sendMessage ( sendMessageFormData ) ;
268270
269271 const response = await firstValueFrom < SendMessageResponse > ( sendMessage$ ) ;
270272
271- console . log ( JSON . stringify ( response ) ) ;
272-
273- // newMessage.messageId = response.messageModel.messageId;
274273 newMessage . attachmentUrl = response . attachmentUrl ;
275274 newMessage . createdAt = response . createdAt ;
276275
277- // const sendNotification$ = this._realtimeService.sendRealtimeNewMessageNotification(
278- // response.messageModel
279- // );
280- //
281- // await firstValueFrom<BaseResponse>(sendNotification$);
276+ if ( this . messageAttachment ) {
277+ this . clearAttachmentInput ( ) ;
278+ }
279+ }
282280
283- this . clearAttachmentInput ( ) ;
284- this . scrollToEnd ( ) ;
281+ pushChatToTop ( chatId : string ) {
282+ const chatIndex = this . chats . findIndex ( ( x ) => x . chatId === chatId ) ;
283+
284+ if ( chatIndex === - 1 ) return ;
285+
286+ const chat = this . chats [ chatIndex ] ;
287+
288+ this . chats . splice ( chatIndex , 1 ) ;
289+
290+ this . chats . splice ( 0 , 0 , chat ) ;
285291 }
286292
287293 onReplyClick (
@@ -311,9 +317,7 @@ export class ChatsComponent implements OnInit {
311317 this . messages . splice ( messageIndex , 1 ) ;
312318
313319 const deleteMessageSub$ = this . _messagesService . deleteMessage ( deleteMessageCommand ) ;
314- const deleteMessageResult = await firstValueFrom < DeleteMessageResponse > ( deleteMessageSub$ ) ;
315-
316- console . log ( deleteMessageResult . message ) ;
320+ await firstValueFrom < DeleteMessageResponse > ( deleteMessageSub$ ) ;
317321 }
318322
319323 async onJoinChatClick ( ) {
@@ -362,13 +366,9 @@ export class ChatsComponent implements OnInit {
362366 const div = event . currentTarget as HTMLDivElement ;
363367 this . chatFilter = div . innerText ;
364368
365- console . log ( this . chatFilter ) ;
366-
367369 const getChatsSub$ = this . _communitiesService . getUserChats ( ) ;
368370 const getChatsResult = await firstValueFrom < GetUserChatsResponse > ( getChatsSub$ ) ;
369371
370- console . log ( getChatsResult . chats ) ;
371-
372372 switch ( this . chatFilter ) {
373373 case 'All chats' :
374374 this . chats = getChatsResult . chats . filter ( ( x ) => ! x . isArchived ) ;
@@ -391,9 +391,7 @@ export class ChatsComponent implements OnInit {
391391
392392 async onLeaveChatClick ( ) {
393393 const leaveChatSub$ = this . _userChatsService . leaveCommunity ( this . activeChatId ) ;
394- const leaveChatResult = await firstValueFrom < BaseResponse > ( leaveChatSub$ ) ;
395-
396- console . log ( leaveChatResult . message ) ;
394+ await firstValueFrom < BaseResponse > ( leaveChatSub$ ) ;
397395
398396 this . activeChatId = '' ;
399397
@@ -402,26 +400,19 @@ export class ChatsComponent implements OnInit {
402400
403401 async onArchiveChatClick ( ) {
404402 const archiveChatSub$ = this . _userChatsService . archiveCommunity ( this . activeChatId ) ;
405- const archiveResult = await firstValueFrom < BaseResponse > ( archiveChatSub$ ) ;
406-
407- console . log ( archiveResult . message ) ;
403+ await firstValueFrom < BaseResponse > ( archiveChatSub$ ) ;
408404
409405 this . activeChatId = '' ;
410406
411407 await this . initializeView ( ) ;
412408 }
413409
414410 private onMessageSendHandler ( message : Message ) {
415- // console.log(JSON.stringify(message));
416-
417411 message . self = message . userId == this . userId ;
418412
419413 const chatIndex = this . chats . findIndex ( ( x ) => x . chatId === message . chatId ) ;
420414
421415 if ( chatIndex === - 1 ) return ;
422-
423- // console.log('chats: ' + JSON.stringify(this.chats));
424-
425416 const chat = this . chats [ chatIndex ] ;
426417
427418 chat . lastMessageAuthor = message . userDisplayName ;
@@ -430,9 +421,6 @@ export class ChatsComponent implements OnInit {
430421 chat . lastMessageId = message . messageId ;
431422
432423 this . chats . splice ( chatIndex , 1 ) ;
433-
434- // console.log('chats excluded: ' + JSON.stringify(this.chats));
435-
436424 this . chats . splice ( 0 , 0 , chat ) ;
437425
438426 if ( this . activeChatId !== message . chatId ) return ;
@@ -459,13 +447,6 @@ export class ChatsComponent implements OnInit {
459447 }
460448
461449 private onMessageDeleteHandler ( notification : DeleteMessageNotification ) {
462- console . log ( notification ) ;
463-
464- // const message = this.messages.filter((x) => x.messageId === notification.deletedMessageId)[0];
465-
466- console . log ( `deleted message id: ${ notification . deletedMessageId } ` ) ;
467- console . log ( `last message id: ${ this . activeChat . lastMessageId } ` ) ;
468-
469450 const chatIndex = this . chats . findIndex ( ( x ) => x . chatId === notification . chatId ) ;
470451
471452 if ( notification . isLastMessage && chatIndex !== - 1 ) {
@@ -475,8 +456,6 @@ export class ChatsComponent implements OnInit {
475456 updatedChat . lastMessageText = notification . newLastMessageText ;
476457 updatedChat . lastMessageTime = notification . newLastMessageTime ;
477458 updatedChat . lastMessageId = notification . newLastMessageId ;
478-
479- console . log ( `updated chat: ${ JSON . stringify ( updatedChat ) } ` ) ;
480459 }
481460
482461 if ( this . activeChatId !== notification . chatId ) return ;
0 commit comments