@chat21/chat21-ionic 3.0.62-rc2 → 3.0.64-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +6 -2
  3. package/deploy_prod.sh +5 -5
  4. package/package.json +7 -1
  5. package/src/app/app.component.ts +127 -69
  6. package/src/app/app.module.ts +1 -0
  7. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +2 -0
  8. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +2 -1
  9. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +34 -22
  10. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +33 -12
  11. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +4 -40
  12. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +18 -6
  13. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +1 -1
  14. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +2 -2
  15. package/src/app/chatlib/conversation-detail/message/html/html.component.html +1 -0
  16. package/src/app/chatlib/conversation-detail/message/html/html.component.scss +79 -0
  17. package/src/app/chatlib/conversation-detail/message/html/html.component.spec.ts +25 -0
  18. package/src/app/chatlib/conversation-detail/message/html/html.component.ts +33 -0
  19. package/src/app/chatlib/conversation-detail/message/image/image.component.ts +5 -3
  20. package/src/app/chatlib/conversation-detail/message/return-receipt/return-receipt.component.scss +1 -1
  21. package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.html +1 -1
  22. package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.scss +4 -4
  23. package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.html +1 -1
  24. package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.scss +3 -3
  25. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +3 -3
  26. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +10 -55
  27. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +10 -4
  28. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +4 -2
  29. package/src/app/components/image-viewer/image-viewer.component.ts +28 -10
  30. package/src/app/components/project-item/project-item.component.ts +6 -30
  31. package/src/app/components/sidebar/sidebar.component.html +2 -2
  32. package/src/app/components/sidebar/sidebar.component.ts +49 -83
  33. package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +17 -1
  34. package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +52 -6
  35. package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +81 -111
  36. package/src/app/directives/safe-html.pipe.ts +2 -2
  37. package/src/app/pages/authentication/login/login.page.ts +20 -1
  38. package/src/app/pages/conversation-detail/conversation-detail.page.html +42 -19
  39. package/src/app/pages/conversation-detail/conversation-detail.page.scss +15 -6
  40. package/src/app/pages/conversation-detail/conversation-detail.page.ts +188 -264
  41. package/src/app/pages/conversations-list/conversations-list.page.html +21 -12
  42. package/src/app/pages/conversations-list/conversations-list.page.ts +58 -191
  43. package/src/app/pages/loader-preview/loader-preview.module.ts +1 -2
  44. package/src/app/services/nav-proxy.service.ts +15 -13
  45. package/src/app/shared/shared.module.ts +4 -0
  46. package/src/assets/i18n/de.json +2 -1
  47. package/src/assets/i18n/en.json +2 -1
  48. package/src/assets/i18n/es.json +2 -1
  49. package/src/assets/i18n/fr.json +2 -1
  50. package/src/assets/i18n/it.json +2 -1
  51. package/src/assets/i18n/pt.json +2 -1
  52. package/src/assets/i18n/ru.json +2 -1
  53. package/src/assets/i18n/sr.json +2 -1
  54. package/src/assets/i18n/tr.json +2 -1
  55. package/src/chat-config-pre-test.json +2 -1
  56. package/src/chat-config-pre.json +15 -3
  57. package/src/chat21-core/models/conversation.ts +1 -1
  58. package/src/chat21-core/providers/abstract/conversations-handler.service.ts +1 -1
  59. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +2 -3
  60. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +65 -9
  61. package/src/chat21-core/providers/logger/customLogger.ts +2 -10
  62. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +1 -1
  63. package/src/chat21-core/utils/utils-message.ts +101 -85
  64. package/src/variables.scss +4 -1
@@ -143,7 +143,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
143
143
  arrowkeyLocation = -1
144
144
  public_Key: any;
145
145
  areVisibleCAR: boolean;
146
- support_mode: boolean;
146
+ supportMode: boolean;
147
147
  //SOUND
148
148
  setTimeoutSound: any;
149
149
  audio: any;
@@ -166,6 +166,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
166
166
  public checkInternet: boolean;
167
167
  public msgCount: number;
168
168
  public disableTextarea: boolean;
169
+ appsidebarIsWide: boolean;
169
170
 
170
171
  /**
171
172
  * Constructor
@@ -252,8 +253,44 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
252
253
  this.watchToConnectionStatus();
253
254
  this.getOSCODE();
254
255
  this.getStoredProjectAndUserRole();
256
+ this.listenToDsbrdPostMsgs();
255
257
  }
256
258
 
259
+ listenToDsbrdPostMsgs() {
260
+
261
+ window.addEventListener("message", (event) => {
262
+ this.logger.log("[CONVS-DETAIL] message event ", event);
263
+
264
+ // const chat21InfoConversationEle = <HTMLElement>document.querySelector('#chat21-info-conversation');
265
+ // console.log('[CONVS-DETAIL] HAS CLICKED ENLARGE SIDEBAR WIDE chat21InfoConversationEle ', chat21InfoConversationEle)
266
+
267
+ // const chatAreaEle = <HTMLElement>document.querySelector('#chatArea');
268
+ // console.log('[CONVS-DETAIL] HAS CLICKED ENLARGE SIDEBAR WIDE chatAreaEle ', chatAreaEle)
269
+
270
+ if (event && event.data && event.data.action && event.data.action === 'openAppsSidebarWideMode' && event.data.parameter === true) {
271
+ this.logger.log('[CONVS-DETAIL] HERE YES 1')
272
+ this.appsidebarIsWide = true
273
+ // chat21InfoConversationEle.classList.add("info-convs-apps-sidebar-wide");
274
+ // chatAreaEle.classList.add("chat-area-apps-sidebar-wide");
275
+ }
276
+
277
+ if (event && event.data && event.data.action && event.data.action === 'openAppsSidebarWideMode' && event.data.parameter === false) {
278
+ this.logger.log('[CONVS-DETAIL] HERE YES 2')
279
+ this.appsidebarIsWide = false
280
+ // chat21InfoConversationEle.classList.remove("info-convs-apps-sidebar-wide");
281
+ // chatAreaEle.classList.remove("chat-area-apps-sidebar-wide");
282
+ }
283
+
284
+ if (event && event.data && event.data.action && event.data.action === 'closeAppsSidebarWideMode' && event.data.parameter === true) {
285
+ this.logger.log('[CONVS-DETAIL] HERE YES 3')
286
+ this.appsidebarIsWide = false
287
+ // chat21InfoConversationEle.classList.remove("info-convs-apps-sidebar-wide");
288
+ // chatAreaEle.classList.remove("chat-area-apps-sidebar-wide");
289
+ }
290
+ })
291
+ }
292
+
293
+
257
294
  getStoredProjectAndUserRole() {
258
295
  const stored_project = localStorage.getItem('last_project')
259
296
  // console.log('[SIDEBAR] stored_project ', stored_project)
@@ -276,7 +313,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
276
313
  const conversations = this.conversationsHandlerService.conversations
277
314
  // console.log('[CONVS-DETAIL] conversations', conversations);
278
315
  this.conversation_count = conversations.length
279
- this.logger.log('[CONVS-DETAIL] conversation_count', this.conversation_count)
280
316
  })
281
317
 
282
318
  this.conversationsHandlerService.conversationChanged.subscribe((conv) => {
@@ -284,10 +320,22 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
284
320
  const conversations = this.conversationsHandlerService.conversations
285
321
  // console.log('[CONVS-DETAIL] conversations', conversations);
286
322
  this.conversation_count = conversations.length
287
- this.logger.log(
288
- '[CONVS-DETAIL] conversation_count',
289
- this.conversation_count,
290
- )
323
+ if (conv && conv.sender !== this.loggedUser.uid) {
324
+ this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange data sender ', conv.sender)
325
+ this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange this.loggedUser.uid ', this.loggedUser.uid)
326
+ this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange is_new ', conv.is_new)
327
+ this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange showButtonToBottom ', this.showButtonToBottom)
328
+ // UPDATE THE CONVERSATION TO 'READ' IF IT IS ME WHO WRITES THE LAST MESSAGE OF THE CONVERSATION
329
+ // AND IF THE POSITION OF THE SCROLL IS AT THE END
330
+ if (!this.showButtonToBottom && conv.is_new) {
331
+ // ARE AT THE END
332
+ this.updateConversationBadge()
333
+ }
334
+ if(conv.uid && conv.uid === this.conversationWith){
335
+ this.conversationAvatar = setConversationAvatar(conv.conversation_with,conv.conversation_with_fullname,conv.channel_type)
336
+ }
337
+
338
+ }
291
339
  })
292
340
 
293
341
  this.conversationsHandlerService.conversationRemoved.subscribe((conv) => {
@@ -295,10 +343,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
295
343
  const conversations = this.conversationsHandlerService.conversations
296
344
  // console.log('[CONVS-DETAIL] conversations', conversations);
297
345
  this.conversation_count = conversations.length
298
- this.logger.log(
299
- '[CONVS-DETAIL] conversation_count',
300
- this.conversation_count,
301
- )
346
+ this.logger.log('[CONVS-DETAIL] conversation_count', this.conversation_count)
302
347
  })
303
348
 
304
349
  setTimeout(() => {
@@ -307,15 +352,15 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
307
352
  }
308
353
 
309
354
  getOSCODE() {
310
- this.support_mode = null
311
- if( this.appConfigProvider.getConfig().supportMode === true || this.appConfigProvider.getConfig().supportMode === 'true') {
312
- this.support_mode = true
313
- } else if ( this.appConfigProvider.getConfig().supportMode === false || this.appConfigProvider.getConfig().supportMode === 'false') {
314
- this.support_mode = false
315
- } else if ( !this.appConfigProvider.getConfig().supportMode ) {
316
- this.support_mode = false
355
+ this.supportMode = null
356
+ if (this.appConfigProvider.getConfig().supportMode === true || this.appConfigProvider.getConfig().supportMode === 'true') {
357
+ this.supportMode = true
358
+ } else if (this.appConfigProvider.getConfig().supportMode === false || this.appConfigProvider.getConfig().supportMode === 'false') {
359
+ this.supportMode = false
360
+ } else if (!this.appConfigProvider.getConfig().supportMode) {
361
+ this.supportMode = false
317
362
  }
318
- this.logger.log('[CONVS-DETAIL] AppConfigService getAppConfig support_mode', this.support_mode)
363
+ this.logger.log('[CONVS-DETAIL] AppConfigService getAppConfig supportMode', this.supportMode)
319
364
  this.public_Key = this.appConfigProvider.getConfig().t2y12PruGU9wUtEGzBJfolMIgK
320
365
  this.logger.log('[CONVS-DETAIL] AppConfigService getAppConfig public_Key', this.public_Key)
321
366
 
@@ -328,26 +373,17 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
328
373
  let car = key.split(':')
329
374
  if (car[1] === 'F') {
330
375
  this.areVisibleCAR = false
331
- this.logger.log(
332
- '[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
333
- this.areVisibleCAR,
334
- )
376
+ this.logger.log('[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',this.areVisibleCAR)
335
377
  } else {
336
378
  this.areVisibleCAR = true
337
- this.logger.log(
338
- '[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
339
- this.areVisibleCAR,
340
- )
379
+ this.logger.log('[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',this.areVisibleCAR)
341
380
  }
342
381
  }
343
382
  })
344
383
 
345
384
  if (!this.public_Key.includes('CAR')) {
346
385
  this.areVisibleCAR = false
347
- this.logger.log(
348
- '[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
349
- this.areVisibleCAR,
350
- )
386
+ this.logger.log('[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',this.areVisibleCAR)
351
387
  }
352
388
  } else {
353
389
  this.areVisibleCAR = false
@@ -430,21 +466,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
430
466
  // @ Inizialize
431
467
  // --------------------------------------------------
432
468
  initialize() {
433
- // this.logger.log('[CONVS-DETAIL] x conversationWith getConversationDetail', this.conversationWith)
434
- // this.logger.log('[CONVS-DETAIL] x conversationsHandlerService getConversationDetail', this.conversationsHandlerService)
435
- // this.logger.log('[CONVS-DETAIL] x this.conv_type getConversationDetail', this.conv_type)
436
-
437
- // if (this.conversationWith && this.conversationsHandlerService && this.conv_type === 'active') {
438
- // this.conversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
439
- // this.logger.log('[CONVS-DETAIL] x conversationsHandlerService getConversationDetail', this.conversationWith, conv)
440
- // })
441
- // }
442
- // else { //get conversation from 'conversations' firebase node
443
- // this.archivedConversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
444
- // this.logger.log('[CONVS-DETAIL] x archivedConversationsHandlerService getConversationDetail', this.conversationWith, conv)
445
-
446
- // })
447
- // }
448
469
 
449
470
  this.loggedUser = this.tiledeskAuthService.getCurrentUser()
450
471
  this.logger.log('[CONVS-DETAIL] - initialize -> loggedUser: ', this.loggedUser)
@@ -454,7 +475,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
454
475
  this.showMessageWelcome = false
455
476
 
456
477
  const appconfig = this.appConfigProvider.getConfig()
457
- // this.tenant = appconfig.tenant;
458
478
  this.tenant = appconfig.firebaseConfig.tenant
459
479
  this.logger.log('[CONVS-DETAIL] - initialize -> firebaseConfig tenant ', this.tenant)
460
480
 
@@ -473,40 +493,21 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
473
493
  this.logger.log('[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ', this.isMobile)
474
494
  } else {
475
495
  this.isMobile = false
476
- this.logger.log(
477
- '[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ',
478
- this.isMobile,
479
- )
496
+ this.logger.log('[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ', this.isMobile)
480
497
  // this.openInfoConversation = true;
481
498
  }
482
499
 
483
500
  if (this.isMobile === false) {
484
501
  if (checkWindowWidthIsLessThan991px()) {
485
- this.logger.log(
486
- '[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ',
487
- checkWindowWidthIsLessThan991px(),
488
- )
502
+ this.logger.log('[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ', checkWindowWidthIsLessThan991px())
489
503
  this.openInfoConversation = false // indica se è aperto il box info conversazione
490
504
  this.isOpenInfoConversation = false
491
- this.logger.log(
492
- '[CONVS-DETAIL] - initialize -> openInfoConversation ',
493
- this.openInfoConversation,
494
- ' -> isOpenInfoConversation ',
495
- this.isOpenInfoConversation,
496
- )
505
+ this.logger.log('[CONVS-DETAIL] - initialize -> openInfoConversation ', this.openInfoConversation, ' -> isOpenInfoConversation ', this.isOpenInfoConversation)
497
506
  } else {
498
- this.logger.log(
499
- '[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ',
500
- checkWindowWidthIsLessThan991px(),
501
- )
507
+ this.logger.log('[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ', checkWindowWidthIsLessThan991px())
502
508
  this.openInfoConversation = true
503
509
  this.isOpenInfoConversation = true
504
- this.logger.log(
505
- '[CONVS-DETAIL] - initialize -> openInfoConversation ',
506
- this.openInfoConversation,
507
- ' -> isOpenInfoConversation ',
508
- this.isOpenInfoConversation,
509
- )
510
+ this.logger.log('[CONVS-DETAIL] - initialize -> openInfoConversation ', this.openInfoConversation, ' -> isOpenInfoConversation ', this.isOpenInfoConversation)
510
511
  }
511
512
  }
512
513
 
@@ -582,10 +583,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
582
583
  }
583
584
 
584
585
  returnOpenCloseInfoConversation(openInfoConversation: boolean) {
585
- this.logger.log(
586
- '[CONVS-DETAIL] returnOpenCloseInfoConversation - openInfoConversation ',
587
- openInfoConversation,
588
- )
586
+ this.logger.log('[CONVS-DETAIL] returnOpenCloseInfoConversation - openInfoConversation ', openInfoConversation)
589
587
  this.resizeTextArea()
590
588
  this.openInfoMessage = false
591
589
  this.openInfoConversation = openInfoConversation
@@ -677,15 +675,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
677
675
  initConversationHandler() {
678
676
  const translationMap = this.setTranslationMapForConversationHandler()
679
677
  this.showMessageWelcome = false
680
- const handler: ConversationHandlerService = this.chatManager.getConversationHandlerByConversationId(
681
- this.conversationWith,
682
- )
683
- this.logger.log(
684
- '[CONVS-DETAIL] - initConversationHandler - handler ',
685
- handler,
686
- ' conversationWith ',
687
- this.conversationWith,
688
- )
678
+ const handler: ConversationHandlerService = this.chatManager.getConversationHandlerByConversationId(this.conversationWith)
679
+ this.logger.log('[CONVS-DETAIL] - initConversationHandler - handler ', handler, ' conversationWith ', this.conversationWith)
689
680
  if (!handler) {
690
681
  this.conversationHandlerService = this.conversationHandlerBuilderService.build()
691
682
  this.conversationHandlerService.initialize(
@@ -696,15 +687,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
696
687
  translationMap,
697
688
  )
698
689
  this.conversationHandlerService.connect()
699
- this.logger.log(
700
- '[CONVS-DETAIL] - initConversationHandler - NEW handler - conversationHandlerService',
701
- this.conversationHandlerService,
702
- )
690
+ this.logger.log('[CONVS-DETAIL] - initConversationHandler - NEW handler - conversationHandlerService', this.conversationHandlerService)
703
691
  this.messages = this.conversationHandlerService.messages
704
- this.logger.log(
705
- '[CONVS-DETAIL] - initConversationHandler - messages: ',
706
- this.messages,
707
- )
692
+ this.logger.log('[CONVS-DETAIL] - initConversationHandler - messages: ', this.messages)
708
693
  this.chatManager.addConversationHandler(this.conversationHandlerService)
709
694
 
710
695
  // // wait 8 second and then display the message if there are no messages
@@ -773,15 +758,10 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
773
758
  // this.logger.log('[CONVS-DETAIL] - setHeaderContent conversationWith', this.conversationWith)
774
759
  // this.logger.log('[CONVS-DETAIL] - setHeaderContent conversationsHandlerService', this.conversationsHandlerService)
775
760
  // this.logger.log('[CONVS-DETAIL] - setHeaderContent conv_type', this.conv_type)
776
- if (
777
- this.conversationWith &&
778
- this.conversationsHandlerService &&
779
- this.conv_type === 'active'
780
- ) {
761
+ if (this.conversationWith && this.conversationsHandlerService && this.conv_type === 'active') {
781
762
  this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail CALLING')
782
763
  this.conversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
783
764
  if (conv) {
784
- // console.log( '[CONVS-DETAIL] - setHeaderContent getConversationDetail (active)', this.conversationWith, conv )
785
765
  this.conversationAvatar = setConversationAvatar(
786
766
  conv.conversation_with,
787
767
  conv.conversation_with_fullname,
@@ -789,23 +769,19 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
789
769
  )
790
770
  }
791
771
  this.logger.log('[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ', this.conversationAvatar)
792
- },
793
- )
772
+ })
794
773
  } else {
795
774
  //get conversation from 'conversations' firebase node
796
- this.archivedConversationsHandlerService.getConversationDetail(
797
- this.conversationWith,
798
- (conv) => {
799
- if (conv) {
800
- // console.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail (archived)', this.conversationWith, 'CONVS', conv)
801
- this.conversationAvatar = setConversationAvatar(
802
- conv.conversation_with,
803
- conv.conversation_with_fullname,
804
- conv.channel_type,
805
- )
806
- }
807
- },
808
- )
775
+ this.archivedConversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
776
+ if (conv) {
777
+ // console.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail (archived)', this.conversationWith, 'CONVS', conv)
778
+ this.conversationAvatar = setConversationAvatar(
779
+ conv.conversation_with,
780
+ conv.conversation_with_fullname,
781
+ conv.channel_type,
782
+ )
783
+ }
784
+ })
809
785
  }
810
786
 
811
787
  // this.conversationAvatar = setConversationAvatar(
@@ -924,81 +900,71 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
924
900
  let subscription: any
925
901
  let subscriptionKey: string
926
902
 
927
- subscriptionKey = 'BSConversationsChanged'
928
- subscription = this.subscriptions.find(
929
- (item) => item.key === subscriptionKey,
930
- )
931
- if (!subscription) {
932
- subscription = this.conversationsHandlerService.conversationChanged.subscribe(
933
- (data: ConversationModel) => {
934
- this.logger.log('[CONVS-DETAIL] subscribe BSConversationsChanged data ', data, ' this.loggedUser.uid:', this.loggedUser.uid)
935
-
936
- if (data && data.sender !== this.loggedUser.uid) {
937
- this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange data sender ', data.sender)
938
- this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange this.loggedUser.uid ', this.loggedUser.uid)
939
- this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange is_new ', data.is_new)
940
- this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange showButtonToBottom ', this.showButtonToBottom)
941
- // UPDATE THE CONVERSATION TO 'READ' IF IT IS ME WHO WRITES THE LAST MESSAGE OF THE CONVERSATION
942
- // AND IF THE POSITION OF THE SCROLL IS AT THE END
943
- if (!this.showButtonToBottom && data.is_new) {
944
- // ARE AT THE END
945
- this.updateConversationBadge()
946
- }
947
- }
948
- },
949
- )
950
- const subscribe = { key: subscriptionKey, value: subscription }
951
- this.subscriptions.push(subscribe)
952
- }
903
+ // subscriptionKey = 'BSConversationsChanged'
904
+ // subscription = this.subscriptions.find((item) => item.key === subscriptionKey)
905
+ // if (!subscription) {
906
+ // subscription = this.conversationsHandlerService.conversationChanged.subscribe((data: ConversationModel) => {
907
+ // this.logger.log('[CONVS-DETAIL] subscribe BSConversationsChanged data ', data, ' this.loggedUser.uid:', this.loggedUser.uid)
908
+
909
+ // if (data && data.sender !== this.loggedUser.uid) {
910
+ // this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange data sender ', data.sender)
911
+ // this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange this.loggedUser.uid ', this.loggedUser.uid)
912
+ // this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange is_new ', data.is_new)
913
+ // this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange showButtonToBottom ', this.showButtonToBottom)
914
+ // // UPDATE THE CONVERSATION TO 'READ' IF IT IS ME WHO WRITES THE LAST MESSAGE OF THE CONVERSATION
915
+ // // AND IF THE POSITION OF THE SCROLL IS AT THE END
916
+ // if (!this.showButtonToBottom && data.is_new) {
917
+ // // ARE AT THE END
918
+ // this.updateConversationBadge()
919
+ // }
920
+ // if(data.uid === this.conversationWith){
921
+ // this.conversationAvatar = setConversationAvatar(
922
+ // data.conversation_with,
923
+ // data.conversation_with_fullname,
924
+ // data.channel_type,
925
+ // )
926
+ // }
927
+
928
+ // }
929
+ // })
930
+ // const subscribe = { key: subscriptionKey, value: subscription }
931
+ // this.subscriptions.push(subscribe)
932
+ // }
953
933
 
954
934
  subscriptionKey = 'messageAdded'
955
- subscription = this.subscriptions.find(
956
- (item) => item.key === subscriptionKey,
957
- )
935
+ subscription = this.subscriptions.find((item) => item.key === subscriptionKey)
958
936
  if (!subscription) {
959
937
  this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - conversationHandlerService', this.conversationHandlerService)
960
- subscription = this.conversationHandlerService.messageAdded.subscribe(
961
- (msg: any) => {
962
- this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - msg ', msg)
963
- if (msg) {
964
- that.newMessageAdded(msg)
965
- }
966
- },
967
- )
938
+ subscription = this.conversationHandlerService.messageAdded.subscribe((msg: any) => {
939
+ this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - msg ', msg)
940
+ if (msg) {
941
+ that.newMessageAdded(msg)
942
+ // this.setHeaderContent()
943
+ }
944
+ })
968
945
  const subscribe = { key: subscriptionKey, value: subscription }
969
946
  this.subscriptions.push(subscribe)
970
947
  }
971
948
 
972
949
  // IS USED ?
973
950
  subscriptionKey = 'messageChanged'
974
- subscription = this.subscriptions.find(
975
- (item) => item.key === subscriptionKey,
976
- )
951
+ subscription = this.subscriptions.find((item) => item.key === subscriptionKey)
977
952
  if (!subscription) {
978
953
  this.logger.log('[CONVS-DETAIL] subscribe to messageChanged')
979
- subscription = this.conversationHandlerService.messageChanged.subscribe(
980
- (msg: any) => {
981
- this.logger.log(
982
- '[CONVS-DETAIL] subscribe to messageChanged - msg ',
983
- msg,
984
- )
985
- },
986
- )
954
+ subscription = this.conversationHandlerService.messageChanged.subscribe((msg: any) => {
955
+ this.logger.log('[CONVS-DETAIL] subscribe to messageChanged - msg ', msg)
956
+ })
987
957
  const subscribe = { key: subscriptionKey, value: subscription }
988
958
  this.subscriptions.push(subscribe)
989
959
  }
990
960
 
991
961
  subscriptionKey = 'messageRemoved'
992
- subscription = this.subscriptions.find(
993
- (item) => item.key === subscriptionKey,
994
- )
962
+ subscription = this.subscriptions.find((item) => item.key === subscriptionKey)
995
963
  if (!subscription) {
996
964
  this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved')
997
- subscription = this.conversationHandlerService.messageRemoved.subscribe(
998
- (messageId: any) => {
999
- this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved - messageId ', messageId)
1000
- },
1001
- )
965
+ subscription = this.conversationHandlerService.messageRemoved.subscribe((messageId: any) => {
966
+ this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved - messageId ', messageId)
967
+ })
1002
968
  const subscribe = { key: subscriptionKey, value: subscription }
1003
969
  this.subscriptions.push(subscribe)
1004
970
  }
@@ -1008,22 +974,15 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1008
974
  // if (!subscription) {
1009
975
  // subscription =
1010
976
  if (this.conversationWith.startsWith('group-')) {
1011
- this.groupService
1012
- .onGroupChange(this.conversationWith)
1013
- .pipe(takeUntil(this.unsubscribe$))
1014
- .subscribe(
1015
- (groupDetail: any) => {
1016
- this.groupDetail = groupDetail
1017
- this.logger.log('[CONVS-DETAIL] subscribe to onGroupChange - groupDetail ', this.groupDetail)
1018
- },
1019
- (error) => {
1020
- this.logger.error('[CONVS-DETAIL] subscribe to onGroupChange - ERROR ', error)
1021
- },
1022
- () => {
1023
- this.logger.log('[CONVS-DETAIL] subscribe to onGroupChange /* COMPLETE */')
1024
- this.groupDetail = null
1025
- },
1026
- )
977
+ this.groupService.onGroupChange(this.conversationWith).pipe(takeUntil(this.unsubscribe$)).subscribe((groupDetail: any) => {
978
+ this.groupDetail = groupDetail
979
+ this.logger.log('[CONVS-DETAIL] subscribe to onGroupChange - groupDetail ', this.groupDetail)
980
+ }, (error) => {
981
+ this.logger.error('[CONVS-DETAIL] subscribe to onGroupChange - ERROR ', error)
982
+ }, () => {
983
+ this.logger.log('[CONVS-DETAIL] subscribe to onGroupChange /* COMPLETE */')
984
+ this.groupDetail = null
985
+ })
1027
986
  }
1028
987
  // const subscribe = { key: subscriptionKey, value: subscription };
1029
988
  // this.subscriptions.push(subscribe);
@@ -1095,22 +1054,10 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1095
1054
  }
1096
1055
 
1097
1056
  updateConversationBadge() {
1098
- if (
1099
- this.conversationWith &&
1100
- this.conversationsHandlerService &&
1101
- this.conv_type === 'active'
1102
- ) {
1103
- this.conversationsHandlerService.setConversationRead(
1104
- this.conversationWith,
1105
- )
1106
- } else if (
1107
- this.conversationWith &&
1108
- this.archivedConversationsHandlerService &&
1109
- this.conv_type === 'archived'
1110
- ) {
1111
- this.archivedConversationsHandlerService.setConversationRead(
1112
- this.conversationWith,
1113
- )
1057
+ if (this.conversationWith && this.conversationsHandlerService && this.conv_type === 'active') {
1058
+ this.conversationsHandlerService.setConversationRead(this.conversationWith)
1059
+ } else if (this.conversationWith && this.archivedConversationsHandlerService && this.conv_type === 'archived') {
1060
+ this.archivedConversationsHandlerService.setConversationRead(this.conversationWith)
1114
1061
  }
1115
1062
  }
1116
1063
 
@@ -1157,23 +1104,19 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1157
1104
  // }
1158
1105
  idCurrentUser = this.loggedUser.uid
1159
1106
 
1160
- if (
1161
- this.loggedUser.firstname &&
1162
- this.loggedUser.firstname !== undefined
1163
- ) {
1107
+ if (this.loggedUser.firstname && this.loggedUser.firstname !== undefined) {
1164
1108
  userFullname = this.loggedUser.firstname
1165
1109
  }
1166
- this.typingService.setTyping(
1167
- this.conversationWith,
1168
- message,
1169
- idCurrentUser,
1170
- userFullname,
1171
- )
1110
+
1111
+ /** DO NOT SET TYPING if message is empty */
1112
+ if (message !== '') {
1113
+ this.typingService.setTyping(this.conversationWith, message, idCurrentUser, userFullname)
1114
+ }
1172
1115
 
1173
1116
  // ----------------------------------------------------------
1174
1117
  // DISPLAY CANNED RESPONSES if message.lastIndexOf("/")
1175
1118
  // ----------------------------------------------------------
1176
- if (this.areVisibleCAR && this.support_mode === true) {
1119
+ if (this.areVisibleCAR && this.supportMode === true) {
1177
1120
  setTimeout(() => {
1178
1121
  if (this.conversationWith.startsWith('support-group')) {
1179
1122
  const pos = message.lastIndexOf('/')
@@ -1291,15 +1234,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1291
1234
 
1292
1235
  const conversationWith_segments = conversationWith.split('-')
1293
1236
  // Removes the last element of the array if is = to the separator
1294
- if (
1295
- conversationWith_segments[conversationWith_segments.length - 1] === ''
1296
- ) {
1237
+ if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
1297
1238
  conversationWith_segments.pop()
1298
1239
  }
1299
1240
 
1300
1241
  if (conversationWith_segments.length === 4) {
1301
- const lastArrayElement =
1302
- conversationWith_segments[conversationWith_segments.length - 1]
1242
+ const lastArrayElement = conversationWith_segments[conversationWith_segments.length - 1]
1303
1243
  this.logger.log('[CONVS-DETAIL] - lastArrayElement ', lastArrayElement)
1304
1244
  this.logger.log('[CONVS-DETAIL] - lastArrayElement length', lastArrayElement.length)
1305
1245
  if (lastArrayElement.length !== 32) {
@@ -1313,7 +1253,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1313
1253
  if (conversationWith_segments.length === 4) {
1314
1254
  projectId = conversationWith_segments[2]
1315
1255
  this.logger.log('[CONVS-DETAIL] - loadTagsCanned projectId ', projectId)
1316
-
1317
1256
  this.getAndShowCannedResponses(strSearch, projectId)
1318
1257
  } else {
1319
1258
  this.getProjectIdByConversationWith(strSearch, this.conversationWith)
@@ -1323,56 +1262,41 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1323
1262
  getProjectIdByConversationWith(strSearch, conversationWith: string) {
1324
1263
  const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1325
1264
 
1326
- this.tiledeskService
1327
- .getProjectIdByConvRecipient(tiledeskToken, conversationWith)
1328
- .subscribe(
1329
- (res) => {
1330
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
1331
- if (res) {
1332
- const projectId = res.id_project
1333
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
1334
- if (projectId) {
1335
- this.getAndShowCannedResponses(strSearch, projectId)
1336
- }
1337
- }
1338
- },
1339
- (error) => {
1340
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
1341
- },
1342
- () => {
1343
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
1344
- },
1345
- )
1265
+ this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
1266
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
1267
+ if (res) {
1268
+ const projectId = res.id_project
1269
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
1270
+ if (projectId) {
1271
+ this.getAndShowCannedResponses(strSearch, projectId)
1272
+ }
1273
+ }
1274
+ }, (error) => {
1275
+ this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
1276
+ }, () => {
1277
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
1278
+ })
1346
1279
  }
1347
1280
 
1348
1281
  getAndShowCannedResponses(strSearch, projectId) {
1349
1282
  const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1350
- this.logger.log(
1351
- '[CONVS-DETAIL] - loadTagsCanned tagsCanned.length',
1352
- this.tagsCanned.length,
1353
- )
1283
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned tagsCanned.length', this.tagsCanned.length)
1354
1284
  //if(this.tagsCanned.length <= 0 ){
1355
1285
  this.tagsCanned = []
1356
- this.cannedResponsesService
1357
- .getCannedResponses(tiledeskToken, projectId)
1358
- .subscribe(
1359
- (res) => {
1360
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses RES', res)
1361
-
1362
- this.tagsCanned = res
1363
- this.tagsCannedCount = res.length
1364
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses tagsCannedCount', this.tagsCannedCount)
1365
- if (this.HIDE_CANNED_RESPONSES === false) {
1366
- this.showTagsCanned(strSearch)
1367
- }
1368
- },
1369
- (error) => {
1370
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned getCannedResponses - ERROR ', error)
1371
- },
1372
- () => {
1373
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses * COMPLETE *')
1374
- },
1375
- )
1286
+ this.cannedResponsesService.getCannedResponses(tiledeskToken, projectId).subscribe((res) => {
1287
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses RES', res)
1288
+
1289
+ this.tagsCanned = res
1290
+ this.tagsCannedCount = res.length
1291
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses tagsCannedCount', this.tagsCannedCount)
1292
+ if (this.HIDE_CANNED_RESPONSES === false) {
1293
+ this.showTagsCanned(strSearch)
1294
+ }
1295
+ }, (error) => {
1296
+ this.logger.error('[CONVS-DETAIL] - loadTagsCanned getCannedResponses - ERROR ', error)
1297
+ }, () => {
1298
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses * COMPLETE *')
1299
+ })
1376
1300
  }
1377
1301
 
1378
1302
  showTagsCanned(strSearch) {
@@ -1396,7 +1320,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1396
1320
  let title = htmlEntities(this.tagsCannedFilter[i].title)
1397
1321
  // this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + this.tagsCannedFilter[i].title.toString().replace(strSearch, strReplace.trim()) + '</div>' + textCanned + '</div>'
1398
1322
  this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + title.toString().replace(strSearch, strReplace.trim()) + '</div>' + textCanned + '</div>'
1399
-
1323
+
1400
1324
  }
1401
1325
  if (this.tagsCannedCount === 0) {
1402
1326
  // const button = this.renderer.createElement('button');
@@ -1406,7 +1330,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1406
1330
  // this.renderer.listen(button, 'click', () => { alert('hi'); });
1407
1331
  // let nocanned = {}
1408
1332
  // if (this.USER_ROLE !== 'agent') {
1409
- const nocanned = {
1333
+ const nocanned = {
1410
1334
  // "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div><div class='cannedText'>" + this.translationMap.get('TO_CREATE_THEM_GO_TO_THE_PROJECT') + '</div></div>'
1411
1335
  // <div class='cannedText no-canned-available-text'>" + this.translationMap.get('AddNewCannedResponse') + '</div>
1412
1336
  title:
@@ -1459,7 +1383,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1459
1383
  // console.log('[CONVS-DETAIL] replaceTagInMessage canned ', canned)
1460
1384
  // console.log('[CONVS-DETAIL] replaceTagInMessage canned title', canned.title)
1461
1385
  // console.log('[CONVS-DETAIL] replaceTagInMessage canned contains nocannedTitle', canned.title.includes('nocannedTitle'))
1462
-
1386
+
1463
1387
  const elTextArea = this.rowTextArea['el']
1464
1388
  const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1465
1389