@chat21/chat21-ionic 3.0.61-rc2 → 3.0.61-rc21

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 (120) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/angular.json +2 -0
  3. package/config.xml +4 -5
  4. package/deploy_pre.sh +27 -27
  5. package/deploy_prod.sh +5 -1
  6. package/env.sample +1 -1
  7. package/package.json +8 -8
  8. package/resources/{Android → android}/icon/drawable-hdpi-icon.png +0 -0
  9. package/resources/{Android → android}/icon/drawable-ldpi-icon.png +0 -0
  10. package/resources/{Android → android}/icon/drawable-mdpi-icon.png +0 -0
  11. package/resources/{Android → android}/icon/drawable-xhdpi-icon.png +0 -0
  12. package/resources/{Android → android}/icon/drawable-xxhdpi-icon.png +0 -0
  13. package/resources/{Android → android}/icon/drawable-xxxhdpi-icon.png +0 -0
  14. package/resources/{Android → android}/icon.png +0 -0
  15. package/resources/{Android → android}/splash/drawable-land-hdpi-screen.png +0 -0
  16. package/resources/{Android → android}/splash/drawable-land-ldpi-screen.png +0 -0
  17. package/resources/{Android → android}/splash/drawable-land-mdpi-screen.png +0 -0
  18. package/resources/{Android → android}/splash/drawable-land-xhdpi-screen.png +0 -0
  19. package/resources/{Android → android}/splash/drawable-land-xxhdpi-screen.png +0 -0
  20. package/resources/{Android → android}/splash/drawable-land-xxxhdpi-screen.png +0 -0
  21. package/resources/{Android → android}/splash/drawable-port-hdpi-screen.png +0 -0
  22. package/resources/{Android → android}/splash/drawable-port-ldpi-screen.png +0 -0
  23. package/resources/{Android → android}/splash/drawable-port-mdpi-screen.png +0 -0
  24. package/resources/{Android → android}/splash/drawable-port-xhdpi-screen.png +0 -0
  25. package/resources/{Android → android}/splash/drawable-port-xxhdpi-screen.png +0 -0
  26. package/resources/{Android → android}/splash/drawable-port-xxxhdpi-screen.png +0 -0
  27. package/resources/{Android → android}/splash.png +0 -0
  28. package/src/app/app-routing.module.ts +15 -0
  29. package/src/app/app.component.html +4 -3
  30. package/src/app/app.component.scss +6 -1
  31. package/src/app/app.component.ts +29 -18
  32. package/src/app/app.module.ts +11 -3
  33. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +36 -25
  34. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +160 -50
  35. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +101 -18
  36. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +21 -36
  37. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +19 -7
  38. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +35 -40
  39. package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.scss +1 -1
  40. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +6 -1
  41. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +89 -21
  42. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +37 -33
  43. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +7 -1
  44. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +148 -63
  45. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +59 -22
  46. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +32 -9
  47. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +102 -23
  48. package/src/app/components/conversation-info/info-content/info-content.component.html +2 -2
  49. package/src/app/components/ddp-header/ddp-header.component.html +11 -4
  50. package/src/app/components/ddp-header/ddp-header.component.ts +94 -19
  51. package/src/app/components/project-item/project-item.component.html +2 -2
  52. package/src/app/components/project-item/project-item.component.scss +1 -1
  53. package/src/app/components/project-item/project-item.component.ts +1 -1
  54. package/src/app/components/sidebar/sidebar.component.html +151 -86
  55. package/src/app/components/sidebar/sidebar.component.scss +72 -4
  56. package/src/app/components/sidebar/sidebar.component.ts +211 -72
  57. package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +29 -10
  58. package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +53 -29
  59. package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +176 -97
  60. package/src/app/pages/conversation-detail/conversation-detail.module.ts +6 -1
  61. package/src/app/pages/conversation-detail/conversation-detail.page.html +20 -10
  62. package/src/app/pages/conversation-detail/conversation-detail.page.scss +28 -0
  63. package/src/app/pages/conversation-detail/conversation-detail.page.ts +1124 -777
  64. package/src/app/pages/conversations-list/conversations-list.module.ts +2 -1
  65. package/src/app/pages/conversations-list/conversations-list.page.html +9 -6
  66. package/src/app/pages/conversations-list/conversations-list.page.scss +9 -1
  67. package/src/app/pages/conversations-list/conversations-list.page.ts +724 -436
  68. package/src/app/pages/create-canned-response/create-canned-response-routing.module.ts +17 -0
  69. package/src/app/pages/create-canned-response/create-canned-response.module.ts +30 -0
  70. package/src/app/pages/create-canned-response/create-canned-response.page.html +150 -0
  71. package/src/app/pages/create-canned-response/create-canned-response.page.scss +55 -0
  72. package/src/app/pages/create-canned-response/create-canned-response.page.spec.ts +24 -0
  73. package/src/app/pages/create-canned-response/create-canned-response.page.ts +319 -0
  74. package/src/app/pages/create-requester/create-requester-routing.module.ts +17 -0
  75. package/src/app/pages/create-requester/create-requester.module.ts +28 -0
  76. package/src/app/pages/create-requester/create-requester.page.html +67 -0
  77. package/src/app/pages/create-requester/create-requester.page.scss +30 -0
  78. package/src/app/pages/create-requester/create-requester.page.spec.ts +24 -0
  79. package/src/app/pages/create-requester/create-requester.page.ts +138 -0
  80. package/src/app/pages/create-ticket/create-ticket-routing.module.ts +17 -0
  81. package/src/app/pages/create-ticket/create-ticket.module.ts +28 -0
  82. package/src/app/pages/create-ticket/create-ticket.page.html +171 -0
  83. package/src/app/pages/create-ticket/create-ticket.page.scss +52 -0
  84. package/src/app/pages/create-ticket/create-ticket.page.spec.ts +24 -0
  85. package/src/app/pages/create-ticket/create-ticket.page.ts +432 -0
  86. package/src/app/pages/loader-preview/loader-preview.page.ts +226 -166
  87. package/src/app/pages/profile-info/profile-info.page.html +2 -2
  88. package/src/app/pages/profile-info/profile-info.page.scss +13 -2
  89. package/src/app/services/tiledesk/tiledesk.service.ts +209 -0
  90. package/src/app/shared/shared.module.ts +1 -1
  91. package/src/app/utils/scrollbar-theme.directive.ts +58 -24
  92. package/src/assets/i18n/de.json +46 -7
  93. package/src/assets/i18n/en.json +42 -3
  94. package/src/assets/i18n/es.json +42 -3
  95. package/src/assets/i18n/fr.json +45 -6
  96. package/src/assets/i18n/it.json +42 -3
  97. package/src/assets/i18n/pt.json +42 -3
  98. package/src/assets/i18n/ru.json +43 -4
  99. package/src/assets/i18n/sr.json +265 -0
  100. package/src/assets/i18n/tr.json +42 -4
  101. package/src/assets/images/default-avatar-x-select.png +0 -0
  102. package/src/assets/images/language_flag/hr.png +0 -0
  103. package/src/assets/images/language_flag/sr.png +0 -0
  104. package/src/assets/images/priority_icons/high.svg +3 -0
  105. package/src/assets/images/priority_icons/high_v2.svg +14 -0
  106. package/src/assets/images/priority_icons/low.svg +10 -0
  107. package/src/assets/images/priority_icons/low_v2.svg +14 -0
  108. package/src/assets/images/priority_icons/medium.svg +16 -0
  109. package/src/assets/images/priority_icons/medium_v2.svg +11 -0
  110. package/src/assets/images/priority_icons/urgent.svg +4 -0
  111. package/src/assets/images/priority_icons/urgent_v2.svg +16 -0
  112. package/src/chat-config-pre-test.json +1 -1
  113. package/src/chat-config-template.json +1 -1
  114. package/src/chat-config.json +1 -1
  115. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +8 -3
  116. package/src/chat21-core/utils/constants.ts +6 -1
  117. package/src/chat21-core/utils/utils-message.ts +19 -0
  118. package/src/global.scss +65 -111
  119. package/publish_pre.sh +0 -33
  120. package/publish_prod.sh +0 -33
@@ -1,41 +1,48 @@
1
- import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service';
2
- import { Component, OnInit, ViewChild } from '@angular/core';
3
- import { IonContent, ModalController } from '@ionic/angular';
4
- import { ActivatedRoute, Router, NavigationExtras } from '@angular/router';
1
+ import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service'
2
+ import { Component, OnInit, ViewChild } from '@angular/core'
3
+ import { IonContent, ModalController } from '@ionic/angular'
4
+ import { ActivatedRoute, Router, NavigationExtras } from '@angular/router'
5
5
  // config
6
- import { environment } from '../../../environments/environment';
6
+ import { environment } from '../../../environments/environment'
7
7
 
8
8
  // models
9
- import { ConversationModel } from 'src/chat21-core/models/conversation';
10
- import { UserModel } from 'src/chat21-core/models/user';
9
+ import { ConversationModel } from 'src/chat21-core/models/conversation'
10
+ import { UserModel } from 'src/chat21-core/models/user'
11
11
 
12
12
  // utils
13
- import { isInArray, checkPlatformIsMobile, presentModal, closeModal, convertMessage, isGroup, } from '../../../chat21-core/utils/utils';
14
-
15
- import { EventsService } from '../../services/events-service';
16
- import PerfectScrollbar from 'perfect-scrollbar'; // https://github.com/mdbootstrap/perfect-scrollbar
13
+ import {
14
+ isInArray,
15
+ checkPlatformIsMobile,
16
+ presentModal,
17
+ closeModal,
18
+ convertMessage,
19
+ isGroup,
20
+ } from '../../../chat21-core/utils/utils'
21
+
22
+ import { EventsService } from '../../services/events-service'
23
+ import PerfectScrollbar from 'perfect-scrollbar' // https://github.com/mdbootstrap/perfect-scrollbar
17
24
 
18
25
  // services
19
- import { ConversationsHandlerService } from 'src/chat21-core/providers/abstract/conversations-handler.service';
20
- import { ChatManager } from 'src/chat21-core/providers/chat-manager';
21
- import { NavProxyService } from '../../services/nav-proxy.service';
22
- import { TiledeskService } from '../../services/tiledesk/tiledesk.service';
23
- import { ConversationDetailPage } from '../conversation-detail/conversation-detail.page';
24
- import { ContactsDirectoryPage } from '../contacts-directory/contacts-directory.page';
25
- import { UnassignedConversationsPage } from '../unassigned-conversations/unassigned-conversations.page';
26
- import { ProfileInfoPage } from '../profile-info/profile-info.page';
27
- import { MessagingAuthService } from 'src/chat21-core/providers/abstract/messagingAuth.service';
28
- import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
29
- import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service';
30
- import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
31
- import { AppConfigProvider } from '../../services/app-config';
32
- import { Subscription } from 'rxjs';
33
- import { Platform } from '@ionic/angular';
26
+ import { ConversationsHandlerService } from 'src/chat21-core/providers/abstract/conversations-handler.service'
27
+ import { ChatManager } from 'src/chat21-core/providers/chat-manager'
28
+ import { NavProxyService } from '../../services/nav-proxy.service'
29
+ import { TiledeskService } from '../../services/tiledesk/tiledesk.service'
30
+ import { ConversationDetailPage } from '../conversation-detail/conversation-detail.page'
31
+ import { ContactsDirectoryPage } from '../contacts-directory/contacts-directory.page'
32
+ import { UnassignedConversationsPage } from '../unassigned-conversations/unassigned-conversations.page'
33
+ import { ProfileInfoPage } from '../profile-info/profile-info.page'
34
+ import { MessagingAuthService } from 'src/chat21-core/providers/abstract/messagingAuth.service'
35
+ import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service'
36
+ import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service'
37
+ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service'
38
+ import { AppConfigProvider } from '../../services/app-config'
39
+ import { Subscription } from 'rxjs'
40
+ import { Platform } from '@ionic/angular'
34
41
  // Logger
35
- import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
36
- import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
37
- import { NetworkService } from 'src/app/services/network-service/network.service';
38
- import { Subject } from 'rxjs';
42
+ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'
43
+ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
44
+ import { NetworkService } from 'src/app/services/network-service/network.service'
45
+ import { Subject } from 'rxjs'
39
46
  import { takeUntil } from 'rxjs/operators'
40
47
 
41
48
  @Component({
@@ -44,53 +51,54 @@ import { takeUntil } from 'rxjs/operators'
44
51
  styleUrls: ['./conversations-list.page.scss'],
45
52
  })
46
53
  export class ConversationListPage implements OnInit {
47
-
48
- @ViewChild('ioncontentconvlist', { static: false }) ionContentConvList: IonContent;
49
-
50
- private unsubscribe$: Subject<any> = new Subject<any>();
51
- private subscriptions: Array<string>;
52
- public tenant: string;
53
- public loggedUserUid: string;
54
- public conversations: Array<ConversationModel> = [];
55
- public archivedConversations: Array<ConversationModel> = [];
56
- public uidConvSelected: string;
57
- public conversationSelected: ConversationModel;
58
- public uidReciverFromUrl: string;
59
- public showPlaceholder = true;
60
- public numberOpenConv = 0;
61
- public loadingIsActive = true;
62
- public supportMode: boolean;
63
- public teammates_btn: boolean;
64
- public archived_btn: boolean;
65
- public convertMessage = convertMessage;
66
- private isShowMenuPage = false;
67
- private logger: LoggerService = LoggerInstance.getInstance();
68
- translationMapConversation: Map<string, string>;
69
- stylesMap: Map<string, string>;
54
+ @ViewChild('ioncontentconvlist', { static: false })
55
+ ionContentConvList: IonContent
56
+
57
+ private unsubscribe$: Subject<any> = new Subject<any>()
58
+ private subscriptions: Array<string>
59
+ public tenant: string
60
+ public loggedUserUid: string
61
+ public conversations: Array<ConversationModel> = []
62
+ public archivedConversations: Array<ConversationModel> = []
63
+ public uidConvSelected: string
64
+ public conversationSelected: ConversationModel
65
+ public uidReciverFromUrl: string
66
+ public showPlaceholder = true
67
+ public numberOpenConv = 0
68
+ public loadingIsActive = true
69
+ public supportMode: boolean
70
+ public writeto_btn: boolean
71
+ public archived_btn: boolean
72
+ public convertMessage = convertMessage
73
+ private isShowMenuPage = false
74
+ private logger: LoggerService = LoggerInstance.getInstance()
75
+ translationMapConversation: Map<string, string>
76
+ stylesMap: Map<string, string>
70
77
 
71
78
  public conversationType = 'active'
72
- headerTitle: string;
73
- subscription: Subscription;
79
+ headerTitle: string
80
+ subscription: Subscription
74
81
 
75
- public UNASSIGNED_CONVS_URL: any;
76
- public PROJECTS_FOR_PANEL_URL: any;
77
- public IFRAME_URL: any;
78
- public hasClickedOpenUnservedConvIframe: boolean = false;
79
- public lastProjectId: string;
80
- public isOnline: boolean = true;
81
- public checkInternet: boolean;
82
+ public UNASSIGNED_CONVS_URL: any
83
+ public PROJECTS_FOR_PANEL_URL: any
84
+ public IFRAME_URL: any
85
+ public hasClickedOpenUnservedConvIframe: boolean = false
86
+ public lastProjectId: string
87
+ public isOnline: boolean = true
88
+ public checkInternet: boolean
82
89
 
83
90
  public displayNewConvsItem: boolean = true
91
+ public archiveActionNotAllowed: boolean = false
84
92
 
85
93
  tooltipOptions = {
86
94
  'show-delay': 1500,
87
95
  'tooltip-class': 'chat-tooltip',
88
- 'theme': 'light',
89
- 'shadow': false,
96
+ theme: 'light',
97
+ shadow: false,
90
98
  'hide-delay-mobile': 0,
91
- 'hideDelayAfterClick': 3000,
92
- 'hide-delay': 200
93
- };
99
+ hideDelayAfterClick: 3000,
100
+ 'hide-delay': 200,
101
+ }
94
102
 
95
103
  constructor(
96
104
  private router: Router,
@@ -110,39 +118,50 @@ export class ConversationListPage implements OnInit {
110
118
  public appConfigProvider: AppConfigProvider,
111
119
  public platform: Platform,
112
120
  private networkService: NetworkService,
113
-
114
121
  ) {
115
- this.listenToAppCompConvsLengthOnInitConvs();
116
- this.listenToLogoutEvent();
117
- this.listenGoOnline();
118
- this.listenGoOffline();
119
- this.listenToSwPostMessage();
120
- this.listenSupportConvIdHasChanged();
122
+ this.listenToAppCompConvsLengthOnInitConvs()
123
+ this.listenToLogoutEvent()
124
+ this.listenGoOnline()
125
+ this.listenGoOffline()
126
+ this.listenToSwPostMessage()
127
+ this.listenSupportConvIdHasChanged()
121
128
  // this.listenDirectConvIdHasChanged();
129
+ this.listenToCloseConvFromHeaderConversation()
122
130
  }
123
131
 
124
132
  listenSupportConvIdHasChanged() {
125
133
  this.events.subscribe('supportconvid:haschanged', (IDConv) => {
126
- this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - convId', IDConv);
134
+ // console.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - convId', IDConv);
127
135
  if (IDConv) {
128
136
  // const conversationSelected = this.conversations.find(item => item.uid === convId);
129
137
  // this.onConversationSelected(conversationSelected)
130
- this.setUidConvSelected(IDConv, 'active');
138
+ this.setUidConvSelected(IDConv, 'active')
131
139
  }
132
140
  if (!IDConv) {
133
- this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - is the page without conv select');
141
+ this.logger.log(
142
+ '[CONVS-LIST-PAGE] - listen To convid:haschanged - is the page without conv select',
143
+ )
134
144
 
135
145
  const chatTabCount = +localStorage.getItem('tabCount')
136
- this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - chatTabCount ', chatTabCount);
146
+ this.logger.log(
147
+ '[CONVS-LIST-PAGE] - listen To convid:haschanged - chatTabCount ',
148
+ chatTabCount,
149
+ )
137
150
  if (chatTabCount && chatTabCount > 0) {
138
- this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - the chat is already open ', chatTabCount);
151
+ this.logger.log(
152
+ '[CONVS-LIST-PAGE] - listen To convid:haschanged - the chat is already open ',
153
+ chatTabCount,
154
+ )
139
155
  if (checkPlatformIsMobile()) {
140
- this.logger.log('[CONVS-LIST-PAGE] - the chat is in mobile mode ', checkPlatformIsMobile());
141
- this.events.publish('noparams:mobile', true);
156
+ this.logger.log(
157
+ '[CONVS-LIST-PAGE] - the chat is in mobile mode ',
158
+ checkPlatformIsMobile(),
159
+ )
160
+ this.events.publish('noparams:mobile', true)
142
161
  }
143
162
  }
144
163
  }
145
- });
164
+ })
146
165
  }
147
166
 
148
167
  // listenDirectConvIdHasChanged() {
@@ -154,13 +173,12 @@ export class ConversationListPage implements OnInit {
154
173
  // });
155
174
  // }
156
175
 
157
-
158
176
  // -----------------------------------------------
159
177
  // @ Lifehooks
160
178
  // -----------------------------------------------
161
179
  ngOnInit() {
162
- this.watchToConnectionStatus();
163
- this.getAppConfigToHideDiplayBtns();
180
+ this.watchToConnectionStatus()
181
+ this.getAppConfigToHideDiplayBtns()
164
182
 
165
183
  // const currentUrl = this.router.url;
166
184
  // this.logger.log('[CONVS-LIST-PAGE] current_url ngOnInit ', currentUrl);
@@ -203,76 +221,98 @@ export class ConversationListPage implements OnInit {
203
221
  // });
204
222
  }
205
223
 
224
+ ngOnChanges() {
225
+ this.getConversationListHeight()
226
+ }
227
+
228
+ getConversationListHeight() {
229
+ var scrollbar2element = document.getElementById('scrollbar2')
230
+ this.logger.log(
231
+ '[CONVS-LIST-PAGE] getConversationListHeight scrollbar2element',
232
+ scrollbar2element,
233
+ )
234
+ }
206
235
 
207
236
  getAppConfigToHideDiplayBtns() {
208
- const appConfig = this.appConfigProvider.getConfig();
209
- console.log('[ION-LIST-CONVS-COMP] - appConfig ', appConfig)
237
+ const appConfig = this.appConfigProvider.getConfig()
238
+ // console.log('[ION-LIST-CONVS-COMP] - appConfig ', appConfig)
210
239
  if (appConfig && appConfig.supportMode) {
211
- this.supportMode = appConfig.supportMode;
240
+ this.supportMode = appConfig.supportMode
212
241
  } else {
213
- this.supportMode = false;
242
+ this.supportMode = false
214
243
  }
215
244
  if (appConfig && appConfig.archivedButton) {
216
- this.archived_btn = appConfig.archivedButton;
245
+ this.archived_btn = appConfig.archivedButton
217
246
  } else {
218
- this.archived_btn = false;
247
+ this.archived_btn = false
219
248
  }
220
- if (appConfig && appConfig.teammatesButton) {
221
- this.teammates_btn = appConfig.teammatesButton;
249
+ if (appConfig && appConfig.writeToButton) {
250
+ this.writeto_btn = appConfig.writeToButton
222
251
  } else {
223
- this.teammates_btn = false;
252
+ this.writeto_btn = false
224
253
  }
225
254
  // console.log('[ION-LIST-CONVS-COMP] - supportMode ', this.supportMode)
226
255
  }
227
256
 
228
257
  watchToConnectionStatus() {
229
- this.networkService.checkInternetFunc().subscribe(isOnline => {
258
+ this.networkService.checkInternetFunc().subscribe((isOnline) => {
230
259
  this.checkInternet = isOnline
231
- this.logger.log('[ION-LIST-CONVS-COMP] - watchToConnectionStatus - isOnline', this.checkInternet)
260
+ this.logger.log(
261
+ '[ION-LIST-CONVS-COMP] - watchToConnectionStatus - isOnline',
262
+ this.checkInternet,
263
+ )
232
264
 
233
265
  // checking internet connection
234
266
  if (this.checkInternet == true) {
235
-
236
- this.isOnline = true;
267
+ this.isOnline = true
237
268
  } else {
238
- this.isOnline = false;
269
+ this.isOnline = false
239
270
  }
240
- });
271
+ })
241
272
  }
242
273
 
243
-
244
274
  ionViewWillEnter() {
245
275
  this.logger.log('Called ionViewDidEnter')
246
- this.logger.log('[CONVS-LIST-PAGE] ionViewWillEnter uidConvSelected', this.uidConvSelected);
247
- this.listnerStart();
276
+ this.logger.log(
277
+ '[CONVS-LIST-PAGE] ionViewWillEnter uidConvSelected',
278
+ this.uidConvSelected,
279
+ )
280
+ this.listnerStart()
248
281
 
249
282
  // exit from app with hardware back button
250
283
  this.subscription = this.platform.backButton.subscribe(() => {
251
- navigator['app'].exitApp();
252
- });
284
+ navigator['app'].exitApp()
285
+ })
253
286
  }
254
287
 
255
288
  // unsubscribe backButton.subscribe method to not use from other page
256
289
  ionViewWillLeave() {
257
290
  this.logger.log('Called ionViewWillLeave')
258
- this.subscription.unsubscribe();
291
+ this.subscription.unsubscribe()
259
292
  }
260
293
 
261
294
  ionViewDidEnter() { }
262
295
 
263
296
  getLastProjectId(projectid: string) {
264
- this.logger.log('[CONVS-LIST-PAGE] - GET LAST PROJECT ID', projectid);
265
- this.lastProjectId = projectid;
297
+ this.logger.log('[CONVS-LIST-PAGE] - GET LAST PROJECT ID', projectid)
298
+ this.lastProjectId = projectid
266
299
  }
267
300
 
268
301
  openUnsevedConversationIframe(event) {
269
302
  this.logger.log('[CONVS-LIST-PAGE] openUnsevedConversationIframe ', event)
270
303
  this.hasClickedOpenUnservedConvIframe = true
271
- this.logger.log('[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME', this.hasClickedOpenUnservedConvIframe);
272
- const DASHBOARD_BASE_URL = this.appConfigProvider.getConfig().dashboardUrl;
304
+ this.logger.log(
305
+ '[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME',
306
+ this.hasClickedOpenUnservedConvIframe,
307
+ )
308
+ const DASHBOARD_BASE_URL = this.appConfigProvider.getConfig().dashboardUrl
273
309
  // http://localhost:4204/#/projects-for-panel
274
- this.PROJECTS_FOR_PANEL_URL = DASHBOARD_BASE_URL + '#/projects-for-panel';
275
- this.UNASSIGNED_CONVS_URL = DASHBOARD_BASE_URL + '#/project/' + this.lastProjectId + '/unserved-request-for-panel';
310
+ this.PROJECTS_FOR_PANEL_URL = DASHBOARD_BASE_URL + '#/projects-for-panel'
311
+ this.UNASSIGNED_CONVS_URL =
312
+ DASHBOARD_BASE_URL +
313
+ '#/project/' +
314
+ this.lastProjectId +
315
+ '/unserved-request-for-panel'
276
316
 
277
317
  if (event === 'pinbtn') {
278
318
  this.IFRAME_URL = this.PROJECTS_FOR_PANEL_URL
@@ -280,7 +320,10 @@ export class ConversationListPage implements OnInit {
280
320
  this.IFRAME_URL = this.UNASSIGNED_CONVS_URL
281
321
  }
282
322
 
283
- this.logger.log('[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME > UNASSIGNED CONVS URL', this.UNASSIGNED_CONVS_URL);
323
+ this.logger.log(
324
+ '[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME > UNASSIGNED CONVS URL',
325
+ this.UNASSIGNED_CONVS_URL,
326
+ )
284
327
  this.openUnassignedConversations(this.IFRAME_URL, event)
285
328
  }
286
329
 
@@ -291,180 +334,233 @@ export class ConversationListPage implements OnInit {
291
334
  if (checkPlatformIsMobile()) {
292
335
  presentModal(this.modalController, UnassignedConversationsPage, {
293
336
  iframe_URL: IFRAME_URL,
294
- callerBtn: event
295
- });
337
+ callerBtn: event,
338
+ })
296
339
  } else {
297
340
  this.navService.push(UnassignedConversationsPage, {
298
341
  iframe_URL: IFRAME_URL,
299
- callerBtn: event
300
-
301
- });
342
+ callerBtn: event,
343
+ })
302
344
  }
303
345
  }
304
346
 
305
347
  _closeContactsDirectory() {
306
348
  try {
307
- closeModal(this.modalController);
349
+ closeModal(this.modalController)
308
350
  } catch (err) {
309
- this.logger.error('[CONVS-LIST-PAGE] closeContactsDirectory -> error:', err);
351
+ this.logger.error(
352
+ '[CONVS-LIST-PAGE] closeContactsDirectory -> error:',
353
+ err,
354
+ )
310
355
  }
311
356
  }
312
357
 
313
-
314
358
  listenToSwPostMessage() {
315
- this.logger.log('[CONVS-LIST-PAGE] listenToNotificationCLick - CALLED: ');
316
- const that = this;
359
+ this.logger.log('[CONVS-LIST-PAGE] listenToNotificationCLick - CALLED: ')
360
+ const that = this
317
361
  if (navigator && navigator.serviceWorker) {
318
-
319
362
  navigator.serviceWorker.addEventListener('message', function (event) {
320
-
321
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data: ', event.data);
322
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data: ', event.data['data']);
323
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data typeof: ', typeof event.data['data']);
363
+ that.logger.log(
364
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data: ',
365
+ event.data,
366
+ )
367
+ that.logger.log(
368
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data: ',
369
+ event.data['data'],
370
+ )
371
+ that.logger.log(
372
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data typeof: ',
373
+ typeof event.data['data'],
374
+ )
324
375
  let uidConvSelected = ''
325
376
  if (event.data && event.data['conversWith']) {
326
- uidConvSelected = event.data['conversWith'];
327
- }
328
- else {
329
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - DIFFERENT MSG');
330
- return;
377
+ uidConvSelected = event.data['conversWith']
378
+ } else {
379
+ that.logger.log(
380
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - DIFFERENT MSG',
381
+ )
382
+ return
331
383
  }
332
384
 
333
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event dataObjct uidConvSelected: ', uidConvSelected);
334
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker that.conversations: ', that.conversations);
335
- const conversationSelected = that.conversations.find(item => item.uid === uidConvSelected);
385
+ that.logger.log(
386
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event dataObjct uidConvSelected: ',
387
+ uidConvSelected,
388
+ )
389
+ that.logger.log(
390
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker that.conversations: ',
391
+ that.conversations,
392
+ )
393
+ const conversationSelected = that.conversations.find(
394
+ (item) => item.uid === uidConvSelected,
395
+ )
336
396
  if (conversationSelected) {
337
-
338
- that.conversationSelected = conversationSelected;
339
- that.logger.log('[CONVS-LIST-PAGE] listenToNotificationCLick- Received a message from service worker event conversationSelected: ', that.conversationSelected);
397
+ that.conversationSelected = conversationSelected
398
+ that.logger.log(
399
+ '[CONVS-LIST-PAGE] listenToNotificationCLick- Received a message from service worker event conversationSelected: ',
400
+ that.conversationSelected,
401
+ )
340
402
 
341
403
  that.navigateByUrl('active', uidConvSelected)
342
404
  }
343
- });
405
+ })
344
406
  }
345
407
  }
346
408
 
347
-
348
409
  private listnerStart() {
349
- const that = this;
350
- this.chatManager.BSStart
351
- .pipe(
352
- takeUntil(that.unsubscribe$)
353
- )
354
- .subscribe((data: any) => {
355
- this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR DATA - Current user *****', data);
410
+ const that = this
411
+ this.chatManager.BSStart.pipe(takeUntil(that.unsubscribe$)).subscribe(
412
+ (data: any) => {
413
+ this.logger.log(
414
+ '[CONVS-LIST-PAGE] - BSStart SUBSCR DATA - Current user *****',
415
+ data,
416
+ )
356
417
  if (data) {
357
- that.initialize();
418
+ that.initialize()
358
419
  }
359
- }, error => {
360
- this.logger.error('[CONVS-LIST-PAGE] - BSStart SUBSCR - ERROR: ', error);
361
- }, () => {
420
+ },
421
+ (error) => {
422
+ this.logger.error('[CONVS-LIST-PAGE] - BSStart SUBSCR - ERROR: ', error)
423
+ },
424
+ () => {
362
425
  this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR * COMPLETE *')
363
- });
426
+ },
427
+ )
364
428
  }
365
429
 
366
-
367
430
  // ------------------------------------------------------------------ //
368
431
  // Init convrsation handler
369
432
  // ------------------------------------------------------------------ //
370
433
  initConversationsHandler() {
371
- this.conversations = this.conversationsHandlerService.conversations;
434
+ this.conversations = this.conversationsHandlerService.conversations
372
435
  this.logger.log('[CONVS-LIST-PAGE] - CONVERSATIONS ', this.conversations)
373
436
  // save conversationHandler in chatManager
374
- this.chatManager.setConversationsHandler(this.conversationsHandlerService);
375
- this.showPlaceholder = false;
437
+ this.chatManager.setConversationsHandler(this.conversationsHandlerService)
438
+ this.showPlaceholder = false
376
439
  }
377
440
 
378
-
379
-
380
441
  initArchivedConversationsHandler() {
381
- const keysConversation = ['CLOSED', 'Resolve'];
382
- this.translationMapConversation = this.translateService.translateLanguage(keysConversation);
442
+ const keysConversation = ['CLOSED', 'Resolve']
443
+ this.translationMapConversation = this.translateService.translateLanguage(
444
+ keysConversation,
445
+ )
383
446
 
384
447
  this.archivedConversationsHandlerService.subscribeToConversations(() => {
385
- this.logger.log('[CONVS-LIST-PAGE]-CONVS - conversations archived length ', this.archivedConversations.length)
386
-
387
- });
448
+ this.logger.log(
449
+ '[CONVS-LIST-PAGE]-CONVS - conversations archived length ',
450
+ this.archivedConversations.length,
451
+ )
452
+ })
388
453
 
389
- this.archivedConversations = this.archivedConversationsHandlerService.archivedConversations;
390
- this.logger.log('[CONVS-LIST-PAGE] archived conversation', this.archivedConversations)
454
+ this.archivedConversations = this.archivedConversationsHandlerService.archivedConversations
455
+ this.logger.log(
456
+ '[CONVS-LIST-PAGE] archived conversation',
457
+ this.archivedConversations,
458
+ )
391
459
 
392
460
  // save archivedConversationsHandlerService in chatManager
393
- this.chatManager.setArchivedConversationsHandler(this.archivedConversationsHandlerService);
394
-
395
- this.logger.log('[CONVS-LIST-PAGE]-CONVS SubscribeToConversations - conversations archived length ', this.archivedConversations.length)
396
- if (!this.archivedConversations || this.archivedConversations.length === 0) {
397
- this.loadingIsActive = false;
461
+ this.chatManager.setArchivedConversationsHandler(
462
+ this.archivedConversationsHandlerService,
463
+ )
464
+
465
+ this.logger.log(
466
+ '[CONVS-LIST-PAGE]-CONVS SubscribeToConversations - conversations archived length ',
467
+ this.archivedConversations.length,
468
+ )
469
+ if (
470
+ !this.archivedConversations ||
471
+ this.archivedConversations.length === 0
472
+ ) {
473
+ this.loadingIsActive = false
398
474
  }
399
475
  }
400
476
 
401
-
402
477
  // ----------------------------------------------------------------------------------------------------
403
- // To display "No conversation yet" MESSAGE in conversazion list
478
+ // To display "No conversation yet" MESSAGE in conversazion list
404
479
  // this.loadingIsActive is set to false only if on init there are not conversation
405
480
  // otherwise loadingIsActive remains set to true and the message "No conversation yet" is not displayed
406
481
  // to fix this
407
- // - for the direct conversation
408
- // ----------------------------------------------------------------------------------------------------
482
+ // - for the direct conversation
483
+ // ----------------------------------------------------------------------------------------------------
409
484
  listenToAppCompConvsLengthOnInitConvs() {
410
- this.events.subscribe('appcompSubscribeToConvs:loadingIsActive', (loadingIsActive) => {
411
- this.logger.log('[CONVS-LIST-PAGE]-CONVS loadingIsActive', loadingIsActive);
412
- if (loadingIsActive === false) {
413
- this.loadingIsActive = false
414
- }
415
- });
485
+ this.events.subscribe(
486
+ 'appcompSubscribeToConvs:loadingIsActive',
487
+ (loadingIsActive) => {
488
+ this.logger.log(
489
+ '[CONVS-LIST-PAGE]-CONVS loadingIsActive',
490
+ loadingIsActive,
491
+ )
492
+ if (loadingIsActive === false) {
493
+ this.loadingIsActive = false
494
+ }
495
+ },
496
+ )
416
497
  }
417
498
 
418
499
  listenGoOnline() {
419
500
  this.events.subscribe('go:online', (goonline) => {
420
- this.logger.info('[CONVS-LIST-PAGE] - listen To go:online - goonline', goonline);
501
+ this.logger.info(
502
+ '[CONVS-LIST-PAGE] - listen To go:online - goonline',
503
+ goonline,
504
+ )
421
505
  // this.events.unsubscribe('profileInfoButtonClick:logout')
422
506
  if (goonline === true) {
423
507
  this.displayNewConvsItem = true
424
508
  }
425
- });
509
+ })
426
510
  }
427
511
 
428
512
  listenGoOffline() {
429
513
  this.events.subscribe('go:offline', (offline) => {
430
- this.logger.info('[CONVS-LIST-PAGE] - listen To go:offline - offline', offline);
514
+ this.logger.info(
515
+ '[CONVS-LIST-PAGE] - listen To go:offline - offline',
516
+ offline,
517
+ )
431
518
  // this.events.unsubscribe('profileInfoButtonClick:logout')
432
519
  if (offline === true) {
433
520
  this.displayNewConvsItem = false
434
521
  }
435
- });
522
+ })
436
523
  }
437
524
 
438
525
  listenToLogoutEvent() {
439
- this.events.subscribe('profileInfoButtonClick:logout', (hasclickedlogout) => {
440
- this.logger.info('[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout', hasclickedlogout);
441
-
442
-
443
- this.conversations = []
444
- this.conversationsHandlerService.conversations = [];
445
- this.uidConvSelected = null;
446
-
447
- this.logger.log('[CONVS-LIST-PAGE] - listenToLogoutEvent - CONVERSATIONS ', this.conversations)
448
- this.logger.log('[CONVS-LIST-PAGE] - listenToLogoutEvent - uidConvSelected ', this.uidConvSelected)
449
- if (hasclickedlogout === true) {
450
- this.loadingIsActive = false
451
- }
452
- });
526
+ this.events.subscribe(
527
+ 'profileInfoButtonClick:logout',
528
+ (hasclickedlogout) => {
529
+ this.logger.info(
530
+ '[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout',
531
+ hasclickedlogout,
532
+ )
533
+
534
+ this.conversations = []
535
+ this.conversationsHandlerService.conversations = []
536
+ this.uidConvSelected = null
537
+
538
+ this.logger.log(
539
+ '[CONVS-LIST-PAGE] - listenToLogoutEvent - CONVERSATIONS ',
540
+ this.conversations,
541
+ )
542
+ this.logger.log(
543
+ '[CONVS-LIST-PAGE] - listenToLogoutEvent - uidConvSelected ',
544
+ this.uidConvSelected,
545
+ )
546
+ if (hasclickedlogout === true) {
547
+ this.loadingIsActive = false
548
+ }
549
+ },
550
+ )
453
551
  }
454
552
 
455
-
456
- // ------------------------------------------------------------------
553
+ // ------------------------------------------------------------------
457
554
  // SUBSCRIPTIONS
458
555
  // ------------------------------------------------------------------
459
556
  initSubscriptions() {
460
557
  this.logger.log('[CONVS-LIST-PAGE] - CALLING - initSubscriptions ')
461
- let key = '';
462
-
558
+ let key = ''
463
559
 
464
- key = 'loggedUser:logout';
560
+ key = 'loggedUser:logout'
465
561
  if (!isInArray(key, this.subscriptions)) {
466
- this.subscriptions.push(key);
467
- this.events.subscribe(key, this.subscribeLoggedUserLogout);
562
+ this.subscriptions.push(key)
563
+ this.events.subscribe(key, this.subscribeLoggedUserLogout)
468
564
  }
469
565
 
470
566
  // key = 'readAllMessages';
@@ -473,10 +569,10 @@ export class ConversationListPage implements OnInit {
473
569
  // this.events.subscribe(key, this.readAllMessages);
474
570
  // }
475
571
 
476
- key = 'profileInfoButtonClick:changed';
572
+ key = 'profileInfoButtonClick:changed'
477
573
  if (!isInArray(key, this.subscriptions)) {
478
- this.subscriptions.push(key);
479
- this.events.subscribe(key, this.subscribeProfileInfoButtonClicked);
574
+ this.subscriptions.push(key)
575
+ this.events.subscribe(key, this.subscribeProfileInfoButtonClicked)
480
576
  }
481
577
 
482
578
  // this.conversationsHandlerService.readAllMessages.subscribe((conversationId: string) => {
@@ -484,67 +580,89 @@ export class ConversationListPage implements OnInit {
484
580
  // this.readAllMessages(conversationId);
485
581
  // });
486
582
 
487
- this.conversationsHandlerService.conversationAdded.subscribe((conversation: ConversationModel) => {
488
- // this.logger.log('[CONVS-LIST-PAGE] ***** conversationsAdded *****', conversation);
489
- // that.conversationsChanged(conversations);
490
- if (conversation) {
491
- this.onImageLoaded(conversation)
492
- this.onConversationLoaded(conversation)
493
- }
494
- });
495
-
496
- this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
497
- // this.logger.log('[CONVS-LIST-PAGE] ***** subscribeConversationChanged *****', conversation);
498
- // that.conversationsChanged(conversations)
499
- if (conversation) {
500
- this.onImageLoaded(conversation)
501
- this.onConversationLoaded(conversation)
502
- }
503
- });
504
-
505
- this.conversationsHandlerService.conversationRemoved.subscribe((conversation: ConversationModel) => {
506
- this.logger.log('[CONVS-LIST-PAGE] ***** conversationsRemoved *****', conversation);
507
- });
508
-
509
- this.archivedConversationsHandlerService.archivedConversationAdded.subscribe((conversation: ConversationModel) => {
510
- this.logger.log('[CONVS-LIST-PAGE] ***** archivedConversationAdded *****', conversation);
511
- // that.conversationsChanged(conversations);
512
- if (conversation) {
513
- this.onImageLoaded(conversation)
514
- this.onConversationLoaded(conversation)
515
- }
516
- });
583
+ this.conversationsHandlerService.conversationAdded.subscribe(
584
+ (conversation: ConversationModel) => {
585
+ // this.logger.log('[CONVS-LIST-PAGE] ***** conversationsAdded *****', conversation);
586
+ // that.conversationsChanged(conversations);
587
+ if (conversation) {
588
+ this.onImageLoaded(conversation)
589
+ this.onConversationLoaded(conversation)
590
+ }
591
+ },
592
+ )
593
+
594
+ this.conversationsHandlerService.conversationChanged.subscribe(
595
+ (conversation: ConversationModel) => {
596
+ // this.logger.log('[CONVS-LIST-PAGE] ***** subscribeConversationChanged *****', conversation);
597
+ // that.conversationsChanged(conversations)
598
+ if (conversation) {
599
+ this.onImageLoaded(conversation)
600
+ this.onConversationLoaded(conversation)
601
+ }
602
+ },
603
+ )
604
+
605
+ this.conversationsHandlerService.conversationRemoved.subscribe(
606
+ (conversation: ConversationModel) => {
607
+ this.logger.log(
608
+ '[CONVS-LIST-PAGE] ***** conversationsRemoved *****',
609
+ conversation,
610
+ )
611
+ },
612
+ )
613
+
614
+ this.archivedConversationsHandlerService.archivedConversationAdded.subscribe(
615
+ (conversation: ConversationModel) => {
616
+ this.logger.log(
617
+ '[CONVS-LIST-PAGE] ***** archivedConversationAdded *****',
618
+ conversation,
619
+ )
620
+ // that.conversationsChanged(conversations);
621
+ if (conversation) {
622
+ this.onImageLoaded(conversation)
623
+ this.onConversationLoaded(conversation)
624
+ }
625
+ },
626
+ )
517
627
  }
518
628
 
519
629
  // ------------------------------------------------------------------------------------
520
630
  // @ SUBSCRIBE TO LOGGED USER LOGOUT ??????????? SEEMS NOT USED ?????????????????
521
631
  // ------------------------------------------------------------------------------------
522
632
  subscribeLoggedUserLogout = () => {
523
- this.conversations = [];
524
- this.uidConvSelected = null;
525
- this.logger.log('[CONVS-LIST-PAGE] - subscribeLoggedUserLogout conversations ', this.conversations);
526
- this.logger.log('[CONVS-LIST-PAGE] - subscribeLoggedUserLogout uidConvSelected ', this.uidConvSelected);
633
+ this.conversations = []
634
+ this.uidConvSelected = null
635
+ this.logger.log(
636
+ '[CONVS-LIST-PAGE] - subscribeLoggedUserLogout conversations ',
637
+ this.conversations,
638
+ )
639
+ this.logger.log(
640
+ '[CONVS-LIST-PAGE] - subscribeLoggedUserLogout uidConvSelected ',
641
+ this.uidConvSelected,
642
+ )
527
643
  }
528
644
 
529
-
530
-
531
645
  // ------------------------------------------------------------------------------------
532
646
  // @ SUBSCRIBE TO CONVERSATION CHANGED ??????????? SEEMS NOT USED ?????????????????
533
647
  // ------------------------------------------------------------------------------------
534
648
  conversationsChanged = (conversations: ConversationModel[]) => {
535
- this.numberOpenConv = this.conversationsHandlerService.countIsNew();
536
- this.logger.log('[CONVS-LIST-PAGE] - conversationsChanged - NUMB OF CONVERSATIONS: ', this.numberOpenConv);
649
+ this.numberOpenConv = this.conversationsHandlerService.countIsNew()
650
+ this.logger.log(
651
+ '[CONVS-LIST-PAGE] - conversationsChanged - NUMB OF CONVERSATIONS: ',
652
+ this.numberOpenConv,
653
+ )
537
654
  // console.log('conversationsChanged »»»»»»»»» uidConvSelected', that.conversations[0], that.uidConvSelected);
538
655
  if (this.uidConvSelected && !this.conversationSelected) {
539
- const conversationSelected = this.conversations.find(item => item.uid === this.uidConvSelected);
656
+ const conversationSelected = this.conversations.find(
657
+ (item) => item.uid === this.uidConvSelected,
658
+ )
540
659
  if (conversationSelected) {
541
- this.conversationSelected = conversationSelected;
542
- this.setUidConvSelected(this.uidConvSelected);
660
+ this.conversationSelected = conversationSelected
661
+ this.setUidConvSelected(this.uidConvSelected)
543
662
  }
544
663
  }
545
664
  }
546
665
 
547
-
548
666
  /**
549
667
  * ::: subscribeChangedConversationSelected :::
550
668
  * evento richiamato quando si seleziona un utente nell'elenco degli user
@@ -554,14 +672,27 @@ export class ConversationListPage implements OnInit {
554
672
  // !!!!!! IS USED? ?????
555
673
  // ------------------------------
556
674
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
557
- this.logger.log('[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl', user, type);
558
- this.uidConvSelected = user.uid;
559
- this.logger.log('[CONVS-LIST-PAGE] ************** uidConvSelected ', this.uidConvSelected);
675
+ this.logger.log(
676
+ '[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl',
677
+ user,
678
+ type,
679
+ )
680
+ this.uidConvSelected = user.uid
681
+ this.logger.log(
682
+ '[CONVS-LIST-PAGE] ************** uidConvSelected ',
683
+ this.uidConvSelected,
684
+ )
560
685
  // this.conversationsHandlerService.uidConvSelected = user.uid;
561
- const conversationSelected = this.conversations.find(item => item.uid === this.uidConvSelected);
686
+ const conversationSelected = this.conversations.find(
687
+ (item) => item.uid === this.uidConvSelected,
688
+ )
562
689
  if (conversationSelected) {
563
- this.logger.log('[CONVS-LIST-PAGE] --> uidConvSelected: ', this.conversationSelected, this.uidConvSelected);
564
- this.conversationSelected = conversationSelected;
690
+ this.logger.log(
691
+ '[CONVS-LIST-PAGE] --> uidConvSelected: ',
692
+ this.conversationSelected,
693
+ this.uidConvSelected,
694
+ )
695
+ this.conversationSelected = conversationSelected
565
696
  }
566
697
  // this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
567
698
  }
@@ -571,22 +702,28 @@ export class ConversationListPage implements OnInit {
571
702
  * evento richiamato quando si seleziona bottone profile-info-modal
572
703
  */
573
704
  subscribeProfileInfoButtonClicked = (event: string) => {
574
- this.logger.log('[CONVS-LIST-PAGE] ************** subscribeProfileInfoButtonClicked: ', event);
705
+ this.logger.log(
706
+ '[CONVS-LIST-PAGE] ************** subscribeProfileInfoButtonClicked: ',
707
+ event,
708
+ )
575
709
  if (event === 'displayArchived') {
576
- this.initArchivedConversationsHandler();
710
+ this.initArchivedConversationsHandler()
577
711
  // this.openArchivedConversationsModal()
578
712
  this.conversationType = 'archived'
579
713
 
580
714
  // let storedArchivedConv = localStorage.getItem('activeConversationSelected');
581
- const keys = ['LABEL_ARCHIVED'];
715
+ const keys = ['LABEL_ARCHIVED']
582
716
  // const keys = ['History'];
583
-
584
- this.headerTitle = this.translateService.translateLanguage(keys).get(keys[0]);
585
717
 
718
+ this.headerTitle = this.translateService
719
+ .translateLanguage(keys)
720
+ .get(keys[0])
586
721
  } else if (event === 'displayContact') {
587
722
  this.conversationType = 'archived'
588
- const keys = ['LABEL_CONTACTS'];
589
- this.headerTitle = this.translateService.translateLanguage(keys).get(keys[0]);
723
+ const keys = ['LABEL_CONTACTS']
724
+ this.headerTitle = this.translateService
725
+ .translateLanguage(keys)
726
+ .get(keys[0])
590
727
  }
591
728
  }
592
729
 
@@ -600,12 +737,10 @@ export class ConversationListPage implements OnInit {
600
737
  // console.log('ConversationListPage - storedActiveConv Objct: ', storedActiveConvObjct);
601
738
  // this.navigateByUrl('active', storedActiveConvObjct.uid)
602
739
  // } else {
603
- // // da implementare se nn c'è stata nessuna conv attive selezionata
740
+ // // da implementare se nn c'è stata nessuna conv attive selezionata
604
741
  // }
605
-
606
742
  }
607
743
 
608
-
609
744
  // ------------------------------------------------------------------//
610
745
  // END SUBSCRIPTIONS
611
746
  // ------------------------------------------------------------------//
@@ -627,8 +762,6 @@ export class ConversationListPage implements OnInit {
627
762
  // })
628
763
  // }
629
764
 
630
-
631
-
632
765
  // ------------------------------------------------------------------//
633
766
  // BEGIN FUNCTIONS
634
767
  // ------------------------------------------------------------------//
@@ -636,22 +769,24 @@ export class ConversationListPage implements OnInit {
636
769
  * ::: initialize :::
637
770
  */
638
771
  initialize() {
639
- const appconfig = this.appConfigProvider.getConfig();
640
- this.tenant = appconfig.firebaseConfig.tenant;
641
- this.logger.log('[CONVS-LIST-PAGE] - initialize -> firebaseConfig tenant ', this.tenant);
772
+ const appconfig = this.appConfigProvider.getConfig()
773
+ this.tenant = appconfig.firebaseConfig.tenant
774
+ this.logger.log(
775
+ '[CONVS-LIST-PAGE] - initialize -> firebaseConfig tenant ',
776
+ this.tenant,
777
+ )
642
778
 
643
779
  if (this.tiledeskAuthService.getCurrentUser()) {
644
- this.loggedUserUid = this.tiledeskAuthService.getCurrentUser().uid;
780
+ this.loggedUserUid = this.tiledeskAuthService.getCurrentUser().uid
645
781
  }
646
- this.subscriptions = [];
647
- this.initConversationsHandler();
648
- this.initVariables();
649
- this.initSubscriptions();
782
+ this.subscriptions = []
783
+ this.initConversationsHandler()
784
+ this.initVariables()
785
+ this.initSubscriptions()
650
786
 
651
787
  // this.initHandlerEventEmitter();
652
788
  }
653
789
 
654
-
655
790
  /**
656
791
  * ::: initVariables :::
657
792
  * al caricamento della pagina:
@@ -666,46 +801,61 @@ export class ConversationListPage implements OnInit {
666
801
  // It only works on BSStart.subscribe! it is useful or can be eliminated
667
802
  // --------------------------------------------------------
668
803
  initVariables() {
669
- this.logger.log('[CONVS-LIST-PAGE] uidReciverFromUrl:: ' + this.uidReciverFromUrl);
670
- this.logger.log('[CONVS-LIST-PAGE] loggedUserUid:: ' + this.loggedUserUid);
671
- this.logger.log('[CONVS-LIST-PAGE] tenant:: ' + this.tenant);
672
- if (this.route.component['name'] !== "ConversationListPage") {
673
-
804
+ this.logger.log(
805
+ '[CONVS-LIST-PAGE] uidReciverFromUrl:: ' + this.uidReciverFromUrl,
806
+ )
807
+ this.logger.log('[CONVS-LIST-PAGE] loggedUserUid:: ' + this.loggedUserUid)
808
+ this.logger.log('[CONVS-LIST-PAGE] tenant:: ' + this.tenant)
809
+ if (this.route.component['name'] !== 'ConversationListPage') {
674
810
  if (this.route && this.route.snapshot && this.route.snapshot.firstChild) {
675
- const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
676
- this.logger.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv);
811
+ const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv')
812
+ this.logger.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv)
677
813
  if (IDConv) {
678
- this.setUidConvSelected(IDConv);
814
+ this.setUidConvSelected(IDConv)
679
815
  } else {
680
-
681
- this.logger.log('[CONVS-LIST-PAGE] conversationWith 2 (else): ', IDConv);
816
+ this.logger.log(
817
+ '[CONVS-LIST-PAGE] conversationWith 2 (else): ',
818
+ IDConv,
819
+ )
682
820
  }
683
821
  }
684
822
  }
685
823
  }
686
824
 
687
-
688
-
689
825
  /**
690
826
  * ::: setUidConvSelected :::
691
827
  */
692
- setUidConvSelected(uidConvSelected: string, conversationType?: string,) {
828
+ setUidConvSelected(uidConvSelected: string, conversationType?: string) {
693
829
  this.logger.log('[CONVS-LIST-PAGE] setuidCOnvSelected', uidConvSelected)
694
- this.uidConvSelected = uidConvSelected;
830
+ this.uidConvSelected = uidConvSelected
695
831
  this.logger.log('uidConvSelected', uidConvSelected)
696
832
  // this.conversationsHandlerService.uidConvSelected = uidConvSelected;
697
833
  if (uidConvSelected) {
698
- let conversationSelected;
834
+ let conversationSelected
699
835
  if (conversationType === 'active') {
700
- conversationSelected = this.conversations.find(item => item.uid === this.uidConvSelected);
836
+ conversationSelected = this.conversations.find(
837
+ (item) => item.uid === this.uidConvSelected,
838
+ )
701
839
  } else if (conversationType === 'archived') {
702
- conversationSelected = this.archivedConversations.find(item => item.uid === this.uidConvSelected);
840
+ conversationSelected = this.archivedConversations.find(
841
+ (item) => item.uid === this.uidConvSelected,
842
+ )
703
843
  }
704
844
  if (conversationSelected) {
705
- this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected);
706
- this.logger.log('[CONVS-LIST-PAGE] the conversation ', this.conversationSelected, ' has already been loaded');
707
- this.conversationSelected = conversationSelected;
708
- this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected: ', this.conversationSelected);
845
+ this.logger.log(
846
+ '[CONVS-LIST-PAGE] conversationSelected',
847
+ conversationSelected,
848
+ )
849
+ this.logger.log(
850
+ '[CONVS-LIST-PAGE] the conversation ',
851
+ this.conversationSelected,
852
+ ' has already been loaded',
853
+ )
854
+ this.conversationSelected = conversationSelected
855
+ this.logger.log(
856
+ '[CONVS-LIST-PAGE] setUidConvSelected: ',
857
+ this.conversationSelected,
858
+ )
709
859
  }
710
860
  }
711
861
  }
@@ -714,29 +864,36 @@ export class ConversationListPage implements OnInit {
714
864
  this.logger.log('onConversationSelected conversation', conversation)
715
865
  if (conversation.archived) {
716
866
  this.navigateByUrl('archived', conversation.uid)
717
- this.logger.log('[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ', conversation.uid)
867
+ this.logger.log(
868
+ '[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ',
869
+ conversation.uid,
870
+ )
718
871
  } else {
719
872
  this.navigateByUrl('active', conversation.uid)
720
- this.logger.log('[CONVS-LIST-PAGE] onConversationSelected active conversation.uid ', conversation.uid)
873
+ this.logger.log(
874
+ '[CONVS-LIST-PAGE] onConversationSelected active conversation.uid ',
875
+ conversation.uid,
876
+ )
721
877
  }
722
-
723
878
  }
724
879
 
725
880
  onImageLoaded(conversation: any) {
726
881
  // this.logger.log('[CONVS-LIST-PAGE] onImageLoaded', conversation)
727
- let conversation_with_fullname = conversation.sender_fullname;
728
- let conversation_with = conversation.sender;
882
+ let conversation_with_fullname = conversation.sender_fullname
883
+ let conversation_with = conversation.sender
729
884
  if (conversation.sender === this.loggedUserUid) {
730
- conversation_with = conversation.recipient;
731
- conversation_with_fullname = conversation.recipient_fullname;
885
+ conversation_with = conversation.recipient
886
+ conversation_with_fullname = conversation.recipient_fullname
732
887
  } else if (isGroup(conversation)) {
733
888
  // conversation_with_fullname = conv.sender_fullname;
734
889
  // conv.last_message_text = conv.last_message_text;
735
- conversation_with = conversation.recipient;
736
- conversation_with_fullname = conversation.recipient_fullname;
890
+ conversation_with = conversation.recipient
891
+ conversation_with_fullname = conversation.recipient_fullname
737
892
  }
738
- if (!conversation_with.startsWith("support-group")) {
739
- conversation.image = this.imageRepoService.getImagePhotoUrl(conversation_with)
893
+ if (!conversation_with.startsWith('support-group')) {
894
+ conversation.image = this.imageRepoService.getImagePhotoUrl(
895
+ conversation_with,
896
+ )
740
897
  }
741
898
  }
742
899
 
@@ -747,49 +904,59 @@ export class ConversationListPage implements OnInit {
747
904
  // this.ionContentConvList.scrollToTop(0);
748
905
  // }
749
906
 
750
- const keys = ['YOU', 'SENT_AN_IMAGE', 'SENT_AN_ATTACHMENT'];
751
- const translationMap = this.translateService.translateLanguage(keys);
907
+ const keys = ['YOU', 'SENT_AN_IMAGE', 'SENT_AN_ATTACHMENT']
908
+ const translationMap = this.translateService.translateLanguage(keys)
752
909
  // Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly in the convesations list
753
910
 
754
- var regex = /<br\s*[\/]?>/gi;
911
+ var regex = /<br\s*[\/]?>/gi
755
912
  if (conversation && conversation.last_message_text) {
756
- conversation.last_message_text = conversation.last_message_text.replace(regex, "")
913
+ conversation.last_message_text = conversation.last_message_text.replace(
914
+ regex,
915
+ '',
916
+ )
757
917
 
758
918
  //FIX-BUG: 'YOU: YOU: YOU: text' on last-message-text in conversation-list
759
- if (conversation.sender === this.loggedUserUid && !conversation.last_message_text.includes(': ')) {
919
+ if (
920
+ conversation.sender === this.loggedUserUid &&
921
+ !conversation.last_message_text.includes(': ')
922
+ ) {
760
923
  // this.logger.log('[CONVS-LIST-PAGE] onConversationLoaded', conversation)
761
924
 
762
- if (conversation.type !== "image" && conversation.type !== "file") {
763
- conversation.last_message_text = translationMap.get('YOU') + ': ' + conversation.last_message_text;
764
-
765
- } else if (conversation.type === "image") {
766
-
925
+ if (conversation.type !== 'image' && conversation.type !== 'file') {
926
+ conversation.last_message_text =
927
+ translationMap.get('YOU') + ': ' + conversation.last_message_text
928
+ } else if (conversation.type === 'image') {
767
929
  // this.logger.log('[CONVS-LIST-PAGE] HAS SENT AN IMAGE');
768
930
  // this.logger.log("[CONVS-LIST-PAGE] translationMap.get('YOU')")
769
- const SENT_AN_IMAGE = conversation['last_message_text'] = translationMap.get('SENT_AN_IMAGE')
931
+ const SENT_AN_IMAGE = (conversation[
932
+ 'last_message_text'
933
+ ] = translationMap.get('SENT_AN_IMAGE'))
770
934
 
771
- conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_IMAGE;
772
-
773
- } else if (conversation.type === "file") {
935
+ conversation.last_message_text =
936
+ translationMap.get('YOU') + ': ' + SENT_AN_IMAGE
937
+ } else if (conversation.type === 'file') {
774
938
  // this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
775
- const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
776
- conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_ATTACHMENT;
939
+ const SENT_AN_ATTACHMENT = (conversation[
940
+ 'last_message_text'
941
+ ] = translationMap.get('SENT_AN_ATTACHMENT'))
942
+ conversation.last_message_text =
943
+ translationMap.get('YOU') + ': ' + SENT_AN_ATTACHMENT
777
944
  }
778
945
  } else {
779
- if (conversation.type === "image") {
780
-
946
+ if (conversation.type === 'image') {
781
947
  // this.logger.log('[CONVS-LIST-PAGE] HAS SENT AN IMAGE');
782
948
  // this.logger.log("[CONVS-LIST-PAGE] translationMap.get('YOU')")
783
- const SENT_AN_IMAGE = conversation['last_message_text'] = translationMap.get('SENT_AN_IMAGE')
949
+ const SENT_AN_IMAGE = (conversation[
950
+ 'last_message_text'
951
+ ] = translationMap.get('SENT_AN_IMAGE'))
784
952
 
785
- conversation.last_message_text = SENT_AN_IMAGE;
786
-
787
- }
788
- else if (conversation.type === "file") {
953
+ conversation.last_message_text = SENT_AN_IMAGE
954
+ } else if (conversation.type === 'file') {
789
955
  // this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
790
- const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
791
- conversation.last_message_text = SENT_AN_ATTACHMENT;
792
-
956
+ const SENT_AN_ATTACHMENT = (conversation[
957
+ 'last_message_text'
958
+ ] = translationMap.get('SENT_AN_ATTACHMENT'))
959
+ conversation.last_message_text = SENT_AN_ATTACHMENT
793
960
  }
794
961
  }
795
962
  }
@@ -799,59 +966,103 @@ export class ConversationListPage implements OnInit {
799
966
  // this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 1')
800
967
  // var regex = /^(^|[\n\r])\s*1\.\s.*\s+1\.\s$/
801
968
  // let matchRegex = false
802
- // if (regex.test(last_message_text)) {
969
+ // if (regex.test(last_message_text)) {
803
970
  // this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 2')
804
971
  // matchRegex = true
805
972
  // return matchRegex
806
973
  // }
807
974
  // }
808
975
 
809
-
810
976
  navigateByUrl(converationType: string, uidConvSelected: string) {
811
- this.logger.log('[CONVS-LIST-PAGE] calling navigateByUrl: ');
812
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected);
813
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl run this.setUidConvSelected');
814
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.uidConvSelected ', this.uidConvSelected);
815
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected ', this.conversationSelected)
816
-
817
- this.setUidConvSelected(uidConvSelected, converationType);
977
+ this.logger.log('[CONVS-LIST-PAGE] calling navigateByUrl: ')
978
+ this.logger.log(
979
+ '[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ',
980
+ uidConvSelected,
981
+ )
982
+ this.logger.log(
983
+ '[CONVS-LIST-PAGE] navigateByUrl run this.setUidConvSelected',
984
+ )
985
+ this.logger.log(
986
+ '[CONVS-LIST-PAGE] navigateByUrl this.uidConvSelected ',
987
+ this.uidConvSelected,
988
+ )
989
+ this.logger.log(
990
+ '[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected ',
991
+ this.conversationSelected,
992
+ )
993
+
994
+ this.setUidConvSelected(uidConvSelected, converationType)
818
995
  if (checkPlatformIsMobile()) {
819
- this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
820
- this.logger.log('[CONVS-LIST-PAGE] DESKTOP (window >= 768)', this.navService);
821
- let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
996
+ this.logger.log(
997
+ '[CONVS-LIST-PAGE] checkPlatformIsMobile(): ',
998
+ checkPlatformIsMobile(),
999
+ )
1000
+ this.logger.log(
1001
+ '[CONVS-LIST-PAGE] DESKTOP (window >= 768)',
1002
+ this.navService,
1003
+ )
1004
+ let pageUrl =
1005
+ 'conversation-detail/' +
1006
+ this.uidConvSelected +
1007
+ '/' +
1008
+ this.conversationSelected.conversation_with_fullname +
1009
+ '/' +
1010
+ converationType
822
1011
  this.logger.log('[CONVS-LIST-PAGE] pageURL', pageUrl)
823
- this.router.navigateByUrl(pageUrl);
1012
+ this.router.navigateByUrl(pageUrl)
824
1013
  } else {
825
- this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
826
- this.logger.log('[CONVS-LIST-PAGE] MOBILE (window < 768) ', this.navService);
827
- let pageUrl = 'conversation-detail/' + this.uidConvSelected;
828
- if (this.conversationSelected && this.conversationSelected.conversation_with_fullname) {
829
- pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
1014
+ this.logger.log(
1015
+ '[CONVS-LIST-PAGE] checkPlatformIsMobile(): ',
1016
+ checkPlatformIsMobile(),
1017
+ )
1018
+ this.logger.log(
1019
+ '[CONVS-LIST-PAGE] MOBILE (window < 768) ',
1020
+ this.navService,
1021
+ )
1022
+ let pageUrl = 'conversation-detail/' + this.uidConvSelected
1023
+ if (
1024
+ this.conversationSelected &&
1025
+ this.conversationSelected.conversation_with_fullname
1026
+ ) {
1027
+ pageUrl =
1028
+ 'conversation-detail/' +
1029
+ this.uidConvSelected +
1030
+ '/' +
1031
+ this.conversationSelected.conversation_with_fullname +
1032
+ '/' +
1033
+ converationType
830
1034
  }
831
- this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected navigateByUrl--->: ', pageUrl);
832
- this.router.navigateByUrl(pageUrl);
1035
+ this.logger.log(
1036
+ '[CONVS-LIST-PAGE] setUidConvSelected navigateByUrl--->: ',
1037
+ pageUrl,
1038
+ )
1039
+ this.router.navigateByUrl(pageUrl)
833
1040
  }
834
1041
  }
835
1042
 
836
-
837
1043
  // ---------------------------------------------------------
838
1044
  // Opens the list of contacts for direct convs
839
1045
  // ---------------------------------------------------------
840
1046
  openContactsDirectory(event: any) {
841
- const TOKEN = this.tiledeskAuthService.getTiledeskToken();
842
- this.logger.log('[CONVS-LIST-PAGE] openContactsDirectory', TOKEN);
1047
+ const TOKEN = this.tiledeskAuthService.getTiledeskToken()
1048
+ this.logger.log('[CONVS-LIST-PAGE] openContactsDirectory', TOKEN)
843
1049
  if (checkPlatformIsMobile()) {
844
- presentModal(this.modalController, ContactsDirectoryPage, { token: TOKEN });
1050
+ presentModal(this.modalController, ContactsDirectoryPage, {
1051
+ token: TOKEN,
1052
+ })
845
1053
  } else {
846
- this.navService.push(ContactsDirectoryPage, { token: TOKEN });
1054
+ this.navService.push(ContactsDirectoryPage, { token: TOKEN })
847
1055
  }
848
1056
  }
849
1057
 
850
1058
  closeContactsDirectory() {
851
1059
  try {
852
- closeModal(this.modalController);
1060
+ closeModal(this.modalController)
853
1061
  } catch (err) {
854
- this.logger.error('[CONVS-LIST-PAGE] closeContactsDirectory -> error:', err);
1062
+ this.logger.error(
1063
+ '[CONVS-LIST-PAGE] closeContactsDirectory -> error:',
1064
+ err,
1065
+ )
855
1066
  }
856
1067
  }
857
1068
 
@@ -859,8 +1070,8 @@ export class ConversationListPage implements OnInit {
859
1070
  // Opens logged user profile modal
860
1071
  // ---------------------------------------------------------
861
1072
  openProfileInfo(event: any) {
862
- const TOKEN = this.messagingAuthService.getToken();
863
- this.logger.log('[CONVS-LIST-PAGE] open ProfileInfoPage TOKEN ', TOKEN);
1073
+ const TOKEN = this.messagingAuthService.getToken()
1074
+ this.logger.log('[CONVS-LIST-PAGE] open ProfileInfoPage TOKEN ', TOKEN)
864
1075
  if (checkPlatformIsMobile()) {
865
1076
  presentModal(this.modalController, ProfileInfoPage, { token: TOKEN })
866
1077
  } else {
@@ -868,102 +1079,186 @@ export class ConversationListPage implements OnInit {
868
1079
  }
869
1080
  }
870
1081
 
1082
+ listenToCloseConvFromHeaderConversation() {
1083
+ this.events.subscribe('conversation:closed', (convId) => {
1084
+ this.logger.log('[CONVS-LIST-PAGE] hasclosedconversation convId', convId)
871
1085
 
1086
+ const conversation = this.conversations.find(
1087
+ (conv) => conv.uid === convId,
1088
+ )
1089
+ this.logger.log('[CONVS-LIST-PAGE] hasclosedconversation conversation', conversation)
1090
+ this.onCloseConversation(conversation)
1091
+ })
1092
+ }
872
1093
 
873
1094
  // ----------------------------------------------------------------------------------------------
874
1095
  // onCloseConversation
875
1096
  // https://github.com/chat21/chat21-cloud-functions/blob/master/docs/api.md#delete-a-conversation
876
1097
  // ----------------------------------------------------------------------------------------------
877
1098
  onCloseConversation(conversation: ConversationModel) {
1099
+ this.logger.log('[CONVS-LIST-PAGE] onCloseConversation conversation', conversation)
1100
+
878
1101
  // -------------------------------------------------------------------------------------
879
- // Fix the display of the message "No conversation yet" when a conversation is archived
880
- // but there are others in the list (happens when loadingIsActive is set to false because
1102
+ // Fix the display of the message "No conversation yet" when a conversation is archived
1103
+ // but there are others in the list (happens when loadingIsActive is set to false because
881
1104
  // when is called the initConversationsHandler method there is not conversations)
882
1105
  // -------------------------------------------------------------------------------------
883
- this.loadingIsActive = false;
1106
+ this.loadingIsActive = false
884
1107
  // console.log('CONVS - CONV-LIST-PAGE onCloseConversation CONVS: ', conversation)
885
1108
  this.logger.log('[CONVS-LIST-PAGE] onCloseConversation loadingIsActive: ', this.loadingIsActive)
1109
+ if (conversation) {
1110
+ const conversationId = conversation.uid
886
1111
 
887
- const conversationId = conversation.uid;
888
-
889
- this.logger.log('[CONVS-LIST-PAGE] onCloseConversation conversationId: ', conversationId)
890
-
891
- const conversationWith_segments = conversationId.split('-');
892
- this.logger.log('[CONVS-LIST-PAGE] - conversationId_segments: ', conversationWith_segments);
1112
+ this.logger.log( '[CONVS-LIST-PAGE] onCloseConversation conversationId: ', conversationId )
893
1113
 
894
- // Removes the last element of the array if is = to the separator
895
- if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
896
- conversationWith_segments.pop();
897
- }
1114
+ const conversationWith_segments = conversationId.split('-')
1115
+ this.logger.log(
1116
+ '[CONVS-LIST-PAGE] - conversationId_segments: ',
1117
+ conversationWith_segments,
1118
+ )
898
1119
 
899
- if (conversationWith_segments.length === 4) {
900
- const lastArrayElement = conversationWith_segments[conversationWith_segments.length - 1]
901
- this.logger.log('[CONVS-LIST-PAGE] - lastArrayElement ', lastArrayElement);
902
- this.logger.log('[CONVS-LIST-PAGE] - lastArrayElement length', lastArrayElement.length);
903
- if (lastArrayElement.length !== 32) {
904
- conversationWith_segments.pop();
1120
+ // Removes the last element of the array if is = to the separator
1121
+ if (
1122
+ conversationWith_segments[conversationWith_segments.length - 1] === ''
1123
+ ) {
1124
+ conversationWith_segments.pop()
905
1125
  }
906
- }
907
1126
 
908
- if (conversationId.startsWith("support-group")) {
909
- let project_id = ''
910
1127
  if (conversationWith_segments.length === 4) {
911
- project_id = conversationWith_segments[2];
912
-
913
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
914
- this.archiveSupportGroupConv(tiledeskToken, project_id, conversationId);
1128
+ const lastArrayElement =
1129
+ conversationWith_segments[conversationWith_segments.length - 1]
1130
+ this.logger.log(
1131
+ '[CONVS-LIST-PAGE] - lastArrayElement ',
1132
+ lastArrayElement,
1133
+ )
1134
+ this.logger.log(
1135
+ '[CONVS-LIST-PAGE] - lastArrayElement length',
1136
+ lastArrayElement.length,
1137
+ )
1138
+ if (lastArrayElement.length !== 32) {
1139
+ conversationWith_segments.pop()
1140
+ }
1141
+ }
915
1142
 
1143
+ if (conversationId.startsWith('support-group')) {
1144
+ let project_id = ''
1145
+ if (conversationWith_segments.length === 4) {
1146
+ project_id = conversationWith_segments[2]
1147
+
1148
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1149
+ this.archiveSupportGroupConv(
1150
+ tiledeskToken,
1151
+ project_id,
1152
+ conversationId,
1153
+ )
1154
+ } else {
1155
+ this.getProjectIdByConversationWith(conversationId)
1156
+ }
916
1157
  } else {
917
- this.getProjectIdByConversationWith(conversationId)
1158
+ this.conversationsHandlerService.archiveConversation(conversationId)
918
1159
  }
919
- } else {
920
- this.conversationsHandlerService.archiveConversation(conversationId)
921
1160
  }
922
1161
  }
923
1162
 
924
1163
  getProjectIdByConversationWith(conversationId: string) {
925
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
926
-
927
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationId).subscribe(res => {
928
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT RES', res);
929
-
930
- if (res) {
931
- const project_id = res.id_project
932
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT project_id', project_id);
933
- this.archiveSupportGroupConv(tiledeskToken, project_id, conversationId);
934
- }
935
-
936
- }, (error) => {
937
- this.logger.error('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error);
938
-
939
- }, () => {
940
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *');
941
-
942
- });
1164
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1165
+
1166
+ this.tiledeskService
1167
+ .getProjectIdByConvRecipient(tiledeskToken, conversationId)
1168
+ .subscribe(
1169
+ (res) => {
1170
+ this.logger.log(
1171
+ '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT RES',
1172
+ res,
1173
+ )
1174
+
1175
+ if (res) {
1176
+ const project_id = res.id_project
1177
+ this.logger.log(
1178
+ '[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT project_id',
1179
+ project_id,
1180
+ )
1181
+ this.archiveSupportGroupConv(
1182
+ tiledeskToken,
1183
+ project_id,
1184
+ conversationId,
1185
+ )
1186
+ }
1187
+ },
1188
+ (error) => {
1189
+ this.logger.error(
1190
+ '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT - ERROR ',
1191
+ error,
1192
+ )
1193
+ },
1194
+ () => {
1195
+ this.logger.log(
1196
+ '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
1197
+ )
1198
+ },
1199
+ )
943
1200
  }
944
1201
 
945
1202
  archiveSupportGroupConv(tiledeskToken, project_id, conversationId) {
946
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation projectId: ', project_id)
947
- this.tiledeskService.closeSupportGroup(tiledeskToken, project_id, conversationId).subscribe(res => {
948
-
949
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup RES', res);
950
- }, (error) => {
951
- this.logger.error('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR ', error);
952
- }, () => {
953
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup * COMPLETE *');
954
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS ', this.conversations)
955
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS LENGHT ', this.conversations.length)
956
- });
957
-
1203
+ this.logger.log(
1204
+ '[CONVS-LIST-PAGE] - onCloseConversation projectId: ',
1205
+ project_id,
1206
+ )
1207
+ this.tiledeskService
1208
+ .closeSupportGroup(tiledeskToken, project_id, conversationId)
1209
+ .subscribe(
1210
+ (res) => {
1211
+ this.archiveActionNotAllowed = false
1212
+ this.logger.log(
1213
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup RES',
1214
+ res,
1215
+ )
1216
+ },
1217
+ (error) => {
1218
+ this.logger.error(
1219
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR ',
1220
+ error,
1221
+ )
1222
+ this.logger.error(
1223
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR error.error.msg ',
1224
+ error.error.msg,
1225
+ )
1226
+ this.logger.error(
1227
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR error.status ',
1228
+ error.status,
1229
+ )
1230
+ if (error.error.msg === 'you dont belong to the project.') {
1231
+ this.archiveActionNotAllowed = true
1232
+ }
1233
+ },
1234
+ () => {
1235
+ this.logger.log(
1236
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup * COMPLETE *',
1237
+ )
1238
+ this.logger.log(
1239
+ '[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS ',
1240
+ this.conversations,
1241
+ )
1242
+ this.logger.log(
1243
+ '[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS LENGHT ',
1244
+ this.conversations.length,
1245
+ )
1246
+ this.events.publish('conversationhasbeenclosed', conversationId)
1247
+ },
1248
+ )
958
1249
  }
959
1250
 
1251
+ onCloseAlert($event) {
1252
+ this.logger.log('[CONVS-LIST-PAGE] - onCloseAlert ', $event)
1253
+ this.archiveActionNotAllowed = false
1254
+ }
960
1255
 
961
1256
  public generateFake(count: number): Array<number> {
962
- const indexes = [];
1257
+ const indexes = []
963
1258
  for (let i = 0; i < count; i++) {
964
- indexes.push(i);
1259
+ indexes.push(i)
965
1260
  }
966
- return indexes;
1261
+ return indexes
967
1262
  }
968
1263
 
969
1264
  // ------------------------------------------------------------------
@@ -979,7 +1274,6 @@ export class ConversationListPage implements OnInit {
979
1274
  // this.logger.log('[CONVS-LIST-PAGE] openArchivedConversationsPage');
980
1275
  // }
981
1276
 
982
-
983
1277
  // // info page
984
1278
  // returnCloseInfoPage() {
985
1279
  // this.logger.log('[CONVS-LIST-PAGE] returnCloseInfoPage');
@@ -988,7 +1282,6 @@ export class ConversationListPage implements OnInit {
988
1282
 
989
1283
  // }
990
1284
 
991
-
992
1285
  // private navigatePage() {
993
1286
  // this.logger.log('[CONVS-LIST-PAGE] navigatePage:: >>>> conversationSelected ', this.conversationSelected);
994
1287
  // let urlPage = 'detail/';
@@ -1009,7 +1302,6 @@ export class ConversationListPage implements OnInit {
1009
1302
  // this.navService.openPage(urlPage, ConversationDetailPage, navigationExtras);
1010
1303
  // }
1011
1304
 
1012
-
1013
1305
  // openDetailsWithState(conversationSelected) {
1014
1306
  // console.log('openDetailsWithState:: >>>> conversationSelected ', conversationSelected);
1015
1307
  // let navigationExtras: NavigationExtras = {
@@ -1038,8 +1330,6 @@ export class ConversationListPage implements OnInit {
1038
1330
  // this.initialize();
1039
1331
  // }
1040
1332
 
1041
-
1042
-
1043
1333
  /**
1044
1334
  * ::: conversationsChanged :::
1045
1335
  * evento richiamato su add, change, remove dell'elenco delle conversazioni
@@ -1047,15 +1337,13 @@ export class ConversationListPage implements OnInit {
1047
1337
  * 2 - aggiorno il conto delle nuove conversazioni
1048
1338
  * 4 - se esiste un uidReciverFromUrl (passato nell'url)
1049
1339
  * e se esiste una conversazione con lo stesso id di uidReciverFromUrl
1050
- * imposto questa come conversazione attiva (operazione da fare una sola volta al caricamento delle conversazioni)
1340
+ * imposto questa come conversazione attiva (operazione da fare una sola volta al caricamento delle conversazioni)
1051
1341
  * e la carico nella pagina di dettaglio e azzero la variabile uidReciverFromUrl!!!
1052
1342
  * 5 - altrimenti se esiste una conversazione con lo stesso id della conversazione attiva
1053
- * e la pagina di dettaglio è vuota (placeholder), carico la conversazione attiva (uidConvSelected) nella pagina di dettaglio
1343
+ * e la pagina di dettaglio è vuota (placeholder), carico la conversazione attiva (uidConvSelected) nella pagina di dettaglio
1054
1344
  * (operazione da fare una sola volta al caricamento delle conversazioni)
1055
1345
  */
1056
1346
 
1057
-
1058
-
1059
1347
  // ------------------------------------------------------------------------------------
1060
1348
  // ::: readAllMessages ::: ??????????? SEEMS NOT USED ?????????????????
1061
1349
  // when all chat messages are displayed,