@chat21/chat21-ionic 3.0.61-rc5 → 3.0.61-rc7

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 (58) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/config.xml +5 -5
  3. package/deploy_pre.sh +10 -10
  4. package/deploy_prod.sh +5 -1
  5. package/package.json +6 -6
  6. package/resources/{Android → android}/icon/drawable-hdpi-icon.png +0 -0
  7. package/resources/{Android → android}/icon/drawable-ldpi-icon.png +0 -0
  8. package/resources/{Android → android}/icon/drawable-mdpi-icon.png +0 -0
  9. package/resources/{Android → android}/icon/drawable-xhdpi-icon.png +0 -0
  10. package/resources/{Android → android}/icon/drawable-xxhdpi-icon.png +0 -0
  11. package/resources/{Android → android}/icon/drawable-xxxhdpi-icon.png +0 -0
  12. package/resources/{Android → android}/icon.png +0 -0
  13. package/resources/{Android → android}/splash/drawable-land-hdpi-screen.png +0 -0
  14. package/resources/{Android → android}/splash/drawable-land-ldpi-screen.png +0 -0
  15. package/resources/{Android → android}/splash/drawable-land-mdpi-screen.png +0 -0
  16. package/resources/{Android → android}/splash/drawable-land-xhdpi-screen.png +0 -0
  17. package/resources/{Android → android}/splash/drawable-land-xxhdpi-screen.png +0 -0
  18. package/resources/{Android → android}/splash/drawable-land-xxxhdpi-screen.png +0 -0
  19. package/resources/{Android → android}/splash/drawable-port-hdpi-screen.png +0 -0
  20. package/resources/{Android → android}/splash/drawable-port-ldpi-screen.png +0 -0
  21. package/resources/{Android → android}/splash/drawable-port-mdpi-screen.png +0 -0
  22. package/resources/{Android → android}/splash/drawable-port-xhdpi-screen.png +0 -0
  23. package/resources/{Android → android}/splash/drawable-port-xxhdpi-screen.png +0 -0
  24. package/resources/{Android → android}/splash/drawable-port-xxxhdpi-screen.png +0 -0
  25. package/resources/{Android → android}/splash.png +0 -0
  26. package/src/app/app.component.html +2 -2
  27. package/src/app/app.component.scss +2 -1
  28. package/src/app/app.component.ts +22 -11
  29. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +78 -15
  30. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +4 -3
  31. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +1 -1
  32. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -3
  33. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +12 -2
  34. package/src/app/components/sidebar/sidebar.component.html +119 -66
  35. package/src/app/components/sidebar/sidebar.component.scss +41 -3
  36. package/src/app/components/sidebar/sidebar.component.ts +108 -30
  37. package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +9 -1
  38. package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +25 -17
  39. package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +92 -34
  40. package/src/app/pages/conversation-detail/conversation-detail.page.html +2 -1
  41. package/src/app/pages/conversation-detail/conversation-detail.page.ts +1289 -783
  42. package/src/app/pages/conversations-list/conversations-list.page.html +3 -1
  43. package/src/app/pages/conversations-list/conversations-list.page.ts +28 -18
  44. package/src/app/pages/loader-preview/loader-preview.page.ts +235 -166
  45. package/src/app/pages/profile-info/profile-info.page.scss +1 -1
  46. package/src/app/services/tiledesk/tiledesk.service.ts +19 -0
  47. package/src/assets/i18n/de.json +9 -7
  48. package/src/assets/i18n/en.json +5 -3
  49. package/src/assets/i18n/es.json +4 -2
  50. package/src/assets/i18n/fr.json +7 -5
  51. package/src/assets/i18n/it.json +4 -2
  52. package/src/assets/i18n/pt.json +4 -2
  53. package/src/assets/i18n/ru.json +5 -3
  54. package/src/assets/i18n/tr.json +4 -2
  55. package/src/chat21-core/utils/constants.ts +4 -1
  56. package/src/global.scss +32 -67
  57. package/publish_pre.sh +0 -33
  58. package/publish_prod.sh +0 -33
@@ -1,155 +1,189 @@
1
- import { URL_SOUND_LIST_CONVERSATION } from './../../../chat21-core/utils/constants';
2
- import { Component, OnInit, OnDestroy, AfterViewInit, ViewChild, ElementRef, Directive, HostListener, ChangeDetectorRef } from '@angular/core';
3
- import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
4
- import { ModalController, ToastController, PopoverController, Platform, ActionSheetController, NavController, IonContent, IonTextarea } from '@ionic/angular';
1
+ import { URL_SOUND_LIST_CONVERSATION } from './../../../chat21-core/utils/constants'
2
+ import {
3
+ Component,
4
+ OnInit,
5
+ OnDestroy,
6
+ AfterViewInit,
7
+ ViewChild,
8
+ ElementRef,
9
+ Directive,
10
+ HostListener,
11
+ ChangeDetectorRef,
12
+ } from '@angular/core'
13
+ import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'
14
+ import {
15
+ ModalController,
16
+ ToastController,
17
+ PopoverController,
18
+ Platform,
19
+ ActionSheetController,
20
+ NavController,
21
+ IonContent,
22
+ IonTextarea,
23
+ } from '@ionic/angular'
5
24
 
6
25
  // models
7
- import { UserModel } from 'src/chat21-core/models/user';
8
- import { MessageModel } from 'src/chat21-core/models/message';
9
- import { ConversationModel } from 'src/chat21-core/models/conversation';
10
- import { GroupModel } from 'src/chat21-core/models/group';
26
+ import { UserModel } from 'src/chat21-core/models/user'
27
+ import { MessageModel } from 'src/chat21-core/models/message'
28
+ import { ConversationModel } from 'src/chat21-core/models/conversation'
29
+ import { GroupModel } from 'src/chat21-core/models/group'
11
30
 
12
31
  // services
13
- import { ChatManager } from 'src/chat21-core/providers/chat-manager';
14
- import { AppConfigProvider } from '../../services/app-config';
15
-
16
- import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
17
- import { TypingService } from 'src/chat21-core/providers/abstract/typing.service';
18
- import { ConversationHandlerBuilderService } from 'src/chat21-core/providers/abstract/conversation-handler-builder.service';
19
- import { GroupsHandlerService } from 'src/chat21-core/providers/abstract/groups-handler.service';
20
- import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
21
- import { ConversationsHandlerService } from 'src/chat21-core/providers/abstract/conversations-handler.service';
22
- import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service';
23
- import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service';
24
- import { ContactsService } from 'src/app/services/contacts/contacts.service';
25
- import { CannedResponsesService } from '../../services/canned-responses/canned-responses.service';
26
- import { compareValues } from '../../../chat21-core/utils/utils';
27
- import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service';
28
- import { PresenceService } from 'src/chat21-core/providers/abstract/presence.service';
32
+ import { ChatManager } from 'src/chat21-core/providers/chat-manager'
33
+ import { AppConfigProvider } from '../../services/app-config'
34
+
35
+ import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service'
36
+ import { TypingService } from 'src/chat21-core/providers/abstract/typing.service'
37
+ import { ConversationHandlerBuilderService } from 'src/chat21-core/providers/abstract/conversation-handler-builder.service'
38
+ import { GroupsHandlerService } from 'src/chat21-core/providers/abstract/groups-handler.service'
39
+ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service'
40
+ import { ConversationsHandlerService } from 'src/chat21-core/providers/abstract/conversations-handler.service'
41
+ import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service'
42
+ import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service'
43
+ import { ContactsService } from 'src/app/services/contacts/contacts.service'
44
+ import { CannedResponsesService } from '../../services/canned-responses/canned-responses.service'
45
+ import { compareValues } from '../../../chat21-core/utils/utils'
46
+ import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service'
47
+ import { PresenceService } from 'src/chat21-core/providers/abstract/presence.service'
29
48
 
30
49
  // utils
31
- import { TYPE_MSG_TEXT, MESSAGE_TYPE_INFO, MESSAGE_TYPE_MINE, MESSAGE_TYPE_OTHERS } from '../../../chat21-core/utils/constants';
32
- import { checkPlatformIsMobile, checkWindowWidthIsLessThan991px, setConversationAvatar, setChannelType } from '../../../chat21-core/utils/utils';
33
- import { isFirstMessage, isInfo, isMine, messageType } from 'src/chat21-core/utils/utils-message';
50
+ import {
51
+ TYPE_MSG_TEXT,
52
+ MESSAGE_TYPE_INFO,
53
+ MESSAGE_TYPE_MINE,
54
+ MESSAGE_TYPE_OTHERS,
55
+ } from '../../../chat21-core/utils/constants'
56
+ import {
57
+ checkPlatformIsMobile,
58
+ checkWindowWidthIsLessThan991px,
59
+ setConversationAvatar,
60
+ setChannelType,
61
+ } from '../../../chat21-core/utils/utils'
62
+ import {
63
+ isFirstMessage,
64
+ isInfo,
65
+ isMine,
66
+ messageType,
67
+ } from 'src/chat21-core/utils/utils-message'
34
68
 
35
69
  // Logger
36
- import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
37
- import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
70
+ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'
71
+ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
38
72
 
39
- import { Subject } from 'rxjs';
40
- import { takeUntil } from 'rxjs/operators';
41
- import { TiledeskService } from '../../services/tiledesk/tiledesk.service';
42
- import { NetworkService } from '../../services/network-service/network.service';
43
- import { EventsService } from '../../services/events-service';
73
+ import { Subject } from 'rxjs'
74
+ import { takeUntil } from 'rxjs/operators'
75
+ import { TiledeskService } from '../../services/tiledesk/tiledesk.service'
76
+ import { NetworkService } from '../../services/network-service/network.service'
77
+ import { EventsService } from '../../services/events-service'
78
+ import { ScrollbarThemeDirective } from 'src/app/utils/scrollbar-theme.directive'
44
79
 
45
80
  @Component({
46
81
  selector: 'app-conversation-detail',
47
82
  templateUrl: './conversation-detail.page.html',
48
83
  styleUrls: ['./conversation-detail.page.scss'],
49
84
  })
50
-
51
- export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit {
52
- @ViewChild('ionContentChatArea', { static: false }) ionContentChatArea: IonContent;
53
- @ViewChild('rowMessageTextArea', { static: false }) rowTextArea: ElementRef;
54
-
55
-
85
+ export class ConversationDetailPage
86
+ implements OnInit, OnDestroy, AfterViewInit {
87
+ @ViewChild('ionContentChatArea', { static: false })
88
+ ionContentChatArea: IonContent
89
+ @ViewChild('rowMessageTextArea', { static: false }) rowTextArea: ElementRef
56
90
 
57
91
  // @ViewChild('info_content', { static: false }) info_content_child : InfoContentComponent;
58
92
 
59
- showButtonToBottom = false; // indica lo stato del pulsante per scrollare la chat (showed/hidden)
60
- NUM_BADGES = 0; // numero di messaggi non letti
61
- COLOR_GREEN = '#24d066'; // colore presence active da spostare nelle costanti
62
- COLOR_RED = '#db4437'; // colore presence none da spostare nelle costanti
63
-
64
- private unsubscribe$: Subject<any> = new Subject<any>();
65
- private subscriptions: Array<any>;
66
- public tenant: string;
67
- public loggedUser: UserModel;
68
- public conversationWith: string;
69
- public conversationWithFullname: string;
70
- public messages: Array<MessageModel> = [];
71
- public groupDetail: GroupModel;
72
- public messageSelected: any;
73
- public channelType: string;
74
- public online: boolean;
75
- public lastConnectionDate: string;
76
- public showMessageWelcome: boolean;
77
- public openInfoConversation = false;
78
- public openInfoMessage: boolean; // check is open info message
79
- public isMobile = false;
80
- public isLessThan991px = false; // nk added
81
- public isTyping = false;
82
- public nameUserTypingNow: string;
83
-
84
- public heightMessageTextArea = '';
85
- public translationMap: Map<string, string>;
86
- public conversationAvatar: any;
87
- public membersConversation: any;
88
- public member: UserModel;
89
- public urlConversationSupportGroup: any;
90
- public isFileSelected: boolean;
91
- public showIonContent = false;
92
- public conv_type: string;
93
-
94
- public tagsCanned: any = [];
93
+ showButtonToBottom = false // indica lo stato del pulsante per scrollare la chat (showed/hidden)
94
+ NUM_BADGES = 0 // numero di messaggi non letti
95
+ COLOR_GREEN = '#24d066' // colore presence active da spostare nelle costanti
96
+ COLOR_RED = '#db4437' // colore presence none da spostare nelle costanti
97
+
98
+ private unsubscribe$: Subject<any> = new Subject<any>()
99
+ private subscriptions: Array<any>
100
+ public tenant: string
101
+ public loggedUser: UserModel
102
+ public conversationWith: string
103
+ public conversationWithFullname: string
104
+ public messages: Array<MessageModel> = []
105
+ public groupDetail: GroupModel
106
+ public messageSelected: any
107
+ public channelType: string
108
+ public online: boolean
109
+ public lastConnectionDate: string
110
+ public showMessageWelcome: boolean
111
+ public openInfoConversation = false
112
+ public openInfoMessage: boolean // check is open info message
113
+ public isMobile = false
114
+ public isLessThan991px = false // nk added
115
+ public isTyping = false
116
+ public nameUserTypingNow: string
117
+
118
+ public heightMessageTextArea = ''
119
+ public translationMap: Map<string, string>
120
+ public conversationAvatar: any
121
+ public membersConversation: any
122
+ public member: UserModel
123
+ public urlConversationSupportGroup: any
124
+ public isFileSelected: boolean
125
+ public showIonContent = false
126
+ public conv_type: string
127
+
128
+ public tagsCanned: any = []
95
129
  public tagsCannedCount: number
96
- public tagsCannedFilter: any = [];
97
- public HIDE_CANNED_RESPONSES: boolean = false;
130
+ public tagsCannedFilter: any = []
131
+ public HIDE_CANNED_RESPONSES: boolean = false
98
132
 
133
+ public window: any = window
134
+ public styleMap: Map<string, string> = new Map()
99
135
 
100
- public window: any = window;
101
- public styleMap: Map<string, string> = new Map();
136
+ MESSAGE_TYPE_INFO = MESSAGE_TYPE_INFO
137
+ MESSAGE_TYPE_MINE = MESSAGE_TYPE_MINE
138
+ MESSAGE_TYPE_OTHERS = MESSAGE_TYPE_OTHERS
102
139
 
103
- MESSAGE_TYPE_INFO = MESSAGE_TYPE_INFO;
104
- MESSAGE_TYPE_MINE = MESSAGE_TYPE_MINE;
105
- MESSAGE_TYPE_OTHERS = MESSAGE_TYPE_OTHERS;
106
-
107
- arrowkeyLocation = -1;
108
- public_Key: any;
140
+ arrowkeyLocation = -1
141
+ public_Key: any
109
142
  areVisibleCAR: boolean
110
143
  //SOUND
111
- setTimeoutSound: any;
144
+ setTimeoutSound: any
112
145
  audio: any
113
- isOpenInfoConversation: boolean;
146
+ isOpenInfoConversation: boolean
114
147
  USER_HAS_OPENED_CLOSE_INFO_CONV: boolean = false
115
- isHovering: boolean = false;
116
- conversation_count: number;
148
+ isHovering: boolean = false
149
+ conversation_count: number
117
150
  showSpinner: boolean = true
118
151
  dropEvent: any
119
- isMine = isMine;
120
- isInfo = isInfo;
121
- isFirstMessage = isFirstMessage;
122
- messageType = messageType;
152
+ isMine = isMine
153
+ isInfo = isInfo
154
+ isFirstMessage = isFirstMessage
155
+ messageType = messageType
123
156
  // info_content_child_enabled: boolean = false
124
- private logger: LoggerService = LoggerInstance.getInstance();
125
-
157
+ private logger: LoggerService = LoggerInstance.getInstance()
126
158
 
127
- public isOnline: boolean = true;
128
- public checkInternet: boolean;
159
+ public isOnline: boolean = true
160
+ public checkInternet: boolean
129
161
  public msgCount: number
162
+ public disableTextarea: boolean
163
+
130
164
  /**
131
165
  * Constructor
132
- * @param route
133
- * @param chatManager
134
- * @param actionSheetCtrl
135
- * @param platform
136
- * @param customTranslateService
137
- * @param appConfigProvider
138
- * @param modalController
139
- * @param typingService
140
- * @param tiledeskAuthService
141
- * @param conversationsHandlerService
142
- * @param archivedConversationsHandlerService
143
- * @param conversationHandlerService
144
- * @param groupService
145
- * @param contactsService
146
- * @param conversationHandlerBuilderService
147
- * @param linkifyService
148
- * @param logger
149
- * @param cannedResponsesService
150
- * @param imageRepoService
151
- * @param presenceService
152
- * @param toastController
166
+ * @param route
167
+ * @param chatManager
168
+ * @param actionSheetCtrl
169
+ * @param platform
170
+ * @param customTranslateService
171
+ * @param appConfigProvider
172
+ * @param modalController
173
+ * @param typingService
174
+ * @param tiledeskAuthService
175
+ * @param conversationsHandlerService
176
+ * @param archivedConversationsHandlerService
177
+ * @param conversationHandlerService
178
+ * @param groupService
179
+ * @param contactsService
180
+ * @param conversationHandlerBuilderService
181
+ * @param linkifyService
182
+ * @param logger
183
+ * @param cannedResponsesService
184
+ * @param imageRepoService
185
+ * @param presenceService
186
+ * @param toastController
153
187
  */
154
188
  constructor(
155
189
  private route: ActivatedRoute,
@@ -173,19 +207,17 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
173
207
  public toastController: ToastController,
174
208
  public tiledeskService: TiledeskService,
175
209
  private networkService: NetworkService,
176
- private events: EventsService
210
+ private events: EventsService,
177
211
  ) {
178
-
179
212
  // Change list on date change
180
- this.route.paramMap.subscribe(params => {
181
- this.logger.log('[CONVS-DETAIL] - constructor -> params: ', params);
182
- this.conversationWith = params.get('IDConv');
183
- this.conversationWithFullname = params.get('FullNameConv');
184
- this.conv_type = params.get('Convtype');
185
-
186
- this.events.publish('supportconvid:haschanged', this.conversationWith);
187
- });
213
+ this.route.paramMap.subscribe((params) => {
214
+ this.logger.log('[CONVS-DETAIL] - constructor -> params: ', params)
215
+ this.conversationWith = params.get('IDConv')
216
+ this.conversationWithFullname = params.get('FullNameConv')
217
+ this.conv_type = params.get('Convtype')
188
218
 
219
+ this.events.publish('supportconvid:haschanged', this.conversationWith)
220
+ })
189
221
  }
190
222
 
191
223
  // -----------------------------------------------------------
@@ -208,87 +240,104 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
208
240
 
209
241
  // }
210
242
  // });
211
- this.getConversations();
212
- this.watchToConnectionStatus();
243
+ this.getConversations()
244
+ this.watchToConnectionStatus()
213
245
  this.getOSCODE()
214
246
  }
215
247
 
216
248
  getConversations() {
217
249
  this.conversationsHandlerService.conversationAdded.subscribe((conv) => {
218
250
  // console.log('[CONVS-DETAIL] - conv ', conv)
219
- const conversations = this.conversationsHandlerService.conversations;
251
+ const conversations = this.conversationsHandlerService.conversations
220
252
  // console.log('[CONVS-DETAIL] conversations', conversations);
221
- this.conversation_count = conversations.length;
222
- this.logger.log('[CONVS-DETAIL] conversation_count', this.conversation_count);
223
- });
253
+ this.conversation_count = conversations.length
254
+ this.logger.log(
255
+ '[CONVS-DETAIL] conversation_count',
256
+ this.conversation_count,
257
+ )
258
+ })
224
259
 
225
260
  this.conversationsHandlerService.conversationChanged.subscribe((conv) => {
226
261
  // console.log('[CONVS-DETAIL] - conv ', conv)
227
- const conversations = this.conversationsHandlerService.conversations;
262
+ const conversations = this.conversationsHandlerService.conversations
228
263
  // console.log('[CONVS-DETAIL] conversations', conversations);
229
- this.conversation_count = conversations.length;
230
- this.logger.log('[CONVS-DETAIL] conversation_count', this.conversation_count);
231
- });
264
+ this.conversation_count = conversations.length
265
+ this.logger.log(
266
+ '[CONVS-DETAIL] conversation_count',
267
+ this.conversation_count,
268
+ )
269
+ })
232
270
 
233
271
  this.conversationsHandlerService.conversationRemoved.subscribe((conv) => {
234
272
  // console.log('[CONVS-DETAIL] - conv ', conv)
235
- const conversations = this.conversationsHandlerService.conversations;
273
+ const conversations = this.conversationsHandlerService.conversations
236
274
  // console.log('[CONVS-DETAIL] conversations', conversations);
237
- this.conversation_count = conversations.length;
238
- this.logger.log('[CONVS-DETAIL] conversation_count', this.conversation_count);
239
- });
275
+ this.conversation_count = conversations.length
276
+ this.logger.log(
277
+ '[CONVS-DETAIL] conversation_count',
278
+ this.conversation_count,
279
+ )
280
+ })
240
281
 
241
282
  setTimeout(() => {
242
283
  this.showSpinner = false
243
- }, 3000);
244
-
284
+ }, 3000)
245
285
  }
246
286
 
247
-
248
287
  getOSCODE() {
249
- this.public_Key = this.appConfigProvider.getConfig().t2y12PruGU9wUtEGzBJfolMIgK;
250
- this.logger.log('[CONVS-DETAIL] AppConfigService getAppConfig public_Key', this.public_Key);
288
+ this.public_Key = this.appConfigProvider.getConfig().t2y12PruGU9wUtEGzBJfolMIgK
289
+ this.logger.log(
290
+ '[CONVS-DETAIL] AppConfigService getAppConfig public_Key',
291
+ this.public_Key,
292
+ )
251
293
 
252
294
  if (this.public_Key) {
253
- let keys = this.public_Key.split("-");
295
+ let keys = this.public_Key.split('-')
254
296
  this.logger.log('[CONVS-DETAIL] PUBLIC-KEY - public_Key keys', keys)
255
297
 
256
- keys.forEach(key => {
257
- if (key.includes("CAR")) {
258
- let car = key.split(":");
259
- if (car[1] === "F") {
260
- this.areVisibleCAR = false;
261
- this.logger.log('[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR', this.areVisibleCAR)
298
+ keys.forEach((key) => {
299
+ if (key.includes('CAR')) {
300
+ let car = key.split(':')
301
+ if (car[1] === 'F') {
302
+ this.areVisibleCAR = false
303
+ this.logger.log(
304
+ '[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
305
+ this.areVisibleCAR,
306
+ )
262
307
  } else {
263
- this.areVisibleCAR = true;
264
- this.logger.log('[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR', this.areVisibleCAR)
308
+ this.areVisibleCAR = true
309
+ this.logger.log(
310
+ '[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
311
+ this.areVisibleCAR,
312
+ )
265
313
  }
266
314
  }
315
+ })
267
316
 
268
- });
269
-
270
- if (!this.public_Key.includes("CAR")) {
271
- this.areVisibleCAR = false;
272
- this.logger.log('[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR', this.areVisibleCAR)
317
+ if (!this.public_Key.includes('CAR')) {
318
+ this.areVisibleCAR = false
319
+ this.logger.log(
320
+ '[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
321
+ this.areVisibleCAR,
322
+ )
273
323
  }
274
324
  } else {
275
- this.areVisibleCAR = false;
325
+ this.areVisibleCAR = false
276
326
  }
277
327
  }
278
328
 
279
329
  watchToConnectionStatus() {
280
- this.networkService.checkInternetFunc().subscribe(isOnline => {
330
+ this.networkService.checkInternetFunc().subscribe((isOnline) => {
281
331
  this.checkInternet = isOnline
282
332
  // console.log('[CONVS-LIST-PAGE] - watchToConnectionStatus - isOnline', this.checkInternet)
283
333
 
284
334
  // checking internet connection
285
335
  if (this.checkInternet == true) {
286
-
287
- this.isOnline = true;
336
+ this.isOnline = true
288
337
  } else {
289
- this.isOnline = false;
338
+ this.isOnline = false
290
339
  }
291
- });
340
+ })
292
341
  }
293
342
 
294
343
  ngAfterViewInit() {
@@ -303,13 +352,18 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
303
352
  this.logger.log('[CONVS-DETAIL] > ngOnChanges')
304
353
  }
305
354
 
306
-
307
355
  ionViewWillEnter() {
308
356
  // this.info_content_child_enabled = true;
309
- this.logger.log('[CONVS-DETAIL] TEST > ionViewWillEnter - convId ', this.conversationWith)
310
- this.loggedUser = this.tiledeskAuthService.getCurrentUser();
311
- this.logger.log('[CONVS-DETAIL] ionViewWillEnter loggedUser: ', this.loggedUser);
312
- this.listnerStart();
357
+ this.logger.log(
358
+ '[CONVS-DETAIL] TEST > ionViewWillEnter - convId ',
359
+ this.conversationWith,
360
+ )
361
+ this.loggedUser = this.tiledeskAuthService.getCurrentUser()
362
+ this.logger.log(
363
+ '[CONVS-DETAIL] ionViewWillEnter loggedUser: ',
364
+ this.loggedUser,
365
+ )
366
+ this.listnerStart()
313
367
  }
314
368
 
315
369
  ionViewDidEnter() {
@@ -321,14 +375,14 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
321
375
  ionViewWillLeave() {
322
376
  this.logger.log('[CONVS-DETAIL] > ionViewWillLeave')
323
377
 
324
- // this.logger.log('[CONVS-DETAIL] > ionViewWillLeave info_content_child ', this.info_content_child)
378
+ // this.logger.log('[CONVS-DETAIL] > ionViewWillLeave info_content_child ', this.info_content_child)
325
379
  // if (this.info_content_child) {
326
- // this.logger.log('[CONVS-DETAIL] > HERE YES')
380
+ // this.logger.log('[CONVS-DETAIL] > HERE YES')
327
381
  // this.info_content_child.destroy();
328
- // }
382
+ // }
329
383
 
330
384
  // this.logger.log('[CONVS-DETAIL] TEST > ionViewWillLeave info_content_child_enabled ', this.info_content_child_enabled , 'convId ', this.conversationWith)
331
- this.unsubescribeAll();
385
+ this.unsubescribeAll()
332
386
  }
333
387
 
334
388
  // reloadTree() {
@@ -340,23 +394,20 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
340
394
  // this.info_content_child_enabled = true;
341
395
  // }
342
396
 
343
-
344
-
345
397
  private listnerStart() {
346
- const that = this;
398
+ const that = this
347
399
  this.chatManager.BSStart.subscribe((data: any) => {
348
- this.logger.log('[CONVS-DETAIL] - BSStart data:', data);
400
+ this.logger.log('[CONVS-DETAIL] - BSStart data:', data)
349
401
  if (data) {
350
- that.initialize();
402
+ that.initialize()
351
403
  }
352
- });
404
+ })
353
405
  }
354
406
 
355
- // --------------------------------------------------
407
+ // --------------------------------------------------
356
408
  // @ Inizialize
357
- // --------------------------------------------------
409
+ // --------------------------------------------------
358
410
  initialize() {
359
-
360
411
  // this.logger.log('[CONVS-DETAIL] x conversationWith getConversationDetail', this.conversationWith)
361
412
  // this.logger.log('[CONVS-DETAIL] x conversationsHandlerService getConversationDetail', this.conversationsHandlerService)
362
413
  // this.logger.log('[CONVS-DETAIL] x this.conv_type getConversationDetail', this.conv_type)
@@ -373,87 +424,183 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
373
424
  // })
374
425
  // }
375
426
 
376
-
377
-
378
- this.loggedUser = this.tiledeskAuthService.getCurrentUser();
379
- this.logger.log('[CONVS-DETAIL] - initialize -> loggedUser: ', this.loggedUser);
380
- this.translations();
427
+ this.loggedUser = this.tiledeskAuthService.getCurrentUser()
428
+ this.logger.log(
429
+ '[CONVS-DETAIL] - initialize -> loggedUser: ',
430
+ this.loggedUser,
431
+ )
432
+ this.translations()
381
433
  // this.conversationSelected = localStorage.getItem('conversationSelected');
382
- this.showButtonToBottom = false;
383
- this.showMessageWelcome = false;
434
+ this.showButtonToBottom = false
435
+ this.showMessageWelcome = false
384
436
 
385
437
  const appconfig = this.appConfigProvider.getConfig()
386
438
  // this.tenant = appconfig.tenant;
387
- this.tenant = appconfig.firebaseConfig.tenant;
388
- this.logger.log('[CONVS-DETAIL] - initialize -> firebaseConfig tenant ', this.tenant);
389
-
390
-
391
-
392
-
393
- this.logger.log('[CONVS-DETAIL] - initialize -> conversationWith: ', this.conversationWith, ' -> conversationWithFullname: ', this.conversationWithFullname);
394
- this.subscriptions = [];
395
- this.setHeightTextArea();
396
- this.tagsCanned = []; // list of canned
397
-
398
- this.messages = []; // list messages of conversation
399
- this.isFileSelected = false; // indicates if a file has been selected (image to upload)
400
- this.openInfoMessage = false; // indicates whether the info message panel is open
439
+ this.tenant = appconfig.firebaseConfig.tenant
440
+ this.logger.log(
441
+ '[CONVS-DETAIL] - initialize -> firebaseConfig tenant ',
442
+ this.tenant,
443
+ )
444
+
445
+ this.logger.log(
446
+ '[CONVS-DETAIL] - initialize -> conversationWith: ',
447
+ this.conversationWith,
448
+ ' -> conversationWithFullname: ',
449
+ this.conversationWithFullname,
450
+ )
451
+ this.subscriptions = []
452
+ this.setHeightTextArea()
453
+ this.tagsCanned = [] // list of canned
454
+
455
+ this.messages = [] // list messages of conversation
456
+ this.isFileSelected = false // indicates if a file has been selected (image to upload)
457
+ this.openInfoMessage = false // indicates whether the info message panel is open
401
458
 
402
459
  if (checkPlatformIsMobile()) {
403
- this.isMobile = true;
460
+ this.isMobile = true
404
461
  // this.openInfoConversation = false; // indica se è aperto il box info conversazione
405
- this.logger.log('[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ', this.isMobile)
462
+ this.logger.log(
463
+ '[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ',
464
+ this.isMobile,
465
+ )
406
466
  } else {
407
- this.isMobile = false;
408
- this.logger.log('[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ', this.isMobile)
467
+ this.isMobile = false
468
+ this.logger.log(
469
+ '[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ',
470
+ this.isMobile,
471
+ )
409
472
  // this.openInfoConversation = true;
410
473
  }
411
474
 
412
475
  if (this.isMobile === false) {
413
476
  if (checkWindowWidthIsLessThan991px()) {
414
- this.logger.log('[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ', checkWindowWidthIsLessThan991px())
415
- this.openInfoConversation = false; // indica se è aperto il box info conversazione
416
- this.isOpenInfoConversation = false;
417
- this.logger.log('[CONVS-DETAIL] - initialize -> openInfoConversation ', this.openInfoConversation, ' -> isOpenInfoConversation ', this.isOpenInfoConversation)
477
+ this.logger.log(
478
+ '[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ',
479
+ checkWindowWidthIsLessThan991px(),
480
+ )
481
+ this.openInfoConversation = false // indica se è aperto il box info conversazione
482
+ this.isOpenInfoConversation = false
483
+ this.logger.log(
484
+ '[CONVS-DETAIL] - initialize -> openInfoConversation ',
485
+ this.openInfoConversation,
486
+ ' -> isOpenInfoConversation ',
487
+ this.isOpenInfoConversation,
488
+ )
418
489
  } else {
419
- this.logger.log('[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ', checkWindowWidthIsLessThan991px())
420
- this.openInfoConversation = true;
421
- this.isOpenInfoConversation = true;
422
- this.logger.log('[CONVS-DETAIL] - initialize -> openInfoConversation ', this.openInfoConversation, ' -> isOpenInfoConversation ', this.isOpenInfoConversation)
490
+ this.logger.log(
491
+ '[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ',
492
+ checkWindowWidthIsLessThan991px(),
493
+ )
494
+ this.openInfoConversation = true
495
+ this.isOpenInfoConversation = true
496
+ this.logger.log(
497
+ '[CONVS-DETAIL] - initialize -> openInfoConversation ',
498
+ this.openInfoConversation,
499
+ ' -> isOpenInfoConversation ',
500
+ this.isOpenInfoConversation,
501
+ )
423
502
  }
424
503
  }
425
504
 
426
- this.online = false;
427
- this.lastConnectionDate = '';
505
+ this.online = false
506
+ this.lastConnectionDate = ''
428
507
 
429
508
  // init handler vengono prima delle sottoscrizioni!
430
509
  // this.initConversationsHandler(); // nk
431
510
  if (this.conversationWith) {
432
- this.initConversationHandler();
433
- this.initGroupsHandler();
434
- this.initSubscriptions();
511
+ this.disableTextarea = false
512
+ this._getProjectIdByConversationWith(this.conversationWith)
513
+ this.initConversationHandler()
514
+ this.initGroupsHandler()
515
+ this.initSubscriptions()
435
516
  }
436
- this.addEventsKeyboard();
437
- this.startConversation();
438
- this.updateConversationBadge(); // AGGIORNO STATO DELLA CONVERSAZIONE A 'LETTA' (is_new = false)
517
+ this.addEventsKeyboard()
518
+ this.startConversation()
519
+ this.updateConversationBadge() // AGGIORNO STATO DELLA CONVERSAZIONE A 'LETTA' (is_new = false)
520
+ }
521
+
522
+ _getProjectIdByConversationWith(conversationWith: string) {
523
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
524
+
525
+ this.tiledeskService
526
+ .getProjectIdByConvRecipient(tiledeskToken, conversationWith)
527
+ .subscribe(
528
+ (res) => {
529
+ this.logger.log(
530
+ '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES',
531
+ res,
532
+ )
533
+ if (res) {
534
+ const projectId = res.id_project
535
+ this.logger.log(
536
+ '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT projectId ',
537
+ projectId,
538
+ )
539
+ this.getProjectById(tiledeskToken, projectId)
540
+ }
541
+ },
542
+ (error) => {
543
+ this.logger.error(
544
+ '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ',
545
+ error,
546
+ )
547
+ },
548
+ () => {
549
+ this.logger.log(
550
+ '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
551
+ )
552
+ },
553
+ )
554
+ }
555
+
556
+ getProjectById(tiledeskToken, projectId) {
557
+ this.tiledeskService.getProjectById(tiledeskToken, projectId).subscribe(
558
+ (res) => {
559
+ this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES', res)
560
+ if (res) {
561
+ const projectId = res.id_project
562
+ this.logger.log(
563
+ '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT projectId ',
564
+ projectId,
565
+ )
566
+ }
567
+ },
568
+ (error) => {
569
+ this.logger.error(
570
+ '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ',
571
+ error,
572
+ )
573
+ if ((error.error.msg = 'you dont belong to the project.')) {
574
+ this.disableTextarea = true
575
+ }
576
+ },
577
+ () => {
578
+ this.logger.log(
579
+ '[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
580
+ )
581
+ },
582
+ )
439
583
  }
440
584
 
441
585
  returnOpenCloseInfoConversation(openInfoConversation: boolean) {
442
- this.logger.log('[CONVS-DETAIL] returnOpenCloseInfoConversation - openInfoConversation ', openInfoConversation);
443
- this.resizeTextArea();
444
- this.openInfoMessage = false;
445
- this.openInfoConversation = openInfoConversation;
586
+ this.logger.log(
587
+ '[CONVS-DETAIL] returnOpenCloseInfoConversation - openInfoConversation ',
588
+ openInfoConversation,
589
+ )
590
+ this.resizeTextArea()
591
+ this.openInfoMessage = false
592
+ this.openInfoConversation = openInfoConversation
446
593
  this.isOpenInfoConversation = openInfoConversation
447
- this.USER_HAS_OPENED_CLOSE_INFO_CONV = true;
594
+ this.USER_HAS_OPENED_CLOSE_INFO_CONV = true
448
595
  }
449
596
 
450
597
  @HostListener('window:resize', ['$event'])
451
598
  onResize(event: any) {
452
- const newInnerWidth = event.target.innerWidth;
599
+ const newInnerWidth = event.target.innerWidth
453
600
  if (newInnerWidth < 991) {
454
601
  if (this.USER_HAS_OPENED_CLOSE_INFO_CONV === false) {
455
- this.openInfoConversation = false;
456
- this.isOpenInfoConversation = false;
602
+ this.openInfoConversation = false
603
+ this.isOpenInfoConversation = false
457
604
  }
458
605
  }
459
606
  }
@@ -484,16 +631,19 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
484
631
  'NO_INFORMATION_AVAILABLE',
485
632
  'CONTACT_ID',
486
633
  'USER_ID',
487
- "UPLOAD",
488
- "CANNED_RESPONSES",
489
- "NO_CANNED_RESPONSES",
490
- "YES_CANNED_RESPONSES",
491
- "THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE",
492
- "TO_CREATE_THEM_GO_TO_THE_PROJECT",
493
- ];
634
+ 'UPLOAD',
635
+ 'CANNED_RESPONSES',
636
+ 'NO_CANNED_RESPONSES',
637
+ 'YES_CANNED_RESPONSES',
638
+ 'THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE',
639
+ 'TO_CREATE_THEM_GO_TO_THE_PROJECT',
640
+ ]
494
641
 
495
- this.translationMap = this.customTranslateService.translateLanguage(keys);
496
- this.logger.log('[CONVS-DETAIL] x this.translationMap ', this.translationMap)
642
+ this.translationMap = this.customTranslateService.translateLanguage(keys)
643
+ this.logger.log(
644
+ '[CONVS-DETAIL] x this.translationMap ',
645
+ this.translationMap,
646
+ )
497
647
  }
498
648
 
499
649
  // --------------------------------------------------------
@@ -512,9 +662,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
512
662
  'LABEL_TOMORROW',
513
663
  'LABEL_LAST_ACCESS',
514
664
  'LABEL_TO',
515
- 'ARRAY_DAYS'
516
- ];
517
- return this.customTranslateService.translateLanguage(keys);
665
+ 'ARRAY_DAYS',
666
+ ]
667
+ return this.customTranslateService.translateLanguage(keys)
518
668
  }
519
669
 
520
670
  // -------------------------------------------------------------------------------------
@@ -525,63 +675,105 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
525
675
  // * I wait x sec if no messages arrive I display msg wellcome
526
676
  // -------------------------------------------------------------------------------------
527
677
  initConversationHandler() {
528
- const translationMap = this.setTranslationMapForConversationHandler();
529
- this.showMessageWelcome = false;
530
- const handler: ConversationHandlerService = this.chatManager.getConversationHandlerByConversationId(this.conversationWith);
531
- this.logger.log('[CONVS-DETAIL] - initConversationHandler - handler ', handler, ' conversationWith ', this.conversationWith);
678
+ const translationMap = this.setTranslationMapForConversationHandler()
679
+ this.showMessageWelcome = false
680
+ const handler: ConversationHandlerService = this.chatManager.getConversationHandlerByConversationId(
681
+ this.conversationWith,
682
+ )
683
+ this.logger.log(
684
+ '[CONVS-DETAIL] - initConversationHandler - handler ',
685
+ handler,
686
+ ' conversationWith ',
687
+ this.conversationWith,
688
+ )
532
689
  if (!handler) {
533
- this.conversationHandlerService = this.conversationHandlerBuilderService.build();
690
+ this.conversationHandlerService = this.conversationHandlerBuilderService.build()
534
691
  this.conversationHandlerService.initialize(
535
692
  this.conversationWith,
536
693
  this.conversationWithFullname,
537
694
  this.loggedUser,
538
695
  this.tenant,
539
- translationMap
540
- );
541
- this.conversationHandlerService.connect();
542
- this.logger.log('[CONVS-DETAIL] - initConversationHandler - NEW handler - conversationHandlerService', this.conversationHandlerService);
543
- this.messages = this.conversationHandlerService.messages;
544
- this.logger.log('[CONVS-DETAIL] - initConversationHandler - messages: ', this.messages);
545
- this.chatManager.addConversationHandler(this.conversationHandlerService);
696
+ translationMap,
697
+ )
698
+ this.conversationHandlerService.connect()
699
+ this.logger.log(
700
+ '[CONVS-DETAIL] - initConversationHandler - NEW handler - conversationHandlerService',
701
+ this.conversationHandlerService,
702
+ )
703
+ this.messages = this.conversationHandlerService.messages
704
+ this.logger.log(
705
+ '[CONVS-DETAIL] - initConversationHandler - messages: ',
706
+ this.messages,
707
+ )
708
+ this.chatManager.addConversationHandler(this.conversationHandlerService)
546
709
 
547
710
  // // wait 8 second and then display the message if there are no messages
548
- const that = this;
549
- this.logger.log('[CONVS-DETAIL] - initConversationHandler that.messages ', that.messages);
550
- this.logger.log('[CONVS-DETAIL] - initConversationHandler that.messages.length ', that.messages.length);
711
+ const that = this
712
+ this.logger.log(
713
+ '[CONVS-DETAIL] - initConversationHandler that.messages ',
714
+ that.messages,
715
+ )
716
+ this.logger.log(
717
+ '[CONVS-DETAIL] - initConversationHandler that.messages.length ',
718
+ that.messages.length,
719
+ )
551
720
  this.msgCount = that.messages.length
552
721
  setTimeout(() => {
553
722
  if (!that.messages || that.messages.length === 0) {
554
- this.showIonContent = true;
555
- that.showMessageWelcome = true;
556
- this.logger.log('[CONVS-DETAIL] - initConversationHandler - showMessageWelcome: ', that.showMessageWelcome);
723
+ this.showIonContent = true
724
+ that.showMessageWelcome = true
725
+ this.logger.log(
726
+ '[CONVS-DETAIL] - initConversationHandler - showMessageWelcome: ',
727
+ that.showMessageWelcome,
728
+ )
557
729
  }
558
- }, 8000);
559
-
730
+ }, 8000)
560
731
  } else {
561
- this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - conversationHandlerService ', this.conversationHandlerService, ' handler', handler);
562
- this.conversationHandlerService = handler;
563
- this.messages = this.conversationHandlerService.messages;
564
- this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - this.messages: ', this.messages);
565
- this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - this.showMessageWelcome: ', this.showMessageWelcome);
732
+ this.logger.log(
733
+ '[CONVS-DETAIL] - initConversationHandler (else) - conversationHandlerService ',
734
+ this.conversationHandlerService,
735
+ ' handler',
736
+ handler,
737
+ )
738
+ this.conversationHandlerService = handler
739
+ this.messages = this.conversationHandlerService.messages
740
+ this.logger.log(
741
+ '[CONVS-DETAIL] - initConversationHandler (else) - this.messages: ',
742
+ this.messages,
743
+ )
744
+ this.logger.log(
745
+ '[CONVS-DETAIL] - initConversationHandler (else) - this.showMessageWelcome: ',
746
+ this.showMessageWelcome,
747
+ )
566
748
  }
567
- this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - message ', this.messages, ' showIonContent', this.showIonContent);
749
+ this.logger.log(
750
+ '[CONVS-DETAIL] - initConversationHandler (else) - message ',
751
+ this.messages,
752
+ ' showIonContent',
753
+ this.showIonContent,
754
+ )
568
755
  }
569
756
 
570
-
571
757
  initGroupsHandler() {
572
- if (this.conversationWith.startsWith("support-group") || this.conversationWith.startsWith("group-")) {
758
+ if (
759
+ this.conversationWith.startsWith('support-group') ||
760
+ this.conversationWith.startsWith('group-')
761
+ ) {
573
762
  this.groupService.initialize(this.tenant, this.loggedUser.uid)
574
- this.logger.log('[CONVS-DETAIL] - initGroupsHandler - tenant', this.tenant, ' loggedUser UID', this.loggedUser.uid);
763
+ this.logger.log(
764
+ '[CONVS-DETAIL] - initGroupsHandler - tenant',
765
+ this.tenant,
766
+ ' loggedUser UID',
767
+ this.loggedUser.uid,
768
+ )
575
769
  }
576
770
  }
577
771
 
578
-
579
772
  private setAttributes(): any {
580
773
  const attributes: any = {
581
774
  client: navigator.userAgent,
582
775
  sourcePage: location.href,
583
-
584
- };
776
+ }
585
777
 
586
778
  //TODO: servono ???
587
779
  if (this.loggedUser && this.loggedUser.email) {
@@ -591,21 +783,25 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
591
783
  attributes.userFullname = this.loggedUser.fullname
592
784
  }
593
785
 
594
- return attributes;
786
+ return attributes
595
787
  }
596
788
 
597
-
598
-
599
789
  // ---------------------------------
600
790
  // startConversation
601
791
  // ---------------------------------
602
792
  startConversation() {
603
- this.logger.log('[CONVS-DETAIL] - startConversation conversationWith: ', this.conversationWith);
793
+ this.logger.log(
794
+ '[CONVS-DETAIL] - startConversation conversationWith: ',
795
+ this.conversationWith,
796
+ )
604
797
  if (this.conversationWith) {
605
- this.channelType = setChannelType(this.conversationWith);
606
- this.logger.log('[CONVS-DETAIL] - startConversation channelType : ', this.channelType);
798
+ this.channelType = setChannelType(this.conversationWith)
799
+ this.logger.log(
800
+ '[CONVS-DETAIL] - startConversation channelType : ',
801
+ this.channelType,
802
+ )
607
803
  // this.selectInfoContentTypeComponent();
608
- this.setHeaderContent();
804
+ this.setHeaderContent()
609
805
  }
610
806
  }
611
807
 
@@ -613,31 +809,54 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
613
809
  // this.logger.log('[CONVS-DETAIL] - setHeaderContent conversationWith', this.conversationWith)
614
810
  // this.logger.log('[CONVS-DETAIL] - setHeaderContent conversationsHandlerService', this.conversationsHandlerService)
615
811
  // this.logger.log('[CONVS-DETAIL] - setHeaderContent conv_type', this.conv_type)
616
- if (this.conversationWith && this.conversationsHandlerService && this.conv_type === 'active') {
617
- this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail CALLING')
618
- this.conversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
619
- if (conv) {
620
- this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail (active)', this.conversationWith, conv)
621
- this.conversationAvatar = setConversationAvatar(
622
- conv.conversation_with,
623
- conv.conversation_with_fullname,
624
- conv.channel_type
625
- );
626
- }
627
- this.logger.log('[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ', this.conversationAvatar);
628
- })
629
- }
630
- else { //get conversation from 'conversations' firebase node
631
- this.archivedConversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
632
- if (conv) {
633
- this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail (archived)', this.conversationWith, conv)
634
- this.conversationAvatar = setConversationAvatar(
635
- conv.conversation_with,
636
- conv.conversation_with_fullname,
637
- conv.channel_type
638
- );
639
- }
640
- })
812
+ if (
813
+ this.conversationWith &&
814
+ this.conversationsHandlerService &&
815
+ this.conv_type === 'active'
816
+ ) {
817
+ this.logger.log(
818
+ '[CONVS-DETAIL] - setHeaderContent getConversationDetail CALLING',
819
+ )
820
+ this.conversationsHandlerService.getConversationDetail(
821
+ this.conversationWith,
822
+ (conv) => {
823
+ if (conv) {
824
+ this.logger.log(
825
+ '[CONVS-DETAIL] - setHeaderContent getConversationDetail (active)',
826
+ this.conversationWith,
827
+ conv,
828
+ )
829
+ this.conversationAvatar = setConversationAvatar(
830
+ conv.conversation_with,
831
+ conv.conversation_with_fullname,
832
+ conv.channel_type,
833
+ )
834
+ }
835
+ this.logger.log(
836
+ '[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ',
837
+ this.conversationAvatar,
838
+ )
839
+ },
840
+ )
841
+ } else {
842
+ //get conversation from 'conversations' firebase node
843
+ this.archivedConversationsHandlerService.getConversationDetail(
844
+ this.conversationWith,
845
+ (conv) => {
846
+ if (conv) {
847
+ this.logger.log(
848
+ '[CONVS-DETAIL] - setHeaderContent getConversationDetail (archived)',
849
+ this.conversationWith,
850
+ conv,
851
+ )
852
+ this.conversationAvatar = setConversationAvatar(
853
+ conv.conversation_with,
854
+ conv.conversation_with_fullname,
855
+ conv.channel_type,
856
+ )
857
+ }
858
+ },
859
+ )
641
860
  }
642
861
 
643
862
  // this.conversationAvatar = setConversationAvatar(
@@ -649,62 +868,71 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
649
868
  }
650
869
 
651
870
  returnSendMessage(e: any) {
652
- this.logger.log('[CONVS-DETAIL] - returnSendMessage event', e, ' - conversationWith', this.conversationWith);
653
-
654
- this.logger.log('[CONVS-DETAIL] - returnSendMessage event message', e.message);
871
+ this.logger.log(
872
+ '[CONVS-DETAIL] - returnSendMessage event',
873
+ e,
874
+ ' - conversationWith',
875
+ this.conversationWith,
876
+ )
877
+
878
+ this.logger.log(
879
+ '[CONVS-DETAIL] - returnSendMessage event message',
880
+ e.message,
881
+ )
655
882
  try {
656
- let message = '';
883
+ let message = ''
657
884
  if (e.message) {
658
- message = e.message;
885
+ message = e.message
659
886
  }
660
- const type = e.type;
661
- const metadata = e.metadata;
662
-
663
- this.sendMessage(message, type, metadata);
887
+ const type = e.type
888
+ const metadata = e.metadata
664
889
 
890
+ this.sendMessage(message, type, metadata)
665
891
  } catch (err) {
666
- this.logger.error('[CONVS-DETAIL] - returnSendMessage error: ', err);
892
+ this.logger.error('[CONVS-DETAIL] - returnSendMessage error: ', err)
667
893
  }
668
894
  }
669
895
 
670
-
671
896
  /**
672
- * SendMessage
673
- * @param msg
674
- * @param type
675
- * @param metadata
676
- * @param additional_attributes
677
- */
678
- sendMessage(msg: string, type: string, metadata?: any, additional_attributes?: any) {
679
- this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - MSG: ', msg);
680
- this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - type: ', type);
681
- this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - metadata: ', metadata);
682
- let fullname = this.loggedUser.uid;
897
+ * SendMessage
898
+ * @param msg
899
+ * @param type
900
+ * @param metadata
901
+ * @param additional_attributes
902
+ */
903
+ sendMessage(
904
+ msg: string,
905
+ type: string,
906
+ metadata?: any,
907
+ additional_attributes?: any,
908
+ ) {
909
+ this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - MSG: ', msg)
910
+ this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - type: ', type)
911
+ this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - metadata: ', metadata)
912
+ let fullname = this.loggedUser.uid
683
913
  if (this.loggedUser.fullname) {
684
- fullname = this.loggedUser.fullname;
914
+ fullname = this.loggedUser.fullname
685
915
  }
686
916
 
687
- const g_attributes = this.setAttributes();
917
+ const g_attributes = this.setAttributes()
688
918
  // added <any> to resolve the Error occurred during the npm installation: Property 'userFullname' does not exist on type '{}'
689
- const attributes = <any>{};
919
+ const attributes = <any>{}
690
920
  if (g_attributes) {
691
921
  for (const [key, value] of Object.entries(g_attributes)) {
692
- attributes[key] = value;
922
+ attributes[key] = value
693
923
  }
694
924
  }
695
925
  if (additional_attributes) {
696
926
  for (const [key, value] of Object.entries(additional_attributes)) {
697
- attributes[key] = value;
927
+ attributes[key] = value
698
928
  }
699
929
  }
700
930
 
701
931
  // || type === 'image'
702
932
  if (type === 'file') {
703
-
704
933
  if (msg) {
705
934
  // msg = msg + '<br>' + 'File: ' + metadata.src;
706
935
  msg = `[${metadata.name}](${metadata.src})` + '\n' + msg
707
-
708
936
  } else {
709
937
  // msg = 'File: ' + metadata.src;
710
938
  // msg = `<a href=${metadata.src} download>
@@ -728,11 +956,17 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
728
956
 
729
957
  // }
730
958
 
731
-
732
- (metadata) ? metadata = metadata : metadata = '';
733
- this.logger.log('[CONVS-DETAIL] - SEND MESSAGE msg: ', msg, ' - messages: ', this.messages, ' - loggedUser: ', this.loggedUser);
734
-
735
- if (msg && msg.trim() !== '' || type !== TYPE_MSG_TEXT) {
959
+ metadata ? (metadata = metadata) : (metadata = '')
960
+ this.logger.log(
961
+ '[CONVS-DETAIL] - SEND MESSAGE msg: ',
962
+ msg,
963
+ ' - messages: ',
964
+ this.messages,
965
+ ' - loggedUser: ',
966
+ this.loggedUser,
967
+ )
968
+
969
+ if ((msg && msg.trim() !== '') || type !== TYPE_MSG_TEXT) {
736
970
  this.conversationHandlerService.sendMessage(
737
971
  msg,
738
972
  type,
@@ -742,186 +976,253 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
742
976
  this.loggedUser.uid,
743
977
  fullname,
744
978
  this.channelType,
745
- attributes
746
- );
747
-
979
+ attributes,
980
+ )
748
981
  }
749
982
  }
750
983
  // ----------------------------------------------------------
751
- // InitSubscriptions BS subscriptions
984
+ // InitSubscriptions BS subscriptions
752
985
  // ----------------------------------------------------------
753
986
  initSubscriptions() {
754
- this.logger.log('[CONVS-DETAIL] - initSubscriptions: ', this.subscriptions);
755
-
756
- const that = this;
757
- let subscription: any;
758
- let subscriptionKey: string;
987
+ this.logger.log('[CONVS-DETAIL] - initSubscriptions: ', this.subscriptions)
759
988
 
989
+ const that = this
990
+ let subscription: any
991
+ let subscriptionKey: string
760
992
 
761
- subscriptionKey = 'BSConversationsChanged';
762
- subscription = this.subscriptions.find(item => item.key === subscriptionKey);
993
+ subscriptionKey = 'BSConversationsChanged'
994
+ subscription = this.subscriptions.find(
995
+ (item) => item.key === subscriptionKey,
996
+ )
763
997
  if (!subscription) {
764
- subscription = this.conversationsHandlerService.conversationChanged.subscribe((data: ConversationModel) => {
765
- this.logger.log('[CONVS-DETAIL] subscribe BSConversationsChanged data ', data, ' this.loggedUser.uid:', this.loggedUser.uid);
766
-
767
- if (data && data.sender !== this.loggedUser.uid) {
768
- this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange data sender ', data.sender)
769
- this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange this.loggedUser.uid ', this.loggedUser.uid)
770
- this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange is_new ', data.is_new)
771
- this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange showButtonToBottom ', this.showButtonToBottom)
772
- // UPDATE THE CONVERSATION TO 'READ' IF IT IS ME WHO WRITES THE LAST MESSAGE OF THE CONVERSATION
773
- // AND IF THE POSITION OF THE SCROLL IS AT THE END
774
- if (!this.showButtonToBottom && data.is_new) { // ARE AT THE END
775
- this.updateConversationBadge()
998
+ subscription = this.conversationsHandlerService.conversationChanged.subscribe(
999
+ (data: ConversationModel) => {
1000
+ this.logger.log(
1001
+ '[CONVS-DETAIL] subscribe BSConversationsChanged data ',
1002
+ data,
1003
+ ' this.loggedUser.uid:',
1004
+ this.loggedUser.uid,
1005
+ )
1006
+
1007
+ if (data && data.sender !== this.loggedUser.uid) {
1008
+ this.logger.log(
1009
+ '[CONVS-DETAIL] subscribe to BSConversationsChange data sender ',
1010
+ data.sender,
1011
+ )
1012
+ this.logger.log(
1013
+ '[CONVS-DETAIL] subscribe to BSConversationsChange this.loggedUser.uid ',
1014
+ this.loggedUser.uid,
1015
+ )
1016
+ this.logger.log(
1017
+ '[CONVS-DETAIL] subscribe to BSConversationsChange is_new ',
1018
+ data.is_new,
1019
+ )
1020
+ this.logger.log(
1021
+ '[CONVS-DETAIL] subscribe to BSConversationsChange showButtonToBottom ',
1022
+ this.showButtonToBottom,
1023
+ )
1024
+ // UPDATE THE CONVERSATION TO 'READ' IF IT IS ME WHO WRITES THE LAST MESSAGE OF THE CONVERSATION
1025
+ // AND IF THE POSITION OF THE SCROLL IS AT THE END
1026
+ if (!this.showButtonToBottom && data.is_new) {
1027
+ // ARE AT THE END
1028
+ this.updateConversationBadge()
1029
+ }
776
1030
  }
777
- }
778
- });
779
- const subscribe = { key: subscriptionKey, value: subscription };
780
- this.subscriptions.push(subscribe);
1031
+ },
1032
+ )
1033
+ const subscribe = { key: subscriptionKey, value: subscription }
1034
+ this.subscriptions.push(subscribe)
781
1035
  }
782
1036
 
783
- subscriptionKey = 'messageAdded';
784
- subscription = this.subscriptions.find(item => item.key === subscriptionKey);
1037
+ subscriptionKey = 'messageAdded'
1038
+ subscription = this.subscriptions.find(
1039
+ (item) => item.key === subscriptionKey,
1040
+ )
785
1041
  if (!subscription) {
786
- this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - conversationHandlerService', this.conversationHandlerService);
787
- subscription = this.conversationHandlerService.messageAdded.subscribe((msg: any) => {
788
- this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - msg ', msg);
789
- if (msg) {
790
- that.newMessageAdded(msg);
791
- }
792
- });
793
- const subscribe = { key: subscriptionKey, value: subscription };
794
- this.subscriptions.push(subscribe);
1042
+ this.logger.log(
1043
+ '[CONVS-DETAIL] subscribe to messageAdded - conversationHandlerService',
1044
+ this.conversationHandlerService,
1045
+ )
1046
+ subscription = this.conversationHandlerService.messageAdded.subscribe(
1047
+ (msg: any) => {
1048
+ this.logger.log(
1049
+ '[CONVS-DETAIL] subscribe to messageAdded - msg ',
1050
+ msg,
1051
+ )
1052
+ if (msg) {
1053
+ that.newMessageAdded(msg)
1054
+ }
1055
+ },
1056
+ )
1057
+ const subscribe = { key: subscriptionKey, value: subscription }
1058
+ this.subscriptions.push(subscribe)
795
1059
  }
796
1060
 
797
1061
  // IS USED ?
798
- subscriptionKey = 'messageChanged';
799
- subscription = this.subscriptions.find(item => item.key === subscriptionKey);
1062
+ subscriptionKey = 'messageChanged'
1063
+ subscription = this.subscriptions.find(
1064
+ (item) => item.key === subscriptionKey,
1065
+ )
800
1066
  if (!subscription) {
801
- this.logger.log('[CONVS-DETAIL] subscribe to messageChanged');
802
- subscription = this.conversationHandlerService.messageChanged.subscribe((msg: any) => {
803
- this.logger.log('[CONVS-DETAIL] subscribe to messageChanged - msg ', msg);
804
- });
805
- const subscribe = { key: subscriptionKey, value: subscription };
806
- this.subscriptions.push(subscribe);
1067
+ this.logger.log('[CONVS-DETAIL] subscribe to messageChanged')
1068
+ subscription = this.conversationHandlerService.messageChanged.subscribe(
1069
+ (msg: any) => {
1070
+ this.logger.log(
1071
+ '[CONVS-DETAIL] subscribe to messageChanged - msg ',
1072
+ msg,
1073
+ )
1074
+ },
1075
+ )
1076
+ const subscribe = { key: subscriptionKey, value: subscription }
1077
+ this.subscriptions.push(subscribe)
807
1078
  }
808
1079
 
809
-
810
- subscriptionKey = 'messageRemoved';
811
- subscription = this.subscriptions.find(item => item.key === subscriptionKey);
1080
+ subscriptionKey = 'messageRemoved'
1081
+ subscription = this.subscriptions.find(
1082
+ (item) => item.key === subscriptionKey,
1083
+ )
812
1084
  if (!subscription) {
813
- this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved');
814
- subscription = this.conversationHandlerService.messageRemoved.subscribe((messageId: any) => {
815
- this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved - messageId ', messageId);
816
- });
817
- const subscribe = { key: subscriptionKey, value: subscription };
818
- this.subscriptions.push(subscribe);
1085
+ this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved')
1086
+ subscription = this.conversationHandlerService.messageRemoved.subscribe(
1087
+ (messageId: any) => {
1088
+ this.logger.log(
1089
+ '[CONVS-DETAIL] subscribe to messageRemoved - messageId ',
1090
+ messageId,
1091
+ )
1092
+ },
1093
+ )
1094
+ const subscribe = { key: subscriptionKey, value: subscription }
1095
+ this.subscriptions.push(subscribe)
819
1096
  }
820
1097
 
821
1098
  // subscriptionKey = 'onGroupChange';
822
1099
  // subscription = this.subscriptions.find(item => item.key === subscriptionKey);
823
1100
  // if (!subscription) {
824
- // subscription =
825
- if (this.conversationWith.startsWith("group-")) {
826
- this.groupService.onGroupChange(this.conversationWith)
1101
+ // subscription =
1102
+ if (this.conversationWith.startsWith('group-')) {
1103
+ this.groupService
1104
+ .onGroupChange(this.conversationWith)
827
1105
  .pipe(takeUntil(this.unsubscribe$))
828
- .subscribe((groupDetail: any) => {
829
- this.groupDetail = groupDetail;
830
- this.logger.log('[CONVS-DETAIL] subscribe to onGroupChange - groupDetail ', this.groupDetail)
831
- }, (error) => {
832
- this.logger.error('I[CONVS-DETAIL] subscribe to onGroupChange - ERROR ', error);
833
- }, () => {
834
- this.logger.log('[CONVS-DETAIL] subscribe to onGroupChange /* COMPLETE */');
835
- this.groupDetail = null
836
- });
1106
+ .subscribe(
1107
+ (groupDetail: any) => {
1108
+ this.groupDetail = groupDetail
1109
+ this.logger.log(
1110
+ '[CONVS-DETAIL] subscribe to onGroupChange - groupDetail ',
1111
+ this.groupDetail,
1112
+ )
1113
+ },
1114
+ (error) => {
1115
+ this.logger.error(
1116
+ 'I[CONVS-DETAIL] subscribe to onGroupChange - ERROR ',
1117
+ error,
1118
+ )
1119
+ },
1120
+ () => {
1121
+ this.logger.log(
1122
+ '[CONVS-DETAIL] subscribe to onGroupChange /* COMPLETE */',
1123
+ )
1124
+ this.groupDetail = null
1125
+ },
1126
+ )
837
1127
  }
838
1128
  // const subscribe = { key: subscriptionKey, value: subscription };
839
1129
  // this.subscriptions.push(subscribe);
840
1130
  // }
841
1131
  }
842
1132
 
843
-
844
1133
  // -------------------------------------------------
845
1134
  // addEventsKeyboard
846
1135
  // -------------------------------------------------
847
1136
  addEventsKeyboard() {
848
1137
  window.addEventListener('keyboardWillShow', () => {
849
- this.logger.log('[CONVS-DETAIL] - Keyboard will Show');
850
- });
1138
+ this.logger.log('[CONVS-DETAIL] - Keyboard will Show')
1139
+ })
851
1140
  window.addEventListener('keyboardDidShow', () => {
852
- this.logger.log('[CONVS-DETAIL] - Keyboard is Shown');
853
- });
1141
+ this.logger.log('[CONVS-DETAIL] - Keyboard is Shown')
1142
+ })
854
1143
  window.addEventListener('keyboardWillHide', () => {
855
- this.logger.log('[CONVS-DETAIL] - Keyboard will Hide');
856
- });
1144
+ this.logger.log('[CONVS-DETAIL] - Keyboard will Hide')
1145
+ })
857
1146
  window.addEventListener('keyboardDidHide', () => {
858
- this.logger.log('[CONVS-DETAIL] - Keyboard is Hidden');
859
- });
1147
+ this.logger.log('[CONVS-DETAIL] - Keyboard is Hidden')
1148
+ })
860
1149
  }
861
1150
 
862
1151
  // ----------------------------------------------------------------
863
1152
  // @ Unsubscribe all subscribed events (called in ionViewWillLeave)
864
1153
  // ----------------------------------------------------------------
865
1154
  unsubescribeAll() {
866
- this.logger.log('[CONVS-DETAIL] unsubescribeAll 1: ', this.subscriptions);
1155
+ this.logger.log('[CONVS-DETAIL] unsubescribeAll 1: ', this.subscriptions)
867
1156
  if (this.subscriptions) {
868
- this.logger.log('[CONVS-DETAIL] unsubescribeAll 2: ', this.subscriptions);
869
- this.subscriptions.forEach(subscription => {
870
- subscription.value.unsubscribe(); // vedere come fare l'unsubscribe!!!!
871
- });
872
- this.subscriptions = [];
1157
+ this.logger.log('[CONVS-DETAIL] unsubescribeAll 2: ', this.subscriptions)
1158
+ this.subscriptions.forEach((subscription) => {
1159
+ subscription.value.unsubscribe() // vedere come fare l'unsubscribe!!!!
1160
+ })
1161
+ this.subscriptions = []
873
1162
 
874
1163
  // https://www.w3schools.com/jsref/met_element_removeeventlistener.asp
875
- window.removeEventListener('keyboardWillShow', null);
876
- window.removeEventListener('keyboardDidShow', null);
877
- window.removeEventListener('keyboardWillHide', null);
878
- window.removeEventListener('keyboardDidHide', null);
1164
+ window.removeEventListener('keyboardWillShow', null)
1165
+ window.removeEventListener('keyboardDidShow', null)
1166
+ window.removeEventListener('keyboardWillHide', null)
1167
+ window.removeEventListener('keyboardDidHide', null)
879
1168
  }
880
1169
 
881
- this.unsubscribe$.next();
882
- this.unsubscribe$.complete();
1170
+ this.unsubscribe$.next()
1171
+ this.unsubscribe$.complete()
883
1172
  // this.conversationHandlerService.dispose();
884
1173
  }
885
1174
 
886
-
887
1175
  /**
888
- * newMessageAdded
1176
+ * newMessageAdded
889
1177
  * @param message
890
1178
  */
891
1179
  newMessageAdded(message: MessageModel) {
892
1180
  if (message) {
893
- this.logger.log('[CONVS-DETAIL] - newMessageAdded message ', message);
1181
+ this.logger.log('[CONVS-DETAIL] - newMessageAdded message ', message)
894
1182
 
895
1183
  if (message.isSender) {
896
- this.scrollBottom(0);
897
-
1184
+ this.scrollBottom(0)
898
1185
  } else if (!message.isSender) {
899
- if (this.showButtonToBottom) { // NON SONO ALLA FINE
900
- this.NUM_BADGES++;
901
- } else { //SONO ALLA FINE
902
- this.scrollBottom(0);
1186
+ if (this.showButtonToBottom) {
1187
+ // NON SONO ALLA FINE
1188
+ this.NUM_BADGES++
1189
+ } else {
1190
+ //SONO ALLA FINE
1191
+ this.scrollBottom(0)
903
1192
  }
904
1193
  }
905
1194
  }
906
1195
  }
907
1196
 
908
1197
  updateConversationBadge() {
909
- if (this.conversationWith && this.conversationsHandlerService && this.conv_type === 'active') {
910
- this.conversationsHandlerService.setConversationRead(this.conversationWith)
911
- } else if (this.conversationWith && this.archivedConversationsHandlerService && this.conv_type === 'archived') {
912
- this.archivedConversationsHandlerService.setConversationRead(this.conversationWith)
1198
+ if (
1199
+ this.conversationWith &&
1200
+ this.conversationsHandlerService &&
1201
+ this.conv_type === 'active'
1202
+ ) {
1203
+ this.conversationsHandlerService.setConversationRead(
1204
+ this.conversationWith,
1205
+ )
1206
+ } else if (
1207
+ this.conversationWith &&
1208
+ this.archivedConversationsHandlerService &&
1209
+ this.conv_type === 'archived'
1210
+ ) {
1211
+ this.archivedConversationsHandlerService.setConversationRead(
1212
+ this.conversationWith,
1213
+ )
913
1214
  }
914
1215
  }
915
1216
 
916
1217
  // -----------------------------------------------------------
917
- // OUTPUT-EVENT handler
1218
+ // OUTPUT-EVENT handler
918
1219
  // -----------------------------------------------------------
919
1220
  logScrollStart(event: any) {
920
- this.logger.log('[CONVS-DETAIL] logScrollStart: ', event);
1221
+ this.logger.log('[CONVS-DETAIL] logScrollStart: ', event)
921
1222
  }
922
1223
 
923
1224
  logScrolling(event: any) {
924
- // EVENTO IONIC-NATIVE: SCATTA SEMPRE, QUINDI DECIDO SE MOSTRARE O MENO IL BADGE
1225
+ // EVENTO IONIC-NATIVE: SCATTA SEMPRE, QUINDI DECIDO SE MOSTRARE O MENO IL BADGE
925
1226
  // this.logger.log('[CONVS-DETAIL] logScrolling: ', event);
926
1227
  this.detectBottom()
927
1228
  }
@@ -930,53 +1231,78 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
930
1231
  // this.logger.log('[CONVS-DETAIL] logScrollEnd: ', event);
931
1232
  }
932
1233
 
933
-
934
1234
  returnChangeTextArea(e: any) {
935
- this.logger.log('[CONVS-DETAIL] returnChangeTextArea event', e);
1235
+ this.logger.log('[CONVS-DETAIL] returnChangeTextArea event', e)
936
1236
  try {
937
- let height: number = e.offsetHeight;
1237
+ let height: number = e.offsetHeight
938
1238
  if (height < 50) {
939
- height = 50;
1239
+ height = 50
940
1240
  }
941
1241
 
942
- this.heightMessageTextArea = height.toString(); //e.target.scrollHeight + 20;
943
- const message = e.msg;
944
- this.logger.log('[CONVS-DETAIL] returnChangeTextArea heightMessageTextArea ', this.heightMessageTextArea);
945
-
946
- this.logger.log('[CONVS-DETAIL] returnChangeTextArea e.detail.value', e.msg);
947
- this.logger.log('[CONVS-DETAIL] returnChangeTextArea loggedUser uid:', this.loggedUser.uid);
948
- this.logger.log('[CONVS-DETAIL] returnChangeTextArea loggedUser firstname:', this.loggedUser.firstname);
949
- this.logger.log('[CONVS-DETAIL] returnChangeTextArea conversationSelected uid:', this.conversationWith);
950
- this.logger.log('[CONVS-DETAIL] returnChangeTextArea channelType:', this.channelType);
951
- let idCurrentUser = '';
952
- let userFullname = '';
1242
+ this.heightMessageTextArea = height.toString() //e.target.scrollHeight + 20;
1243
+ const message = e.msg
1244
+ this.logger.log(
1245
+ '[CONVS-DETAIL] returnChangeTextArea heightMessageTextArea ',
1246
+ this.heightMessageTextArea,
1247
+ )
1248
+
1249
+ this.logger.log(
1250
+ '[CONVS-DETAIL] returnChangeTextArea e.detail.value',
1251
+ e.msg,
1252
+ )
1253
+ this.logger.log(
1254
+ '[CONVS-DETAIL] returnChangeTextArea loggedUser uid:',
1255
+ this.loggedUser.uid,
1256
+ )
1257
+ this.logger.log(
1258
+ '[CONVS-DETAIL] returnChangeTextArea loggedUser firstname:',
1259
+ this.loggedUser.firstname,
1260
+ )
1261
+ this.logger.log(
1262
+ '[CONVS-DETAIL] returnChangeTextArea conversationSelected uid:',
1263
+ this.conversationWith,
1264
+ )
1265
+ this.logger.log(
1266
+ '[CONVS-DETAIL] returnChangeTextArea channelType:',
1267
+ this.channelType,
1268
+ )
1269
+ let idCurrentUser = ''
1270
+ let userFullname = ''
953
1271
 
954
1272
  // serve x mantenere la compatibilità con le vecchie chat
955
1273
  // if (this.channelType === TYPE_DIRECT) {
956
1274
  // userId = this.loggedUser.uid;
957
1275
  // }
958
- idCurrentUser = this.loggedUser.uid;
1276
+ idCurrentUser = this.loggedUser.uid
959
1277
 
960
- if (this.loggedUser.firstname && this.loggedUser.firstname !== undefined) {
961
- userFullname = this.loggedUser.firstname;
1278
+ if (
1279
+ this.loggedUser.firstname &&
1280
+ this.loggedUser.firstname !== undefined
1281
+ ) {
1282
+ userFullname = this.loggedUser.firstname
962
1283
  }
963
- this.typingService.setTyping(this.conversationWith, message, idCurrentUser, userFullname);
964
-
965
-
1284
+ this.typingService.setTyping(
1285
+ this.conversationWith,
1286
+ message,
1287
+ idCurrentUser,
1288
+ userFullname,
1289
+ )
966
1290
 
967
1291
  // ----------------------------------------------------------
968
1292
  // DISPLAY CANNED RESPONSES if message.lastIndexOf("/")
969
1293
  // ----------------------------------------------------------
970
1294
  if (this.areVisibleCAR) {
971
1295
  setTimeout(() => {
972
- if (this.conversationWith.startsWith("support-group")) {
973
-
974
- const pos = message.lastIndexOf("/");
975
- this.logger.log("[CONVS-DETAIL] - returnChangeTextArea - canned responses pos of / (using lastIndexOf) ", pos);
1296
+ if (this.conversationWith.startsWith('support-group')) {
1297
+ const pos = message.lastIndexOf('/')
1298
+ this.logger.log(
1299
+ '[CONVS-DETAIL] - returnChangeTextArea - canned responses pos of / (using lastIndexOf) ',
1300
+ pos,
1301
+ )
976
1302
 
977
1303
  if (pos === -1) {
978
- this.tagsCannedFilter = [];
979
- this.HIDE_CANNED_RESPONSES = true;
1304
+ this.tagsCannedFilter = []
1305
+ this.HIDE_CANNED_RESPONSES = true
980
1306
  }
981
1307
  // test
982
1308
  // var rest = message.substring(0, message.lastIndexOf("/") + 1);
@@ -990,33 +1316,44 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
990
1316
  // console.log('[CONVS-DETAIL] - returnChangeTextArea last is NOT space ');
991
1317
  // }
992
1318
 
993
-
994
1319
  if (pos >= 0) {
995
- var strSearch = message.substr(pos + 1);
996
- this.logger.log("[CONVS-DETAIL] - returnChangeTextArea - canned responses strSearch ", strSearch);
1320
+ var strSearch = message.substr(pos + 1)
1321
+ this.logger.log(
1322
+ '[CONVS-DETAIL] - returnChangeTextArea - canned responses strSearch ',
1323
+ strSearch,
1324
+ )
997
1325
 
998
1326
  // --------------------------------------------
999
1327
  // Load canned responses
1000
1328
  // --------------------------------------------
1001
- this.loadTagsCanned(strSearch, this.conversationWith);
1329
+ this.loadTagsCanned(strSearch, this.conversationWith)
1002
1330
 
1003
1331
  // ------------------------------------------------------------------------------------------------------------------------------------------
1004
1332
  // Hide / display Canned when the SLASH has POSITION POS 0 and checking if there is a space after the SLASH (in this case it will be hidden)
1005
1333
  // ------------------------------------------------------------------------------------------------------------------------------------------
1006
1334
 
1007
- var after_slash = message.substring(message.lastIndexOf("/") + 1, message.length);
1008
- if (pos === 0 && after_slash.length === 1 && after_slash.trim() === '') {
1009
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is a white space after ');
1335
+ var after_slash = message.substring(
1336
+ message.lastIndexOf('/') + 1,
1337
+ message.length,
1338
+ )
1339
+ if (
1340
+ pos === 0 &&
1341
+ after_slash.length === 1 &&
1342
+ after_slash.trim() === ''
1343
+ ) {
1344
+ this.logger.log(
1345
+ '[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is a white space after ',
1346
+ )
1010
1347
  this.HIDE_CANNED_RESPONSES = true
1011
1348
  this.tagsCannedFilter = []
1012
1349
  } else if (pos === 0 && after_slash.length === 0) {
1013
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is NOT a white space after');
1350
+ this.logger.log(
1351
+ '[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is NOT a white space after',
1352
+ )
1014
1353
  this.HIDE_CANNED_RESPONSES = false
1015
1354
  }
1016
1355
 
1017
-
1018
1356
  if (pos > 0) {
1019
-
1020
1357
  // ------------------------------------------------------------------------------------------------------------------------------------------
1021
1358
  // Hide / display Canned when the SLASH has POSITION POS > and checking if there is a space after the SLASH (in this case they it be hidden)
1022
1359
  // and if there is not a space before the SLASH (in this it will be hidden)
@@ -1024,228 +1361,335 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1024
1361
 
1025
1362
  let beforeSlash = message.substr(pos - 1)
1026
1363
  let afterSlash = message.substr(pos + 1)
1027
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos);
1028
-
1029
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash', beforeSlash);
1030
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash', afterSlash);
1031
- var afterSlashParts = afterSlash.split("/")
1032
- var beforeSlashParts = beforeSlash.split("/")
1033
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash parts', afterSlashParts);
1034
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash parts', beforeSlashParts);
1364
+ this.logger.log(
1365
+ '[CONVS-DETAIL] - returnChangeTextArea * POS ',
1366
+ pos,
1367
+ )
1368
+
1369
+ this.logger.log(
1370
+ '[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash',
1371
+ beforeSlash,
1372
+ )
1373
+ this.logger.log(
1374
+ '[CONVS-DETAIL] - returnChangeTextArea --> afterSlash',
1375
+ afterSlash,
1376
+ )
1377
+ var afterSlashParts = afterSlash.split('/')
1378
+ var beforeSlashParts = beforeSlash.split('/')
1379
+ this.logger.log(
1380
+ '[CONVS-DETAIL] - returnChangeTextArea --> afterSlash parts',
1381
+ afterSlashParts,
1382
+ )
1383
+ this.logger.log(
1384
+ '[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash parts',
1385
+ beforeSlashParts,
1386
+ )
1035
1387
 
1036
1388
  if (beforeSlashParts.length === 2) {
1037
- if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0] === '') {
1389
+ if (
1390
+ beforeSlashParts[0].indexOf(' ') >= 0 &&
1391
+ afterSlashParts[0] === ''
1392
+ ) {
1038
1393
  this.HIDE_CANNED_RESPONSES = false
1039
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash there is a white space After Not');
1394
+ this.logger.log(
1395
+ '[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash there is a white space After Not',
1396
+ )
1040
1397
  // if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0].indexOf(' ') >= 0)
1041
- } else if (beforeSlashParts[0].indexOf(' ') < 0 && afterSlashParts[0] === '') {
1042
- this.HIDE_CANNED_RESPONSES = true;
1398
+ } else if (
1399
+ beforeSlashParts[0].indexOf(' ') < 0 &&
1400
+ afterSlashParts[0] === ''
1401
+ ) {
1402
+ this.HIDE_CANNED_RESPONSES = true
1043
1403
  this.tagsCannedFilter = []
1044
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After Not');
1045
- } else if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0] === ' ') {
1046
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After YES');
1047
- this.HIDE_CANNED_RESPONSES = true;
1404
+ this.logger.log(
1405
+ '[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After Not',
1406
+ )
1407
+ } else if (
1408
+ beforeSlashParts[0].indexOf(' ') >= 0 &&
1409
+ afterSlashParts[0] === ' '
1410
+ ) {
1411
+ this.logger.log(
1412
+ '[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After YES',
1413
+ )
1414
+ this.HIDE_CANNED_RESPONSES = true
1048
1415
  this.tagsCannedFilter = []
1049
1416
  }
1050
1417
  }
1051
1418
  }
1052
-
1053
-
1054
1419
  } else {
1055
- this.tagsCannedFilter = [];
1420
+ this.tagsCannedFilter = []
1056
1421
  }
1057
1422
  }
1058
- }, 300);
1059
-
1423
+ }, 300)
1060
1424
  }
1061
1425
  // ./ CANNED RESPONSES //
1062
-
1063
1426
  } catch (err) {
1064
- this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err);
1427
+ this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err)
1065
1428
  }
1066
1429
  }
1067
1430
 
1068
-
1069
-
1070
1431
  // ----------------------------------------------------------
1071
1432
  // @ CANNED RESPONSES methods
1072
1433
  // ----------------------------------------------------------
1073
1434
  loadTagsCanned(strSearch, conversationWith) {
1074
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned strSearch ", strSearch);
1075
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned groupDetail ", this.groupDetail);
1076
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned conversationWith ", conversationWith);
1077
-
1078
- const conversationWith_segments = conversationWith.split('-');
1079
- // Removes the last element of the array if is = to the separator
1080
- if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
1081
- conversationWith_segments.pop();
1435
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned strSearch ', strSearch)
1436
+ this.logger.log(
1437
+ '[CONVS-DETAIL] - loadTagsCanned groupDetail ',
1438
+ this.groupDetail,
1439
+ )
1440
+ this.logger.log(
1441
+ '[CONVS-DETAIL] - loadTagsCanned conversationWith ',
1442
+ conversationWith,
1443
+ )
1444
+
1445
+ const conversationWith_segments = conversationWith.split('-')
1446
+ // Removes the last element of the array if is = to the separator
1447
+ if (
1448
+ conversationWith_segments[conversationWith_segments.length - 1] === ''
1449
+ ) {
1450
+ conversationWith_segments.pop()
1082
1451
  }
1083
1452
 
1084
1453
  if (conversationWith_segments.length === 4) {
1085
- const lastArrayElement = conversationWith_segments[conversationWith_segments.length - 1]
1086
- this.logger.log('[CONVS-DETAIL] - lastArrayElement ', lastArrayElement);
1087
- this.logger.log('[CONVS-DETAIL] - lastArrayElement length', lastArrayElement.length);
1454
+ const lastArrayElement =
1455
+ conversationWith_segments[conversationWith_segments.length - 1]
1456
+ this.logger.log('[CONVS-DETAIL] - lastArrayElement ', lastArrayElement)
1457
+ this.logger.log(
1458
+ '[CONVS-DETAIL] - lastArrayElement length',
1459
+ lastArrayElement.length,
1460
+ )
1088
1461
  if (lastArrayElement.length !== 32) {
1089
- conversationWith_segments.pop();
1462
+ conversationWith_segments.pop()
1090
1463
  }
1091
1464
  }
1092
1465
 
1093
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ", conversationWith_segments);
1094
- let projectId = ""
1466
+ this.logger.log(
1467
+ '[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ',
1468
+ conversationWith_segments,
1469
+ )
1470
+ let projectId = ''
1095
1471
 
1096
1472
  if (conversationWith_segments.length === 4) {
1097
- projectId = conversationWith_segments[2];
1098
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned projectId ", projectId);
1473
+ projectId = conversationWith_segments[2]
1474
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned projectId ', projectId)
1099
1475
 
1100
1476
  this.getAndShowCannedResponses(strSearch, projectId)
1101
-
1102
1477
  } else {
1103
1478
  this.getProjectIdByConversationWith(strSearch, this.conversationWith)
1104
1479
  }
1105
1480
  }
1106
1481
 
1107
1482
  getProjectIdByConversationWith(strSearch, conversationWith: string) {
1108
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
1109
-
1110
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe(res => {
1111
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res);
1112
- if (res) {
1113
- const projectId = res.id_project
1114
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId);
1115
- if (projectId) {
1116
- this.getAndShowCannedResponses(strSearch, projectId)
1117
- }
1118
- }
1119
-
1120
- }, (error) => {
1121
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error);
1122
-
1123
- }, () => {
1124
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *');
1125
-
1126
- });
1483
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1484
+
1485
+ this.tiledeskService
1486
+ .getProjectIdByConvRecipient(tiledeskToken, conversationWith)
1487
+ .subscribe(
1488
+ (res) => {
1489
+ this.logger.log(
1490
+ '[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES',
1491
+ res,
1492
+ )
1493
+ if (res) {
1494
+ const projectId = res.id_project
1495
+ this.logger.log(
1496
+ '[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ',
1497
+ projectId,
1498
+ )
1499
+ if (projectId) {
1500
+ this.getAndShowCannedResponses(strSearch, projectId)
1501
+ }
1502
+ }
1503
+ },
1504
+ (error) => {
1505
+ this.logger.error(
1506
+ '[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ',
1507
+ error,
1508
+ )
1509
+ },
1510
+ () => {
1511
+ this.logger.log(
1512
+ '[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
1513
+ )
1514
+ },
1515
+ )
1127
1516
  }
1128
1517
 
1129
1518
  getAndShowCannedResponses(strSearch, projectId) {
1130
-
1131
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
1132
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned tagsCanned.length', this.tagsCanned.length);
1519
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1520
+ this.logger.log(
1521
+ '[CONVS-DETAIL] - loadTagsCanned tagsCanned.length',
1522
+ this.tagsCanned.length,
1523
+ )
1133
1524
  //if(this.tagsCanned.length <= 0 ){
1134
- this.tagsCanned = [];
1135
- this.cannedResponsesService.getCannedResponses(tiledeskToken, projectId).subscribe(res => {
1136
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses RES', res);
1137
-
1138
- this.tagsCanned = res
1139
- this.tagsCannedCount = res.length
1140
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses tagsCannedCount', this.tagsCannedCount);
1141
- if (this.HIDE_CANNED_RESPONSES === false) {
1142
- this.showTagsCanned(strSearch);
1143
- }
1144
-
1145
- }, (error) => {
1146
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned getCannedResponses - ERROR ', error);
1147
-
1148
- }, () => {
1149
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses * COMPLETE *');
1150
-
1151
- });
1525
+ this.tagsCanned = []
1526
+ this.cannedResponsesService
1527
+ .getCannedResponses(tiledeskToken, projectId)
1528
+ .subscribe(
1529
+ (res) => {
1530
+ this.logger.log(
1531
+ '[CONVS-DETAIL] - loadTagsCanned getCannedResponses RES',
1532
+ res,
1533
+ )
1534
+
1535
+ this.tagsCanned = res
1536
+ this.tagsCannedCount = res.length
1537
+ this.logger.log(
1538
+ '[CONVS-DETAIL] - loadTagsCanned getCannedResponses tagsCannedCount',
1539
+ this.tagsCannedCount,
1540
+ )
1541
+ if (this.HIDE_CANNED_RESPONSES === false) {
1542
+ this.showTagsCanned(strSearch)
1543
+ }
1544
+ },
1545
+ (error) => {
1546
+ this.logger.error(
1547
+ '[CONVS-DETAIL] - loadTagsCanned getCannedResponses - ERROR ',
1548
+ error,
1549
+ )
1550
+ },
1551
+ () => {
1552
+ this.logger.log(
1553
+ '[CONVS-DETAIL] - loadTagsCanned getCannedResponses * COMPLETE *',
1554
+ )
1555
+ },
1556
+ )
1152
1557
  }
1153
1558
 
1154
-
1155
1559
  showTagsCanned(strSearch) {
1156
- this.logger.log('[CONVS-DETAIL] - showTagsCanned strSearch ', strSearch);
1157
- this.tagsCannedFilter = [];
1158
- var tagsCannedClone = JSON.parse(JSON.stringify(this.tagsCanned));
1159
- this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedClone ', tagsCannedClone);
1560
+ this.logger.log('[CONVS-DETAIL] - showTagsCanned strSearch ', strSearch)
1561
+ this.tagsCannedFilter = []
1562
+ var tagsCannedClone = JSON.parse(JSON.stringify(this.tagsCanned))
1563
+ this.logger.log(
1564
+ '[CONVS-DETAIL] - showTagsCanned tagsCannedClone ',
1565
+ tagsCannedClone,
1566
+ )
1160
1567
  //this.logger.log("that.contacts lenght:: ", strSearch);
1161
- this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch);
1162
- this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedFilter ', this.tagsCannedFilter);
1163
-
1164
- this.tagsCannedFilter.sort(compareValues('title', 'asc'));
1165
- var strReplace = strSearch;
1568
+ this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch)
1569
+ this.logger.log(
1570
+ '[CONVS-DETAIL] - showTagsCanned tagsCannedFilter ',
1571
+ this.tagsCannedFilter,
1572
+ )
1573
+
1574
+ this.tagsCannedFilter.sort(compareValues('title', 'asc'))
1575
+ var strReplace = strSearch
1166
1576
  if (strSearch.length > 0) {
1167
- strReplace = "<b class='highlight-search-string'>" + strSearch + "</b>";
1577
+ strReplace = "<b class='highlight-search-string'>" + strSearch + '</b>'
1168
1578
  }
1169
1579
  for (var i = 0; i < this.tagsCannedFilter.length; i++) {
1170
- const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(this.tagsCannedFilter[i].text) + "</div>";
1171
- this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + this.tagsCannedFilter[i].title.toString().replace(strSearch, strReplace.trim()) + "</div>" + textCanned + '</div>';
1580
+ const textCanned =
1581
+ "<div class='cannedText'>" +
1582
+ this.replacePlaceholderInCanned(this.tagsCannedFilter[i].text) +
1583
+ '</div>'
1584
+ this.tagsCannedFilter[i].title =
1585
+ "<div class='cannedContent'><div class='cannedTitle'>" +
1586
+ this.tagsCannedFilter[i].title
1587
+ .toString()
1588
+ .replace(strSearch, strReplace.trim()) +
1589
+ '</div>' +
1590
+ textCanned +
1591
+ '</div>'
1172
1592
  }
1173
1593
  if (this.tagsCannedCount === 0) {
1174
- const nocanned = { 'title': "<div class='cannedContent'><div class='cannedTitle nocannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div><div class='cannedText'>" + this.translationMap.get('TO_CREATE_THEM_GO_TO_THE_PROJECT') + "</div></div>", "text": "There are no canned responses available" }
1594
+ const nocanned = {
1595
+ title:
1596
+ "<div class='cannedContent'><div class='cannedTitle nocannedTitle'>" +
1597
+ this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') +
1598
+ ".</div><div class='cannedText'>" +
1599
+ this.translationMap.get('TO_CREATE_THEM_GO_TO_THE_PROJECT') +
1600
+ '</div></div>',
1601
+ text: 'There are no canned responses available',
1602
+ }
1175
1603
  this.tagsCannedFilter.push(nocanned)
1176
1604
  }
1177
1605
  }
1178
1606
 
1179
1607
  filterItems(items, searchTerm) {
1180
- this.logger.log('[CONVS-DETAIL] filterItems tagsCannedClone ', items, ' searchTerm: ', searchTerm);
1608
+ this.logger.log(
1609
+ '[CONVS-DETAIL] filterItems tagsCannedClone ',
1610
+ items,
1611
+ ' searchTerm: ',
1612
+ searchTerm,
1613
+ )
1181
1614
  //this.logger.log("filterItems::: ",searchTerm);
1182
1615
  return items.filter((item) => {
1183
1616
  //this.logger.log("filterItems::: ", item.title.toString().toLowerCase());
1184
- this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item);
1185
- return item.title.toString().toLowerCase().indexOf(searchTerm.toString().toLowerCase()) > -1;
1186
- });
1617
+ this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item)
1618
+ return (
1619
+ item.title
1620
+ .toString()
1621
+ .toLowerCase()
1622
+ .indexOf(searchTerm.toString().toLowerCase()) > -1
1623
+ )
1624
+ })
1187
1625
  }
1188
1626
 
1189
1627
  replacePlaceholderInCanned(str) {
1190
- this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str);
1191
- str = str.replace('$recipient_name', this.conversationWithFullname);
1628
+ this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
1629
+ str = str.replace('$recipient_name', this.conversationWithFullname)
1192
1630
  if (this.loggedUser && this.loggedUser.fullname) {
1193
- str = str.replace('$agent_name', this.loggedUser.fullname);
1631
+ str = str.replace('$agent_name', this.loggedUser.fullname)
1194
1632
  }
1195
- return str;
1633
+ return str
1196
1634
  }
1197
1635
 
1198
1636
  replaceTagInMessage(canned, event) {
1199
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage event ", event);
1200
- const elTextArea = this.rowTextArea['el'];
1201
- const textArea = elTextArea.getElementsByTagName('ion-textarea')[0];
1637
+ this.logger.log('[CONVS-DETAIL] replaceTagInMessage event ', event)
1638
+ const elTextArea = this.rowTextArea['el']
1639
+ const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1202
1640
 
1203
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage textArea ", textArea);
1204
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage textArea value", textArea.value)
1641
+ this.logger.log('[CONVS-DETAIL] replaceTagInMessage textArea ', textArea)
1642
+ this.logger.log(
1643
+ '[CONVS-DETAIL] replaceTagInMessage textArea value',
1644
+ textArea.value,
1645
+ )
1205
1646
 
1206
1647
  // var lastChar = textArea.value.substr(-1); // Selects the last character
1207
- // if (lastChar === '/') {
1648
+ // if (lastChar === '/') {
1208
1649
  // textArea.value = textArea.value.substring(0, textArea.value.length() - 1);
1209
1650
  // }
1210
1651
  // this.insertAtCursor(this.textArea, textArea.value)
1211
1652
 
1212
-
1213
1653
  this.arrowkeyLocation = -1
1214
- this.tagsCannedFilter = [];
1215
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage canned text ", canned.text);
1216
-
1654
+ this.tagsCannedFilter = []
1655
+ this.logger.log(
1656
+ '[CONVS-DETAIL] replaceTagInMessage canned text ',
1657
+ canned.text,
1658
+ )
1217
1659
 
1218
1660
  // replace text
1219
- var pos = textArea.value.lastIndexOf("/");
1220
- var strSearch = textArea.value.substr(pos);
1221
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage strSearch ", strSearch);
1661
+ var pos = textArea.value.lastIndexOf('/')
1662
+ var strSearch = textArea.value.substr(pos)
1663
+ this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strSearch)
1222
1664
 
1223
- var strTEMP = textArea.value.replace(strSearch, canned.text);
1224
- strTEMP = this.replacePlaceholderInCanned(strTEMP);
1225
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage strSearch ", strTEMP);
1665
+ var strTEMP = textArea.value.replace(strSearch, canned.text)
1666
+ strTEMP = this.replacePlaceholderInCanned(strTEMP)
1667
+ this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strTEMP)
1226
1668
  // strTEMP = this.replacePlaceholderInCanned(strTEMP);
1227
1669
  // textArea.value = '';
1228
1670
  // that.messageString = strTEMP;
1229
- textArea.value = strTEMP;
1671
+ textArea.value = strTEMP
1230
1672
  setTimeout(() => {
1231
1673
  // textArea.focus();
1232
- textArea.setFocus();
1233
- this.resizeTextArea();
1234
- }, 200);
1674
+ textArea.setFocus()
1675
+ this.resizeTextArea()
1676
+ }, 200)
1235
1677
  }
1236
1678
 
1237
-
1238
1679
  hasClickedOpenCannedResponses($event) {
1239
1680
  this.logger.log('[CONVS-DETAIL] - hasClickedOpenCannedResponses ', $event)
1240
- const elTextArea = this.rowTextArea['el'];
1241
- const textArea = elTextArea.getElementsByTagName('ion-textarea')[0];
1681
+ const elTextArea = this.rowTextArea['el']
1682
+ const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1242
1683
 
1243
- this.logger.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea ", textArea);
1684
+ this.logger.log(
1685
+ '[CONVS-DETAIL] hasClickedOpenCannedResponses textArea ',
1686
+ textArea,
1687
+ )
1244
1688
  // console.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea value", textArea.value)
1245
1689
  var lastChar = textArea.value[textArea.value.length - 1]
1246
1690
  // console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses lastChar', lastChar)
1247
- if (lastChar !== '/' ) {
1248
- this.insertAtCursor(textArea, '/');
1691
+ if (lastChar !== '/') {
1692
+ this.insertAtCursor(textArea, '/')
1249
1693
  }
1250
1694
  // console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea.value', textArea.value)
1251
1695
  // setTimeout(() => {
@@ -1260,13 +1704,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1260
1704
 
1261
1705
  setCaretPosition(ctrl) {
1262
1706
  ctrl.value.trim()
1263
- ctrl.setFocus();
1707
+ ctrl.setFocus()
1264
1708
  }
1265
1709
 
1266
1710
  insertAtCursor(myField, myValue) {
1267
- this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue);
1268
- this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField);
1269
-
1711
+ this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue)
1712
+ this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField)
1270
1713
 
1271
1714
  // myValue = ' ' + myValue;
1272
1715
 
@@ -1274,38 +1717,41 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1274
1717
  // console.log('[CONVS-DETAIL] - GET TEXT AREA - Here yes textArea value length', myField.value.length);
1275
1718
 
1276
1719
  if (myField.value.length > 0) {
1277
- myValue = ' ' + myValue;
1720
+ myValue = ' ' + myValue
1278
1721
  }
1279
1722
 
1280
1723
  //IE support
1281
1724
  if (myField.selection) {
1282
- myField.focus();
1283
- let sel = myField.selection.createRange();
1284
- sel.text = myValue;
1725
+ myField.focus()
1726
+ let sel = myField.selection.createRange()
1727
+ sel.text = myValue
1285
1728
  // this.cannedResponseMessage = sel.text;
1286
1729
  }
1287
1730
  //MOZILLA and others
1288
1731
  else if (myField.selectionStart || myField.selectionStart == '0') {
1289
- var startPos = myField.selectionStart;
1290
- this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos);
1732
+ var startPos = myField.selectionStart
1733
+ this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos)
1291
1734
 
1292
- var endPos = myField.selectionEnd;
1293
- this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos);
1735
+ var endPos = myField.selectionEnd
1736
+ this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos)
1294
1737
 
1295
- myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
1738
+ myField.value =
1739
+ myField.value.substring(0, startPos) +
1740
+ myValue +
1741
+ myField.value.substring(endPos, myField.value.length)
1296
1742
 
1297
1743
  // place cursor at end of text in text input element
1298
- myField.focus();
1299
- var val = myField.value; //store the value of the element
1300
- myField.value = ''; //clear the value of the element
1301
- myField.value = val + ' '; //set that value back.
1744
+ myField.focus()
1745
+ var val = myField.value //store the value of the element
1746
+ myField.value = '' //clear the value of the element
1747
+ myField.value = val + ' ' //set that value back.
1302
1748
 
1303
1749
  // this.cannedResponseMessage = myField.value;
1304
1750
 
1305
1751
  // this.texareaIsEmpty = false;
1306
1752
  // myField.select();
1307
1753
  } else {
1308
- myField.value += myValue;
1754
+ myField.value += myValue
1309
1755
  // this.cannedResponseMessage = myField.value;
1310
1756
  }
1311
1757
  }
@@ -1315,30 +1761,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1315
1761
  // this.logger.log("CONVERSATION-DETAIL handleKeyboardEvent event.key ", event.key);
1316
1762
 
1317
1763
  if (this.tagsCannedFilter.length > 0) {
1318
-
1319
1764
  if (event.key === 'ArrowDown') {
1320
-
1321
- this.arrowkeyLocation++;
1765
+ this.arrowkeyLocation++
1322
1766
  if (this.arrowkeyLocation === this.tagsCannedFilter.length) {
1323
1767
  this.arrowkeyLocation--
1324
1768
  }
1325
1769
  // this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
1326
- }
1327
- else if (event.key === 'ArrowUp') {
1328
-
1770
+ } else if (event.key === 'ArrowUp') {
1329
1771
  if (this.arrowkeyLocation > 0) {
1330
- this.arrowkeyLocation--;
1772
+ this.arrowkeyLocation--
1331
1773
  } else if (this.arrowkeyLocation < 0) {
1332
- this.arrowkeyLocation++;
1774
+ this.arrowkeyLocation++
1333
1775
  }
1334
1776
  // this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
1335
1777
  }
1336
1778
 
1337
1779
  if (event.key === 'Enter') {
1338
1780
  const canned_selected = this.tagsCannedFilter[this.arrowkeyLocation]
1339
- this.logger.log('[CONVS-DETAIL] replaceTagInMessage canned_selected ', canned_selected)
1781
+ this.logger.log(
1782
+ '[CONVS-DETAIL] replaceTagInMessage canned_selected ',
1783
+ canned_selected,
1784
+ )
1340
1785
  if (canned_selected) {
1341
-
1342
1786
  this.replaceTagInMessage(canned_selected, 'enter')
1343
1787
  // event.preventDefault();
1344
1788
  // return false;
@@ -1350,35 +1794,40 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1350
1794
  // ./end CANNED RESPONSES methods
1351
1795
  // ----------------------------------------------------------
1352
1796
 
1353
-
1354
-
1355
1797
  // ----------------------------------------------------------
1356
- // @ Rule of sound message
1798
+ // @ Rule of sound message
1357
1799
  // * if I send it -> NO SOUND
1358
1800
  // * if I'm not in the conversation -> SOUND
1359
1801
  // * if I'm in the conversation at the bottom of the page -> NO SOUND
1360
1802
  // * otherwise -> SOUND
1361
1803
  // ----------------------------------------------------------
1362
1804
  soundMessage() {
1363
- const that = this;
1364
- this.audio = new Audio();
1805
+ const that = this
1806
+ this.audio = new Audio()
1365
1807
  // this.audio.src = '/assets/sounds/pling.mp3';
1366
- this.audio.src = URL_SOUND_LIST_CONVERSATION;
1367
- this.audio.load();
1368
- this.logger.log('[CONVS-DETAIL] soundMessage conversation this.audio', this.audio);
1369
- clearTimeout(this.setTimeoutSound);
1808
+ this.audio.src = URL_SOUND_LIST_CONVERSATION
1809
+ this.audio.load()
1810
+ this.logger.log(
1811
+ '[CONVS-DETAIL] soundMessage conversation this.audio',
1812
+ this.audio,
1813
+ )
1814
+ clearTimeout(this.setTimeoutSound)
1370
1815
  this.setTimeoutSound = setTimeout(function () {
1371
- that.audio.play().then(() => {
1372
- // Audio is playing.
1373
- this.logger.log('[CONVS-DETAIL] soundMessag that.audio.src ', that.audio.src);
1374
- }).catch(error => {
1375
- that.logger.error(error);
1376
- });
1377
- }, 1000);
1816
+ that.audio
1817
+ .play()
1818
+ .then(() => {
1819
+ // Audio is playing.
1820
+ this.logger.log(
1821
+ '[CONVS-DETAIL] soundMessag that.audio.src ',
1822
+ that.audio.src,
1823
+ )
1824
+ })
1825
+ .catch((error) => {
1826
+ that.logger.error(error)
1827
+ })
1828
+ }, 1000)
1378
1829
  }
1379
1830
 
1380
-
1381
-
1382
1831
  returnOnBeforeMessageRender(event) {
1383
1832
  //this.onBeforeMessageRender.emit(event)
1384
1833
  }
@@ -1391,86 +1840,83 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1391
1840
  // this.isMenuShow = event;
1392
1841
  }
1393
1842
 
1394
- returnOnScrollContent(event: boolean) {
1395
-
1396
- }
1843
+ returnOnScrollContent(event: boolean) {}
1397
1844
 
1398
1845
  returnOnAttachmentButtonClicked(event: any) {
1399
1846
  this.logger.debug('[CONV-COMP] eventbutton', event)
1400
1847
  if (!event || !event.target.type) {
1401
- return;
1848
+ return
1402
1849
  }
1403
1850
  switch (event.target.type) {
1404
1851
  case 'url':
1405
1852
  try {
1406
- this.openLink(event.target.button);
1853
+ this.openLink(event.target.button)
1407
1854
  } catch (err) {
1408
- this.logger.error('[CONV-COMP] url > Error :' + err);
1855
+ this.logger.error('[CONV-COMP] url > Error :' + err)
1409
1856
  }
1410
- return;
1857
+ return
1411
1858
  case 'action':
1412
1859
  try {
1413
- this.actionButton(event.target.button);
1860
+ this.actionButton(event.target.button)
1414
1861
  } catch (err) {
1415
- this.logger.error('[CONV-COMP] action > Error :' + err);
1862
+ this.logger.error('[CONV-COMP] action > Error :' + err)
1416
1863
  }
1417
- return false;
1864
+ return false
1418
1865
  case 'text':
1419
1866
  try {
1420
1867
  const text = event.target.button.value
1421
- const metadata = { 'button': true };
1422
- this.sendMessage(text, TYPE_MSG_TEXT, metadata);
1868
+ const metadata = { button: true }
1869
+ this.sendMessage(text, TYPE_MSG_TEXT, metadata)
1423
1870
  } catch (err) {
1424
- this.logger.error('[CONV-COMP] text > Error :' + err);
1871
+ this.logger.error('[CONV-COMP] text > Error :' + err)
1425
1872
  }
1426
- default: return;
1873
+ default:
1874
+ return
1427
1875
  }
1428
1876
  }
1429
1877
 
1430
1878
  onImageRenderedFN(event) {
1431
- const imageRendered = event;
1879
+ const imageRendered = event
1432
1880
  if (this.showButtonToBottom) {
1433
1881
  this.scrollBottom(0)
1434
1882
  }
1435
1883
  }
1436
1884
 
1437
-
1438
1885
  private openLink(event: any) {
1439
- const link = event.link ? event.link : '';
1440
- const target = event.target ? event.target : '';
1886
+ const link = event.link ? event.link : ''
1887
+ const target = event.target ? event.target : ''
1441
1888
  if (target === 'self' || target === 'parent') {
1442
- window.open(link, '_parent');
1889
+ window.open(link, '_parent')
1443
1890
  } else {
1444
- window.open(link, '_blank');
1891
+ window.open(link, '_blank')
1445
1892
  }
1446
1893
  }
1447
1894
 
1448
-
1449
1895
  private actionButton(event: any) {
1450
1896
  // console.log(event);
1451
- const action = event.action ? event.action : '';
1452
- const message = event.value ? event.value : '';
1453
- const subtype = event.show_reply ? '' : 'info';
1897
+ const action = event.action ? event.action : ''
1898
+ const message = event.value ? event.value : ''
1899
+ const subtype = event.show_reply ? '' : 'info'
1454
1900
 
1455
1901
  const attributes = {
1456
1902
  action: action,
1457
- subtype: subtype
1458
- };
1459
- this.sendMessage(message, TYPE_MSG_TEXT, null, attributes);
1460
- this.logger.debug('[CONV-COMP] > action :');
1903
+ subtype: subtype,
1904
+ }
1905
+ this.sendMessage(message, TYPE_MSG_TEXT, null, attributes)
1906
+ this.logger.debug('[CONV-COMP] > action :')
1461
1907
  }
1462
1908
 
1463
1909
  addUploadingBubbleEvent(event: boolean) {
1464
- this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event);
1910
+ this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event)
1465
1911
  if (event === true) {
1466
- this.scrollBottom(0);
1912
+ this.scrollBottom(0)
1467
1913
  }
1468
1914
  }
1469
1915
 
1470
1916
  onPresentModalScrollToBottom(event: boolean) {
1471
- this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event);
1917
+ this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event)
1472
1918
  if (event === true) {
1473
- this.scrollBottom(0);
1919
+ this.scrollBottom(0)
1474
1920
  }
1475
1921
  }
1476
1922
 
@@ -1478,25 +1924,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1478
1924
  /** */
1479
1925
  resizeTextArea() {
1480
1926
  try {
1481
- const elTextArea = this.rowTextArea['el'];
1482
- const that = this;
1927
+ const elTextArea = this.rowTextArea['el']
1928
+ const that = this
1483
1929
  setTimeout(() => {
1484
- const textArea = elTextArea.getElementsByTagName('ion-textarea')[0];
1930
+ const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1485
1931
  if (textArea) {
1486
- this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea);
1487
- const txtValue = textArea.value;
1488
- textArea.value = ' ';
1489
- textArea.value = txtValue;
1932
+ this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea)
1933
+ const txtValue = textArea.value
1934
+ textArea.value = ' '
1935
+ textArea.value = txtValue
1490
1936
  }
1491
- }, 0);
1937
+ }, 0)
1492
1938
  setTimeout(() => {
1493
1939
  if (elTextArea) {
1494
- this.logger.log('[CONVS-DETAIL] resizeTextArea elTextArea.offsetHeight ', elTextArea.offsetHeight);
1495
- that.heightMessageTextArea = elTextArea.offsetHeight;
1940
+ this.logger.log(
1941
+ '[CONVS-DETAIL] resizeTextArea elTextArea.offsetHeight ',
1942
+ elTextArea.offsetHeight,
1943
+ )
1944
+ that.heightMessageTextArea = elTextArea.offsetHeight
1496
1945
  }
1497
- }, 100);
1946
+ }, 100)
1498
1947
  } catch (err) {
1499
- this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err);
1948
+ this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err)
1500
1949
  }
1501
1950
  }
1502
1951
 
@@ -1505,11 +1954,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1505
1954
  * @param time
1506
1955
  */
1507
1956
  private scrollBottom(time: number) {
1508
- this.showIonContent = true;
1957
+ this.showIonContent = true
1509
1958
  if (this.ionContentChatArea) {
1510
1959
  setTimeout(() => {
1511
- this.ionContentChatArea.scrollToBottom(time);
1512
- }, 0);
1960
+ this.ionContentChatArea.scrollToBottom(time)
1961
+ }, 0)
1513
1962
  // nota: se elimino il settimeout lo scrollToBottom non viene richiamato!!!!!
1514
1963
  }
1515
1964
  }
@@ -1518,14 +1967,17 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1518
1967
  * detectBottom
1519
1968
  */
1520
1969
  async detectBottom() {
1521
- const scrollElement = await this.ionContentChatArea.getScrollElement();
1970
+ const scrollElement = await this.ionContentChatArea.getScrollElement()
1522
1971
 
1523
- if (scrollElement.scrollTop < scrollElement.scrollHeight - scrollElement.clientHeight) {
1972
+ if (
1973
+ scrollElement.scrollTop <
1974
+ scrollElement.scrollHeight - scrollElement.clientHeight
1975
+ ) {
1524
1976
  //NON SONO ALLA FINE --> mostra badge
1525
- this.showButtonToBottom = true;
1977
+ this.showButtonToBottom = true
1526
1978
  } else {
1527
1979
  // SONO ALLA FINE --> non mostrare badge,
1528
- this.showButtonToBottom = false;
1980
+ this.showButtonToBottom = false
1529
1981
  }
1530
1982
  }
1531
1983
 
@@ -1534,149 +1986,203 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1534
1986
  * FIREBY BY: click event ScrollToBottom bottom-right icon button
1535
1987
  */
1536
1988
  public actionScrollBottom() {
1537
- this.logger.log('[CONVS-DETAIL] actionScrollBottom - ionContentChatArea: ', this.ionContentChatArea);
1989
+ this.logger.log(
1990
+ '[CONVS-DETAIL] actionScrollBottom - ionContentChatArea: ',
1991
+ this.ionContentChatArea,
1992
+ )
1538
1993
  // const that = this;
1539
- this.showButtonToBottom = false;
1994
+ this.showButtonToBottom = false
1540
1995
  this.updateConversationBadge()
1541
- this.NUM_BADGES = 0;
1996
+ this.NUM_BADGES = 0
1542
1997
  setTimeout(() => {
1543
- this.ionContentChatArea.scrollToBottom(0);
1998
+ this.ionContentChatArea.scrollToBottom(0)
1544
1999
  // this.conversationsHandlerService.readAllMessages.next(this.conversationWith);
1545
- }, 0);
2000
+ }, 0)
1546
2001
  }
1547
2002
 
1548
2003
  /**
1549
2004
  * Scroll to top of the page after a short delay.
1550
2005
  */
1551
2006
  scrollTop() {
1552
- this.logger.log('[CONVS-DETAIL] scrollTop');
1553
- this.ionContentChatArea.scrollToTop(100);
2007
+ this.logger.log('[CONVS-DETAIL] scrollTop')
2008
+ this.ionContentChatArea.scrollToTop(100)
1554
2009
  }
1555
2010
 
1556
2011
  /** */
1557
2012
  setHeightTextArea() {
1558
2013
  try {
1559
2014
  if (this.rowTextArea) {
1560
- this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight;
1561
- this.logger.log('[CONVS-DETAIL] setHeightTextArea - heightMessageTextArea: ', this.heightMessageTextArea);
2015
+ this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight
2016
+ this.logger.log(
2017
+ '[CONVS-DETAIL] setHeightTextArea - heightMessageTextArea: ',
2018
+ this.heightMessageTextArea,
2019
+ )
1562
2020
  }
1563
2021
  } catch (e) {
1564
2022
  this.logger.error('[CONVS-DETAIL] setHeightTextArea - ERROR ', e)
1565
2023
  // this.heightMessageTextArea = '50';
1566
- this.heightMessageTextArea = '57'; // NK edited
2024
+ this.heightMessageTextArea = '57' // NK edited
1567
2025
  }
1568
2026
  }
1569
2027
  checkAcceptedFile(draggedFileMimeType) {
1570
- let isAcceptFile = false;
1571
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept: ', this.appConfigProvider.getConfig().fileUploadAccept);
1572
- const accept_files = this.appConfigProvider.getConfig().fileUploadAccept;
1573
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - mimeType: ', draggedFileMimeType);
1574
- if (accept_files === "*/*") {
1575
- isAcceptFile = true;
2028
+ let isAcceptFile = false
2029
+ this.logger.log(
2030
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept: ',
2031
+ this.appConfigProvider.getConfig().fileUploadAccept,
2032
+ )
2033
+ const accept_files = this.appConfigProvider.getConfig().fileUploadAccept
2034
+ this.logger.log(
2035
+ '[CONVS-DETAIL] > checkAcceptedFile - mimeType: ',
2036
+ draggedFileMimeType,
2037
+ )
2038
+ if (accept_files === '*/*') {
2039
+ isAcceptFile = true
1576
2040
  return isAcceptFile
1577
- } else if (accept_files !== "*/*") {
1578
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept typeof accept_files ', typeof accept_files);
2041
+ } else if (accept_files !== '*/*') {
2042
+ this.logger.log(
2043
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept typeof accept_files ',
2044
+ typeof accept_files,
2045
+ )
1579
2046
  const accept_files_array = accept_files.split(',')
1580
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array ', accept_files_array);
1581
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array typeof: ', typeof accept_files_array);
1582
-
1583
- accept_files_array.forEach(accept_file => {
1584
-
1585
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file ', accept_file);
2047
+ this.logger.log(
2048
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array ',
2049
+ accept_files_array,
2050
+ )
2051
+ this.logger.log(
2052
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array typeof: ',
2053
+ typeof accept_files_array,
2054
+ )
2055
+
2056
+ accept_files_array.forEach((accept_file) => {
2057
+ this.logger.log(
2058
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file ',
2059
+ accept_file,
2060
+ )
1586
2061
  const accept_file_segment = accept_file.split('/')
1587
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file_segment ', accept_file_segment);
2062
+ this.logger.log(
2063
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file_segment ',
2064
+ accept_file_segment,
2065
+ )
1588
2066
  if (accept_file_segment[1] === '*') {
1589
2067
  if (draggedFileMimeType.startsWith(accept_file_segment[0])) {
1590
- isAcceptFile = true;
1591
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile', isAcceptFile);
2068
+ isAcceptFile = true
2069
+ this.logger.log(
2070
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
2071
+ isAcceptFile,
2072
+ )
1592
2073
  return isAcceptFile
1593
-
1594
2074
  } else {
1595
- isAcceptFile = false;
1596
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile', isAcceptFile);
2075
+ isAcceptFile = false
2076
+ this.logger.log(
2077
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
2078
+ isAcceptFile,
2079
+ )
1597
2080
  return isAcceptFile
1598
-
1599
2081
  }
1600
2082
  } else if (accept_file_segment[1] !== '*') {
1601
2083
  if (draggedFileMimeType === accept_file) {
1602
- isAcceptFile = true;
1603
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile', isAcceptFile);
2084
+ isAcceptFile = true
2085
+ this.logger.log(
2086
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
2087
+ isAcceptFile,
2088
+ )
1604
2089
  return isAcceptFile
1605
2090
  }
1606
2091
  }
1607
2092
  return isAcceptFile
1608
- });
2093
+ })
1609
2094
  return isAcceptFile
1610
2095
  }
1611
2096
  }
1612
2097
  // -------------------------------------------------------------
1613
- // DRAG FILE
2098
+ // DRAG FILE
1614
2099
  // -------------------------------------------------------------
1615
2100
  // DROP (WHEN THE FILE IS RELEASED ON THE DROP ZONE)
1616
2101
  drop(ev: any) {
1617
- ev.preventDefault();
1618
- ev.stopPropagation();
1619
-
1620
- this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev ', ev);
1621
- const fileList = ev.dataTransfer.files;
1622
- this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev.dataTransfer.files ', fileList);
1623
- this.isHovering = false;
1624
- this.logger.log('[CONVS-DETAIL] ----> FILE - DROP isHovering ', this.isHovering);
2102
+ ev.preventDefault()
2103
+ ev.stopPropagation()
2104
+
2105
+ this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev ', ev)
2106
+ const fileList = ev.dataTransfer.files
2107
+ this.logger.log(
2108
+ '[CONVS-DETAIL] ----> FILE - DROP ev.dataTransfer.files ',
2109
+ fileList,
2110
+ )
2111
+ this.isHovering = false
2112
+ this.logger.log(
2113
+ '[CONVS-DETAIL] ----> FILE - DROP isHovering ',
2114
+ this.isHovering,
2115
+ )
1625
2116
  if (fileList.length > 0) {
1626
- const file: File = fileList[0];
1627
- this.logger.log('[CONVS-DETAIL] ----> FILE - DROP file ', file);
2117
+ const file: File = fileList[0]
2118
+ this.logger.log('[CONVS-DETAIL] ----> FILE - DROP file ', file)
1628
2119
 
1629
- var mimeType = fileList[0].type;
1630
- this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files ', mimeType);
2120
+ var mimeType = fileList[0].type
2121
+ this.logger.log(
2122
+ '[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
2123
+ mimeType,
2124
+ )
1631
2125
 
1632
2126
  // if (mimeType.startsWith("image") || mimeType.startsWith("application")) {
1633
2127
  // this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files: ', this.appConfigProvider.getConfig().fileUploadAccept);
1634
2128
  // this.checkAcceptedFile(mimeType);
1635
- const isAccepted = this.checkAcceptedFile(mimeType);
1636
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile FILE - DROP', isAccepted);
2129
+ const isAccepted = this.checkAcceptedFile(mimeType)
2130
+ this.logger.log(
2131
+ '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile FILE - DROP',
2132
+ isAccepted,
2133
+ )
1637
2134
  if (isAccepted === true) {
1638
- this.handleDropEvent(ev);
1639
-
2135
+ this.handleDropEvent(ev)
1640
2136
  } else {
1641
- this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files ', mimeType, 'NOT SUPPORTED FILE TYPE');
2137
+ this.logger.log(
2138
+ '[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
2139
+ mimeType,
2140
+ 'NOT SUPPORTED FILE TYPE',
2141
+ )
1642
2142
  this.presentToastOnlyImageFilesAreAllowedToDrag()
1643
2143
  }
1644
2144
  }
1645
2145
  }
1646
2146
 
1647
2147
  handleDropEvent(ev) {
1648
- this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev);
2148
+ this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev)
1649
2149
  this.dropEvent = ev
1650
2150
  }
1651
2151
 
1652
2152
  // DRAG OVER (WHEN HOVER OVER ON THE "DROP ZONE")
1653
2153
  allowDrop(ev: any) {
1654
- ev.preventDefault();
1655
- ev.stopPropagation();
1656
- this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop ev ', ev);
1657
- this.isHovering = true;
1658
- this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop isHovering ', this.isHovering);
2154
+ ev.preventDefault()
2155
+ ev.stopPropagation()
2156
+ this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop ev ', ev)
2157
+ this.isHovering = true
2158
+ this.logger.log(
2159
+ '[CONVS-DETAIL] ----> FILE - (dragover) allowDrop isHovering ',
2160
+ this.isHovering,
2161
+ )
1659
2162
  }
1660
2163
 
1661
2164
  // DRAG LEAVE (WHEN LEAVE FROM THE DROP ZONE)
1662
2165
  drag(ev: any) {
1663
- ev.preventDefault();
1664
- ev.stopPropagation();
1665
- this.logger.log('[CONVS-DETAIL] ----> FILE - (dragleave) drag ev ', ev);
1666
- this.isHovering = false;
1667
- this.logger.log('[CONVS-DETAIL] ----> FILE - FILE - (dragleave) drag his.isHovering ', this.isHovering);
2166
+ ev.preventDefault()
2167
+ ev.stopPropagation()
2168
+ this.logger.log('[CONVS-DETAIL] ----> FILE - (dragleave) drag ev ', ev)
2169
+ this.isHovering = false
2170
+ this.logger.log(
2171
+ '[CONVS-DETAIL] ----> FILE - FILE - (dragleave) drag his.isHovering ',
2172
+ this.isHovering,
2173
+ )
1668
2174
  }
1669
2175
 
1670
2176
  async presentToastOnlyImageFilesAreAllowedToDrag() {
1671
2177
  const toast = await this.toastController.create({
1672
- message: this.translationMap.get('FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED'),
2178
+ message: this.translationMap.get(
2179
+ 'FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED',
2180
+ ),
1673
2181
  duration: 5000,
1674
- color: "danger",
2182
+ color: 'danger',
1675
2183
  cssClass: 'toast-custom-class',
1676
- });
1677
- toast.present();
2184
+ })
2185
+ toast.present()
1678
2186
  }
1679
-
1680
-
1681
2187
  }
1682
- // END ALL //
2188
+ // END ALL //