@chat21/chat21-ionic 3.0.64 → 3.0.65

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 (52) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/deploy_amazon_beta.sh +0 -0
  3. package/deploy_amazon_prod.sh +1 -0
  4. package/deploy_pre.sh +39 -6
  5. package/package.json +8 -3
  6. package/publiccode.yml +110 -0
  7. package/src/app/app.component.ts +40 -66
  8. package/src/app/app.module.ts +1 -0
  9. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +2 -2
  10. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +0 -1
  11. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +2 -39
  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.ts +1 -11
  14. package/src/app/chatlib/conversation-detail/message/html/html.component.html +1 -0
  15. package/src/app/chatlib/conversation-detail/message/html/html.component.scss +79 -0
  16. package/src/app/chatlib/conversation-detail/message/html/html.component.spec.ts +25 -0
  17. package/src/app/chatlib/conversation-detail/message/html/html.component.ts +33 -0
  18. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +1 -1
  19. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +18 -30
  20. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.ts +0 -1
  21. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +7 -5
  22. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +21 -0
  23. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component_2.html +116 -0
  24. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +2 -2
  25. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +2 -2
  26. package/src/app/components/project-item/project-item.component.ts +5 -0
  27. package/src/app/components/sidebar/sidebar.component.ts +8 -15
  28. package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +12 -23
  29. package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +3 -0
  30. package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +88 -136
  31. package/src/app/directives/safe-html.pipe.ts +2 -2
  32. package/src/app/directives/truncate.pipe.spec.ts +8 -0
  33. package/src/app/directives/truncate.pipe.ts +15 -0
  34. package/src/app/pages/authentication/login/login.page.ts +0 -1
  35. package/src/app/pages/conversation-detail/conversation-detail.module.ts +3 -2
  36. package/src/app/pages/conversation-detail/conversation-detail.page.html +4 -2
  37. package/src/app/pages/conversation-detail/conversation-detail.page.ts +56 -71
  38. package/src/app/pages/conversations-list/conversations-list.page.html +21 -12
  39. package/src/app/pages/conversations-list/conversations-list.page.ts +129 -367
  40. package/src/app/pages/loader-preview/loader-preview.module.ts +1 -2
  41. package/src/app/shared/shared.module.ts +4 -0
  42. package/src/assets/i18n/ar.json +266 -0
  43. package/src/assets/js/chat21client.js +58 -60
  44. package/src/chat21-core/models/conversation.ts +2 -2
  45. package/src/chat21-core/providers/abstract/conversations-handler.service.ts +1 -1
  46. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +26 -21
  47. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +78 -23
  48. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +16 -13
  49. package/src/chat21-core/utils/constants.ts +1 -1
  50. package/src/chat21-core/utils/utils-message.ts +2 -3
  51. package/src/global.scss +2 -2
  52. package/deploy_prod.sh +0 -11
@@ -1,3 +1,4 @@
1
+ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
1
2
  import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service'
2
3
  import { Component, OnInit, ViewChild } from '@angular/core'
3
4
  import { IonContent, ModalController } from '@ionic/angular'
@@ -17,6 +18,8 @@ import {
17
18
  closeModal,
18
19
  convertMessage,
19
20
  isGroup,
21
+ searchIndexInArrayForUid,
22
+ compareValues,
20
23
  } from '../../../chat21-core/utils/utils'
21
24
 
22
25
  import { EventsService } from '../../services/events-service'
@@ -118,6 +121,7 @@ export class ConversationListPage implements OnInit {
118
121
  public appConfigProvider: AppConfigProvider,
119
122
  public platform: Platform,
120
123
  private networkService: NetworkService,
124
+ private appStorageService: AppStorageService
121
125
  ) {
122
126
  this.listenToAppCompConvsLengthOnInitConvs()
123
127
  this.listenToLogoutEvent()
@@ -138,25 +142,14 @@ export class ConversationListPage implements OnInit {
138
142
  this.setUidConvSelected(IDConv, 'active')
139
143
  }
140
144
  if (!IDConv) {
141
- this.logger.log(
142
- '[CONVS-LIST-PAGE] - listen To convid:haschanged - is the page without conv select',
143
- )
145
+ this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - is the page without conv select',)
144
146
 
145
147
  const chatTabCount = +localStorage.getItem('tabCount')
146
- this.logger.log(
147
- '[CONVS-LIST-PAGE] - listen To convid:haschanged - chatTabCount ',
148
- chatTabCount,
149
- )
148
+ this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - chatTabCount ',chatTabCount,)
150
149
  if (chatTabCount && chatTabCount > 0) {
151
- this.logger.log(
152
- '[CONVS-LIST-PAGE] - listen To convid:haschanged - the chat is already open ',
153
- chatTabCount,
154
- )
150
+ this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - the chat is already open ',chatTabCount)
155
151
  if (checkPlatformIsMobile()) {
156
- this.logger.log(
157
- '[CONVS-LIST-PAGE] - the chat is in mobile mode ',
158
- checkPlatformIsMobile(),
159
- )
152
+ this.logger.log('[CONVS-LIST-PAGE] - the chat is in mobile mode ',checkPlatformIsMobile())
160
153
  this.events.publish('noparams:mobile', true)
161
154
  }
162
155
  }
@@ -179,46 +172,7 @@ export class ConversationListPage implements OnInit {
179
172
  ngOnInit() {
180
173
  this.watchToConnectionStatus()
181
174
  this.getAppConfigToHideDiplayBtns()
182
-
183
- // const currentUrl = this.router.url;
184
- // this.logger.log('[CONVS-LIST-PAGE] current_url ngOnInit ', currentUrl);
185
- // this.route.queryParams.subscribe(params => {
186
- // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params', params);
187
- // if (params && params.convId) {
188
- // console.log('[CONVS-LIST-PAGE] ngOnInit params convId:', params.convId);
189
-
190
- // const conversationSelected = this.conversations.find(item => item.uid === params.convId);
191
- // if (conversationSelected) {
192
- // this.conversationSelected = conversationSelected;
193
- // console.log('[CONVS-LIST-PAGE] ngOnInit params convselected - conversationSelected: ', this.conversationSelected);
194
- // setTimeout(() => {
195
- // // this.navigateByUrl('active', params.convId)
196
- // }, 0);
197
- // }
198
-
199
- // } else {
200
- // console.log('[CONVS-LIST-PAGE] ngOnInit params No convId Params ');
201
- // }
202
- // if (params && params.contact_id && params.contact_fullname) {
203
- // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params contact_id:', params.contact_id, 'contact_fullname ', params.contact_fullname);
204
- // setTimeout(() => {
205
- // this.router.navigateByUrl('conversation-detail/' + params.contact_id + '/' + params.contact_fullname + '/new');
206
- // }, 0);
207
- // this.uidConvSelected = params.contact_id
208
- // } else {
209
- // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params No contact_id and contact_fullname Params ');
210
- // }
211
-
212
- // if (params && params.conversation_detail) {
213
- // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params conversation_detail:', params.conversation_detail);
214
- // setTimeout(() => {
215
- // this.router.navigateByUrl('conversation-detail/');
216
- // }, 0);
217
- // } else {
218
- // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params No conversation_detail Params ');
219
- // }
220
-
221
- // });
175
+
222
176
  }
223
177
 
224
178
  ngOnChanges() {
@@ -230,15 +184,6 @@ export class ConversationListPage implements OnInit {
230
184
  this.logger.log('[CONVS-LIST-PAGE] getConversationListHeight scrollbar2element', scrollbar2element)
231
185
  }
232
186
 
233
- // this.support_mode = null
234
- // if( this.appConfigProvider.getConfig().supportMode === true || this.appConfigProvider.getConfig().supportMode === 'true') {
235
- // this.support_mode = true
236
- // } else if ( this.appConfigProvider.getConfig().supportMode === false || this.appConfigProvider.getConfig().supportMode === 'false') {
237
- // this.support_mode = false
238
- // } else if ( !this.appConfigProvider.getConfig().supportMode ) {
239
- // this.support_mode = false
240
- // }
241
-
242
187
  getAppConfigToHideDiplayBtns() {
243
188
  const appConfig = this.appConfigProvider.getConfig()
244
189
  // console.log('[CONVS-LIST-PAGE] - appConfig ', appConfig)
@@ -266,7 +211,6 @@ export class ConversationListPage implements OnInit {
266
211
  this.writeto_btn = false;
267
212
  this.logger.log('[CONVS-LIST-PAGE] getAppConfigToHideDiplayBtns writeto_btn ', this.writeto_btn)
268
213
  }
269
- // console.log('[ION-LIST-CONVS-COMP] - supportMode ', this.supportMode)
270
214
  }
271
215
 
272
216
  watchToConnectionStatus() {
@@ -285,12 +229,9 @@ export class ConversationListPage implements OnInit {
285
229
 
286
230
  ionViewWillEnter() {
287
231
  this.logger.log('Called ionViewDidEnter')
288
- this.logger.log(
289
- '[CONVS-LIST-PAGE] ionViewWillEnter uidConvSelected',
290
- this.uidConvSelected,
291
- )
232
+ this.logger.log('[CONVS-LIST-PAGE] ionViewWillEnter uidConvSelected',this.uidConvSelected )
292
233
  this.listnerStart()
293
-
234
+ // this.conversations = this.manageStoredConversations()
294
235
  // exit from app with hardware back button
295
236
  this.subscription = this.platform.backButton.subscribe(() => {
296
237
  navigator['app'].exitApp()
@@ -313,29 +254,18 @@ export class ConversationListPage implements OnInit {
313
254
  openUnsevedConversationIframe(event) {
314
255
  this.logger.log('[CONVS-LIST-PAGE] openUnsevedConversationIframe ', event)
315
256
  this.hasClickedOpenUnservedConvIframe = true
316
- this.logger.log(
317
- '[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME',
318
- this.hasClickedOpenUnservedConvIframe,
319
- )
257
+ this.logger.log('[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME',this.hasClickedOpenUnservedConvIframe )
320
258
  const DASHBOARD_BASE_URL = this.appConfigProvider.getConfig().dashboardUrl
321
259
  // http://localhost:4204/#/projects-for-panel
322
260
  this.PROJECTS_FOR_PANEL_URL = DASHBOARD_BASE_URL + '#/projects-for-panel'
323
- this.UNASSIGNED_CONVS_URL =
324
- DASHBOARD_BASE_URL +
325
- '#/project/' +
326
- this.lastProjectId +
327
- '/unserved-request-for-panel'
261
+ this.UNASSIGNED_CONVS_URL = DASHBOARD_BASE_URL + '#/project/' + this.lastProjectId + '/unserved-request-for-panel'
328
262
 
329
263
  if (event === 'pinbtn') {
330
264
  this.IFRAME_URL = this.PROJECTS_FOR_PANEL_URL
331
265
  } else {
332
266
  this.IFRAME_URL = this.UNASSIGNED_CONVS_URL
333
267
  }
334
-
335
- this.logger.log(
336
- '[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME > UNASSIGNED CONVS URL',
337
- this.UNASSIGNED_CONVS_URL,
338
- )
268
+ this.logger.log('[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME > UNASSIGNED CONVS URL',this.UNASSIGNED_CONVS_URL )
339
269
  this.openUnassignedConversations(this.IFRAME_URL, event)
340
270
  }
341
271
 
@@ -360,10 +290,7 @@ export class ConversationListPage implements OnInit {
360
290
  try {
361
291
  closeModal(this.modalController)
362
292
  } catch (err) {
363
- this.logger.error(
364
- '[CONVS-LIST-PAGE] closeContactsDirectory -> error:',
365
- err,
366
- )
293
+ this.logger.error( '[CONVS-LIST-PAGE] closeContactsDirectory -> error:', err)
367
294
  }
368
295
  }
369
296
 
@@ -372,46 +299,23 @@ export class ConversationListPage implements OnInit {
372
299
  const that = this
373
300
  if (navigator && navigator.serviceWorker) {
374
301
  navigator.serviceWorker.addEventListener('message', function (event) {
375
- that.logger.log(
376
- '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data: ',
377
- event.data,
378
- )
379
- that.logger.log(
380
- '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data: ',
381
- event.data['data'],
382
- )
383
- that.logger.log(
384
- '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data typeof: ',
385
- typeof event.data['data'],
386
- )
302
+ that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data: ', event.data)
303
+ that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data: ', event.data['data'] )
304
+ that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data typeof: ', typeof event.data['data'] )
387
305
  let uidConvSelected = ''
388
306
  if (event.data && event.data['conversWith']) {
389
307
  uidConvSelected = event.data['conversWith']
390
308
  } else {
391
- that.logger.log(
392
- '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - DIFFERENT MSG',
393
- )
309
+ that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - DIFFERENT MSG',)
394
310
  return
395
311
  }
396
312
 
397
- that.logger.log(
398
- '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event dataObjct uidConvSelected: ',
399
- uidConvSelected,
400
- )
401
- that.logger.log(
402
- '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker that.conversations: ',
403
- that.conversations,
404
- )
405
- const conversationSelected = that.conversations.find(
406
- (item) => item.uid === uidConvSelected,
407
- )
313
+ that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event dataObjct uidConvSelected: ', uidConvSelected )
314
+ that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker that.conversations: ', that.conversations)
315
+ const conversationSelected = that.conversations.find((item) => item.uid === uidConvSelected)
408
316
  if (conversationSelected) {
409
317
  that.conversationSelected = conversationSelected
410
- that.logger.log(
411
- '[CONVS-LIST-PAGE] listenToNotificationCLick- Received a message from service worker event conversationSelected: ',
412
- that.conversationSelected,
413
- )
414
-
318
+ that.logger.log('[CONVS-LIST-PAGE] listenToNotificationCLick- Received a message from service worker event conversationSelected: ', that.conversationSelected )
415
319
  that.navigateByUrl('active', uidConvSelected)
416
320
  }
417
321
  })
@@ -420,68 +324,61 @@ export class ConversationListPage implements OnInit {
420
324
 
421
325
  private listnerStart() {
422
326
  const that = this
423
- this.chatManager.BSStart.pipe(takeUntil(that.unsubscribe$)).subscribe(
424
- (data: any) => {
425
- this.logger.log(
426
- '[CONVS-LIST-PAGE] - BSStart SUBSCR DATA - Current user *****',
427
- data,
428
- )
327
+ this.chatManager.BSStart.pipe(takeUntil(that.unsubscribe$)).subscribe((data: any) => {
328
+ this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR DATA - Current user *****', data)
429
329
  if (data) {
430
330
  that.initialize()
431
331
  }
432
- },
433
- (error) => {
332
+ },(error) => {
434
333
  this.logger.error('[CONVS-LIST-PAGE] - BSStart SUBSCR - ERROR: ', error)
435
- },
436
- () => {
334
+ },() => {
437
335
  this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR * COMPLETE *')
438
- },
439
- )
336
+ })
440
337
  }
441
338
 
442
339
  // ------------------------------------------------------------------ //
443
340
  // Init convrsation handler
444
341
  // ------------------------------------------------------------------ //
445
342
  initConversationsHandler() {
343
+ // this.conversations = this.manageStoredConversations()
446
344
  this.conversations = this.conversationsHandlerService.conversations
447
- this.logger.log('[CONVS-LIST-PAGE] - CONVERSATIONS ', this.conversations)
345
+ this.logger.log('[CONVS-LIST-PAGE] - CONVERSATIONS ', this.conversations.length, this.conversations)
448
346
  // save conversationHandler in chatManager
449
347
  this.chatManager.setConversationsHandler(this.conversationsHandlerService)
450
348
  this.showPlaceholder = false
451
349
  }
452
350
 
351
+ private manageStoredConversations(): ConversationModel[] {
352
+ let conversationsStored = []
353
+ if(this.appStorageService.getItem('conversations')){
354
+ conversationsStored = JSON.parse(this.appStorageService.getItem('conversations'))
355
+ if(conversationsStored && conversationsStored.length > 0) {
356
+ // this.conversationsHandlerService.conversations = conversationsStored
357
+ this.logger.log('[CONVS-LIST-PAGE] retrive conversations from storage --> ', conversationsStored.length)
358
+ this.events.publish('appcompSubscribeToConvs:loadingIsActive', false);
359
+ }
360
+ }
361
+ return conversationsStored
362
+ }
363
+
453
364
  initArchivedConversationsHandler() {
454
365
  const keysConversation = ['CLOSED', 'Resolve']
455
- this.translationMapConversation = this.translateService.translateLanguage(
456
- keysConversation,
457
- )
366
+ this.translationMapConversation = this.translateService.translateLanguage( keysConversation )
458
367
 
459
368
  this.archivedConversationsHandlerService.subscribeToConversations(() => {
460
- this.logger.log(
461
- '[CONVS-LIST-PAGE]-CONVS - conversations archived length ',
462
- this.archivedConversations.length,
463
- )
369
+ this.logger.log('[CONVS-LIST-PAGE]-CONVS - conversations archived length ',this.archivedConversations.length)
464
370
  })
465
371
 
466
372
  this.archivedConversations = this.archivedConversationsHandlerService.archivedConversations
467
- this.logger.log(
468
- '[CONVS-LIST-PAGE] archived conversation',
469
- this.archivedConversations,
470
- )
373
+ this.logger.log('[CONVS-LIST-PAGE] archived conversation',this.archivedConversations )
471
374
 
472
375
  // save archivedConversationsHandlerService in chatManager
473
376
  this.chatManager.setArchivedConversationsHandler(
474
377
  this.archivedConversationsHandlerService,
475
378
  )
476
379
 
477
- this.logger.log(
478
- '[CONVS-LIST-PAGE]-CONVS SubscribeToConversations - conversations archived length ',
479
- this.archivedConversations.length,
480
- )
481
- if (
482
- !this.archivedConversations ||
483
- this.archivedConversations.length === 0
484
- ) {
380
+ this.logger.log('[CONVS-LIST-PAGE]-CONVS SubscribeToConversations - conversations archived length ', this.archivedConversations.length )
381
+ if (!this.archivedConversations || this.archivedConversations.length === 0 ) {
485
382
  this.loadingIsActive = false
486
383
  }
487
384
  }
@@ -494,26 +391,17 @@ export class ConversationListPage implements OnInit {
494
391
  // - for the direct conversation
495
392
  // ----------------------------------------------------------------------------------------------------
496
393
  listenToAppCompConvsLengthOnInitConvs() {
497
- this.events.subscribe(
498
- 'appcompSubscribeToConvs:loadingIsActive',
499
- (loadingIsActive) => {
500
- this.logger.log(
501
- '[CONVS-LIST-PAGE]-CONVS loadingIsActive',
502
- loadingIsActive,
503
- )
504
- if (loadingIsActive === false) {
505
- this.loadingIsActive = false
506
- }
507
- },
508
- )
394
+ this.events.subscribe( 'appcompSubscribeToConvs:loadingIsActive', (loadingIsActive) => {
395
+ this.logger.log( '[CONVS-LIST-PAGE]-CONVS loadingIsActive', loadingIsActive)
396
+ if (loadingIsActive === false) {
397
+ this.loadingIsActive = false
398
+ }
399
+ })
509
400
  }
510
401
 
511
402
  listenGoOnline() {
512
403
  this.events.subscribe('go:online', (goonline) => {
513
- this.logger.info(
514
- '[CONVS-LIST-PAGE] - listen To go:online - goonline',
515
- goonline,
516
- )
404
+ this.logger.info('[CONVS-LIST-PAGE] - listen To go:online - goonline',goonline)
517
405
  // this.events.unsubscribe('profileInfoButtonClick:logout')
518
406
  if (goonline === true) {
519
407
  this.displayNewConvsItem = true
@@ -523,10 +411,7 @@ export class ConversationListPage implements OnInit {
523
411
 
524
412
  listenGoOffline() {
525
413
  this.events.subscribe('go:offline', (offline) => {
526
- this.logger.info(
527
- '[CONVS-LIST-PAGE] - listen To go:offline - offline',
528
- offline,
529
- )
414
+ this.logger.info('[CONVS-LIST-PAGE] - listen To go:offline - offline',offline)
530
415
  // this.events.unsubscribe('profileInfoButtonClick:logout')
531
416
  if (offline === true) {
532
417
  this.displayNewConvsItem = false
@@ -535,31 +420,19 @@ export class ConversationListPage implements OnInit {
535
420
  }
536
421
 
537
422
  listenToLogoutEvent() {
538
- this.events.subscribe(
539
- 'profileInfoButtonClick:logout',
540
- (hasclickedlogout) => {
541
- this.logger.info(
542
- '[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout',
543
- hasclickedlogout,
544
- )
423
+ this.events.subscribe('profileInfoButtonClick:logout', (hasclickedlogout) => {
424
+ this.logger.info('[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout',hasclickedlogout)
545
425
 
546
426
  this.conversations = []
547
427
  this.conversationsHandlerService.conversations = []
548
428
  this.uidConvSelected = null
549
429
 
550
- this.logger.log(
551
- '[CONVS-LIST-PAGE] - listenToLogoutEvent - CONVERSATIONS ',
552
- this.conversations,
553
- )
554
- this.logger.log(
555
- '[CONVS-LIST-PAGE] - listenToLogoutEvent - uidConvSelected ',
556
- this.uidConvSelected,
557
- )
430
+ this.logger.log('[CONVS-LIST-PAGE] - listenToLogoutEvent - CONVERSATIONS ', this.conversations )
431
+ this.logger.log('[CONVS-LIST-PAGE] - listenToLogoutEvent - uidConvSelected ', this.uidConvSelected )
558
432
  if (hasclickedlogout === true) {
559
433
  this.loadingIsActive = false
560
434
  }
561
- },
562
- )
435
+ })
563
436
  }
564
437
 
565
438
  // ------------------------------------------------------------------
@@ -592,50 +465,36 @@ export class ConversationListPage implements OnInit {
592
465
  // this.readAllMessages(conversationId);
593
466
  // });
594
467
 
595
- this.conversationsHandlerService.conversationAdded.subscribe(
596
- (conversation: ConversationModel) => {
468
+ this.conversationsHandlerService.conversationAdded.subscribe((conversation: ConversationModel) => {
597
469
  // this.logger.log('[CONVS-LIST-PAGE] ***** conversationsAdded *****', conversation);
598
470
  // that.conversationsChanged(conversations);
599
471
  if (conversation) {
600
472
  this.onImageLoaded(conversation)
601
473
  this.onConversationLoaded(conversation)
602
474
  }
603
- },
604
- )
475
+ })
605
476
 
606
- this.conversationsHandlerService.conversationChanged.subscribe(
607
- (conversation: ConversationModel) => {
477
+ this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
608
478
  // this.logger.log('[CONVS-LIST-PAGE] ***** subscribeConversationChanged *****', conversation);
609
479
  // that.conversationsChanged(conversations)
610
480
  if (conversation) {
611
481
  this.onImageLoaded(conversation)
612
482
  this.onConversationLoaded(conversation)
613
483
  }
614
- },
615
- )
484
+ })
616
485
 
617
- this.conversationsHandlerService.conversationRemoved.subscribe(
618
- (conversation: ConversationModel) => {
619
- this.logger.log(
620
- '[CONVS-LIST-PAGE] ***** conversationsRemoved *****',
621
- conversation,
622
- )
623
- },
624
- )
486
+ this.conversationsHandlerService.conversationRemoved.subscribe((conversation: ConversationModel) => {
487
+ this.logger.log('[CONVS-LIST-PAGE] ***** conversationsRemoved *****',conversation)
488
+ })
625
489
 
626
- this.archivedConversationsHandlerService.archivedConversationAdded.subscribe(
627
- (conversation: ConversationModel) => {
628
- this.logger.log(
629
- '[CONVS-LIST-PAGE] ***** archivedConversationAdded *****',
630
- conversation,
631
- )
490
+ this.archivedConversationsHandlerService.archivedConversationAdded.subscribe((conversation: ConversationModel) => {
491
+ this.logger.log('[CONVS-LIST-PAGE] ***** archivedConversationAdded *****',conversation)
632
492
  // that.conversationsChanged(conversations);
633
493
  if (conversation) {
634
494
  this.onImageLoaded(conversation)
635
495
  this.onConversationLoaded(conversation)
636
496
  }
637
- },
638
- )
497
+ })
639
498
  }
640
499
 
641
500
  // ------------------------------------------------------------------------------------
@@ -644,14 +503,8 @@ export class ConversationListPage implements OnInit {
644
503
  subscribeLoggedUserLogout = () => {
645
504
  this.conversations = []
646
505
  this.uidConvSelected = null
647
- this.logger.log(
648
- '[CONVS-LIST-PAGE] - subscribeLoggedUserLogout conversations ',
649
- this.conversations,
650
- )
651
- this.logger.log(
652
- '[CONVS-LIST-PAGE] - subscribeLoggedUserLogout uidConvSelected ',
653
- this.uidConvSelected,
654
- )
506
+ this.logger.log('[CONVS-LIST-PAGE] - subscribeLoggedUserLogout conversations ',this.conversations)
507
+ this.logger.log('[CONVS-LIST-PAGE] - subscribeLoggedUserLogout uidConvSelected ',this.uidConvSelected)
655
508
  }
656
509
 
657
510
  // ------------------------------------------------------------------------------------
@@ -659,15 +512,10 @@ export class ConversationListPage implements OnInit {
659
512
  // ------------------------------------------------------------------------------------
660
513
  conversationsChanged = (conversations: ConversationModel[]) => {
661
514
  this.numberOpenConv = this.conversationsHandlerService.countIsNew()
662
- this.logger.log(
663
- '[CONVS-LIST-PAGE] - conversationsChanged - NUMB OF CONVERSATIONS: ',
664
- this.numberOpenConv,
665
- )
515
+ this.logger.log('[CONVS-LIST-PAGE] - conversationsChanged - NUMB OF CONVERSATIONS: ',this.numberOpenConv)
666
516
  // console.log('conversationsChanged »»»»»»»»» uidConvSelected', that.conversations[0], that.uidConvSelected);
667
517
  if (this.uidConvSelected && !this.conversationSelected) {
668
- const conversationSelected = this.conversations.find(
669
- (item) => item.uid === this.uidConvSelected,
670
- )
518
+ const conversationSelected = this.conversations.find((item) => item.uid === this.uidConvSelected)
671
519
  if (conversationSelected) {
672
520
  this.conversationSelected = conversationSelected
673
521
  this.setUidConvSelected(this.uidConvSelected)
@@ -684,26 +532,13 @@ export class ConversationListPage implements OnInit {
684
532
  // !!!!!! IS USED? ?????
685
533
  // ------------------------------
686
534
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
687
- this.logger.log(
688
- '[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl',
689
- user,
690
- type,
691
- )
535
+ this.logger.log('[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl',user, type)
692
536
  this.uidConvSelected = user.uid
693
- this.logger.log(
694
- '[CONVS-LIST-PAGE] ************** uidConvSelected ',
695
- this.uidConvSelected,
696
- )
537
+ this.logger.log('[CONVS-LIST-PAGE] ************** uidConvSelected ', this.uidConvSelected)
697
538
  // this.conversationsHandlerService.uidConvSelected = user.uid;
698
- const conversationSelected = this.conversations.find(
699
- (item) => item.uid === this.uidConvSelected,
700
- )
539
+ const conversationSelected = this.conversations.find( (item) => item.uid === this.uidConvSelected)
701
540
  if (conversationSelected) {
702
- this.logger.log(
703
- '[CONVS-LIST-PAGE] --> uidConvSelected: ',
704
- this.conversationSelected,
705
- this.uidConvSelected,
706
- )
541
+ this.logger.log('[CONVS-LIST-PAGE] --> uidConvSelected: ',this.conversationSelected, this.uidConvSelected)
707
542
  this.conversationSelected = conversationSelected
708
543
  }
709
544
  // this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
@@ -714,10 +549,7 @@ export class ConversationListPage implements OnInit {
714
549
  * evento richiamato quando si seleziona bottone profile-info-modal
715
550
  */
716
551
  subscribeProfileInfoButtonClicked = (event: string) => {
717
- this.logger.log(
718
- '[CONVS-LIST-PAGE] ************** subscribeProfileInfoButtonClicked: ',
719
- event,
720
- )
552
+ this.logger.log('[CONVS-LIST-PAGE] ************** subscribeProfileInfoButtonClicked: ', event)
721
553
  if (event === 'displayArchived') {
722
554
  this.initArchivedConversationsHandler()
723
555
  // this.openArchivedConversationsModal()
@@ -727,15 +559,11 @@ export class ConversationListPage implements OnInit {
727
559
  const keys = ['LABEL_ARCHIVED']
728
560
  // const keys = ['History'];
729
561
 
730
- this.headerTitle = this.translateService
731
- .translateLanguage(keys)
732
- .get(keys[0])
562
+ this.headerTitle = this.translateService.translateLanguage(keys).get(keys[0])
733
563
  } else if (event === 'displayContact') {
734
564
  this.conversationType = 'archived'
735
565
  const keys = ['LABEL_CONTACTS']
736
- this.headerTitle = this.translateService
737
- .translateLanguage(keys)
738
- .get(keys[0])
566
+ this.headerTitle = this.translateService.translateLanguage(keys).get(keys[0])
739
567
  }
740
568
  }
741
569
 
@@ -783,10 +611,7 @@ export class ConversationListPage implements OnInit {
783
611
  initialize() {
784
612
  const appconfig = this.appConfigProvider.getConfig()
785
613
  this.tenant = appconfig.firebaseConfig.tenant
786
- this.logger.log(
787
- '[CONVS-LIST-PAGE] - initialize -> firebaseConfig tenant ',
788
- this.tenant,
789
- )
614
+ this.logger.log('[CONVS-LIST-PAGE] - initialize -> firebaseConfig tenant ',this.tenant)
790
615
 
791
616
  if (this.tiledeskAuthService.getCurrentUser()) {
792
617
  this.loggedUserUid = this.tiledeskAuthService.getCurrentUser().uid
@@ -813,22 +638,18 @@ export class ConversationListPage implements OnInit {
813
638
  // It only works on BSStart.subscribe! it is useful or can be eliminated
814
639
  // --------------------------------------------------------
815
640
  initVariables() {
816
- this.logger.log(
817
- '[CONVS-LIST-PAGE] uidReciverFromUrl:: ' + this.uidReciverFromUrl,
818
- )
641
+ this.logger.log('[CONVS-LIST-PAGE] uidReciverFromUrl:: ' + this.uidReciverFromUrl)
819
642
  this.logger.log('[CONVS-LIST-PAGE] loggedUserUid:: ' + this.loggedUserUid)
820
643
  this.logger.log('[CONVS-LIST-PAGE] tenant:: ' + this.tenant)
821
644
  if (this.route.component['name'] !== 'ConversationListPage') {
822
645
  if (this.route && this.route.snapshot && this.route.snapshot.firstChild) {
823
646
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv')
647
+ const convType = this.route.snapshot.firstChild.paramMap.get('Convtype')
824
648
  this.logger.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv)
825
649
  if (IDConv) {
826
- this.setUidConvSelected(IDConv)
650
+ this.setUidConvSelected(IDConv, convType)
827
651
  } else {
828
- this.logger.log(
829
- '[CONVS-LIST-PAGE] conversationWith 2 (else): ',
830
- IDConv,
831
- )
652
+ this.logger.log('[CONVS-LIST-PAGE] conversationWith 2 (else): ',IDConv)
832
653
  }
833
654
  }
834
655
  }
@@ -846,12 +667,15 @@ export class ConversationListPage implements OnInit {
846
667
  let conversationSelected
847
668
  if (conversationType === 'active') {
848
669
  conversationSelected = this.conversations.find((item) => item.uid === this.uidConvSelected)
849
- } else if (conversationType === 'archived') { conversationSelected = this.archivedConversations.find((item) => item.uid === this.uidConvSelected) }
670
+ } else if (conversationType === 'archived') {
671
+ conversationSelected = this.archivedConversations.find((item) => item.uid === this.uidConvSelected)
672
+ }
850
673
  if (conversationSelected) {
851
- this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected,)
674
+ this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected)
852
675
  this.logger.log('[CONVS-LIST-PAGE] the conversation ', this.conversationSelected, ' has already been loaded')
853
676
  this.conversationSelected = conversationSelected
854
677
  this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected: ', this.conversationSelected)
678
+ conversationType === 'active'? this.conversationsHandlerService.uidConvSelected = conversationSelected.uid : this.archivedConversationsHandlerService.uidConvSelected = conversationSelected.uid
855
679
  }
856
680
  }
857
681
  }
@@ -860,10 +684,12 @@ export class ConversationListPage implements OnInit {
860
684
  this.logger.log('onConversationSelected conversation', conversation)
861
685
  if (conversation.archived) {
862
686
  this.navigateByUrl('archived', conversation.uid)
687
+ this.archivedConversationsHandlerService.uidConvSelected = conversation.uid
863
688
  this.logger.log('[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ', conversation.uid,
864
689
  )
865
690
  } else {
866
691
  this.navigateByUrl('active', conversation.uid)
692
+ this.conversationsHandlerService.uidConvSelected = conversation.uid
867
693
  this.logger.log('[CONVS-LIST-PAGE] onConversationSelected active conversation.uid ', conversation.uid)
868
694
  }
869
695
  }
@@ -882,9 +708,7 @@ export class ConversationListPage implements OnInit {
882
708
  conversation_with_fullname = conversation.recipient_fullname
883
709
  }
884
710
  if (!conversation_with.startsWith('support-group')) {
885
- conversation.image = this.imageRepoService.getImagePhotoUrl(
886
- conversation_with,
887
- )
711
+ conversation.image = this.imageRepoService.getImagePhotoUrl(conversation_with)
888
712
  }
889
713
  }
890
714
 
@@ -1048,29 +872,18 @@ export class ConversationListPage implements OnInit {
1048
872
  this.logger.log('[CONVS-LIST-PAGE] onCloseConversation conversationId: ', conversationId)
1049
873
 
1050
874
  const conversationWith_segments = conversationId.split('-')
1051
- this.logger.log(
1052
- '[CONVS-LIST-PAGE] - conversationId_segments: ',
1053
- conversationWith_segments,
1054
- )
875
+ this.logger.log('[CONVS-LIST-PAGE] - conversationId_segments: ',conversationWith_segments)
1055
876
 
1056
877
  // Removes the last element of the array if is = to the separator
1057
- if (
1058
- conversationWith_segments[conversationWith_segments.length - 1] === ''
1059
- ) {
878
+ if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
1060
879
  conversationWith_segments.pop()
1061
880
  }
1062
881
 
1063
882
  if (conversationWith_segments.length === 4) {
1064
883
  const lastArrayElement =
1065
884
  conversationWith_segments[conversationWith_segments.length - 1]
1066
- this.logger.log(
1067
- '[CONVS-LIST-PAGE] - lastArrayElement ',
1068
- lastArrayElement,
1069
- )
1070
- this.logger.log(
1071
- '[CONVS-LIST-PAGE] - lastArrayElement length',
1072
- lastArrayElement.length,
1073
- )
885
+ this.logger.log('[CONVS-LIST-PAGE] - lastArrayElement ',lastArrayElement)
886
+ this.logger.log('[CONVS-LIST-PAGE] - lastArrayElement length',lastArrayElement.length)
1074
887
  if (lastArrayElement.length !== 32) {
1075
888
  conversationWith_segments.pop()
1076
889
  }
@@ -1082,11 +895,7 @@ export class ConversationListPage implements OnInit {
1082
895
  project_id = conversationWith_segments[2]
1083
896
 
1084
897
  const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1085
- this.archiveSupportGroupConv(
1086
- tiledeskToken,
1087
- project_id,
1088
- conversationId,
1089
- )
898
+ this.archiveSupportGroupConv(tiledeskToken,project_id,conversationId,)
1090
899
  } else {
1091
900
  this.getProjectIdByConversationWith(conversationId)
1092
901
  }
@@ -1099,89 +908,42 @@ export class ConversationListPage implements OnInit {
1099
908
  getProjectIdByConversationWith(conversationId: string) {
1100
909
  const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1101
910
 
1102
- this.tiledeskService
1103
- .getProjectIdByConvRecipient(tiledeskToken, conversationId)
1104
- .subscribe(
1105
- (res) => {
1106
- this.logger.log(
1107
- '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT RES',
1108
- res,
1109
- )
911
+ this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationId).subscribe((res) => {
912
+ this.logger.log('[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT RES',res)
1110
913
 
1111
914
  if (res) {
1112
915
  const project_id = res.id_project
1113
- this.logger.log(
1114
- '[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT project_id',
1115
- project_id,
1116
- )
1117
- this.archiveSupportGroupConv(
1118
- tiledeskToken,
1119
- project_id,
1120
- conversationId,
1121
- )
916
+ this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT project_id',project_id)
917
+ this.archiveSupportGroupConv(tiledeskToken,project_id,conversationId)
1122
918
  }
1123
- },
1124
- (error) => {
1125
- this.logger.error(
1126
- '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT - ERROR ',
1127
- error,
1128
- )
1129
- },
1130
- () => {
1131
- this.logger.log(
1132
- '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
1133
- )
1134
- },
1135
- )
919
+ },(error) => {
920
+ this.logger.error('[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT - ERROR ',error)
921
+ },() => {
922
+ this.logger.log('[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
923
+ })
1136
924
  }
1137
925
 
1138
926
  archiveSupportGroupConv(tiledeskToken, project_id, conversationId) {
1139
- this.logger.log(
1140
- '[CONVS-LIST-PAGE] - onCloseConversation projectId: ',
1141
- project_id,
1142
- )
1143
- this.tiledeskService
1144
- .closeSupportGroup(tiledeskToken, project_id, conversationId)
1145
- .subscribe(
1146
- (res) => {
1147
- this.archiveActionNotAllowed = false
1148
- this.logger.log(
1149
- '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup RES',
1150
- res,
1151
- )
1152
- },
1153
- (error) => {
1154
- this.logger.error(
1155
- '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR ',
1156
- error,
1157
- )
1158
- this.logger.error(
1159
- '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR error.error.msg ',
1160
- error.error.msg,
1161
- )
1162
- this.logger.error(
1163
- '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR error.status ',
1164
- error.status,
1165
- )
1166
- if (error.error.msg === 'you dont belong to the project.') {
1167
- this.archiveActionNotAllowed = true
1168
- }
1169
- },
1170
- () => {
1171
- this.logger.log(
1172
- '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup * COMPLETE *',
1173
- )
1174
- this.logger.log(
1175
- '[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS ',
1176
- this.conversations,
1177
- )
1178
- this.logger.log(
1179
- '[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS LENGHT ',
1180
- this.conversations.length,
1181
- )
1182
- this.events.publish('conversationhasbeenclosed', conversationId)
1183
- },
1184
- )
927
+ this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation projectId: ',project_id)
928
+ this.tiledeskService.closeSupportGroup(tiledeskToken, project_id, conversationId).subscribe((res) => {
929
+ this.archiveActionNotAllowed = false
930
+ this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup RES',res)
931
+ },(error) => {
932
+ this.logger.error('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR ',error)
933
+ this.logger.error('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR error.error.msg ',error.error.msg)
934
+ this.logger.error('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR error.status ',error.status)
935
+ if (error.error.msg === 'you dont belong to the project.') {
936
+ this.archiveActionNotAllowed = true
937
+ }
938
+ },() => {
939
+ this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup * COMPLETE *')
940
+ this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS ',this.conversations)
941
+ this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS LENGHT ',this.conversations.length)
942
+ this.events.publish('conversationhasbeenclosed', conversationId)
943
+ if(conversationId === this.uidConvSelected){
944
+ this.navigateByUrl('archived', conversationId)
945
+ }
946
+ })
1185
947
  }
1186
948
 
1187
949
  onCloseAlert($event) {