@chat21/chat21-ionic 3.0.61-rc4 → 3.0.61-rc8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +28 -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 +4 -3
  27. package/src/app/app.component.scss +2 -1
  28. package/src/app/app.component.ts +23 -12
  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 +9 -3
  31. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +2 -2
  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/project-item/project-item.component.html +1 -1
  35. package/src/app/components/sidebar/sidebar.component.html +118 -66
  36. package/src/app/components/sidebar/sidebar.component.scss +49 -4
  37. package/src/app/components/sidebar/sidebar.component.ts +134 -41
  38. package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +13 -5
  39. package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +35 -27
  40. package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +122 -57
  41. package/src/app/pages/conversation-detail/conversation-detail.module.ts +2 -1
  42. package/src/app/pages/conversation-detail/conversation-detail.page.html +5 -4
  43. package/src/app/pages/conversation-detail/conversation-detail.page.ts +1297 -783
  44. package/src/app/pages/conversations-list/conversations-list.module.ts +2 -1
  45. package/src/app/pages/conversations-list/conversations-list.page.html +4 -2
  46. package/src/app/pages/conversations-list/conversations-list.page.scss +9 -1
  47. package/src/app/pages/conversations-list/conversations-list.page.ts +44 -24
  48. package/src/app/pages/loader-preview/loader-preview.page.ts +235 -166
  49. package/src/app/pages/profile-info/profile-info.page.scss +1 -1
  50. package/src/app/services/tiledesk/tiledesk.service.ts +19 -0
  51. package/src/app/utils/scrollbar-theme.directive.ts +58 -24
  52. package/src/assets/i18n/de.json +9 -7
  53. package/src/assets/i18n/en.json +5 -3
  54. package/src/assets/i18n/es.json +4 -2
  55. package/src/assets/i18n/fr.json +7 -5
  56. package/src/assets/i18n/it.json +4 -2
  57. package/src/assets/i18n/pt.json +4 -2
  58. package/src/assets/i18n/ru.json +5 -3
  59. package/src/assets/i18n/sr.json +229 -0
  60. package/src/assets/i18n/tr.json +5 -4
  61. package/src/chat21-core/utils/constants.ts +4 -1
  62. package/src/global.scss +35 -105
  63. package/publish_pre.sh +0 -33
  64. 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,50 +1231,79 @@ 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
- // console.log("[CONVS-DETAIL] - returnChangeTextArea - canned responses pos of / (using lastIndexOf) ", pos);
976
-
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
+ )
1302
+
1303
+ if (pos === -1) {
1304
+ this.tagsCannedFilter = []
1305
+ this.HIDE_CANNED_RESPONSES = true
1306
+ }
977
1307
  // test
978
1308
  // var rest = message.substring(0, message.lastIndexOf("/") + 1);
979
1309
  // var last = message.substring(message.lastIndexOf("/") + 1, message.length);
@@ -986,33 +1316,44 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
986
1316
  // console.log('[CONVS-DETAIL] - returnChangeTextArea last is NOT space ');
987
1317
  // }
988
1318
 
989
-
990
1319
  if (pos >= 0) {
991
- var strSearch = message.substr(pos + 1);
992
- 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
+ )
993
1325
 
994
1326
  // --------------------------------------------
995
1327
  // Load canned responses
996
1328
  // --------------------------------------------
997
- this.loadTagsCanned(strSearch, this.conversationWith);
1329
+ this.loadTagsCanned(strSearch, this.conversationWith)
998
1330
 
999
1331
  // ------------------------------------------------------------------------------------------------------------------------------------------
1000
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)
1001
1333
  // ------------------------------------------------------------------------------------------------------------------------------------------
1002
1334
 
1003
- var after_slash = message.substring(message.lastIndexOf("/") + 1, message.length);
1004
- if (pos === 0 && after_slash.length === 1 && after_slash.trim() === '') {
1005
- 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
+ )
1006
1347
  this.HIDE_CANNED_RESPONSES = true
1007
1348
  this.tagsCannedFilter = []
1008
1349
  } else if (pos === 0 && after_slash.length === 0) {
1009
- 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
+ )
1010
1353
  this.HIDE_CANNED_RESPONSES = false
1011
1354
  }
1012
1355
 
1013
-
1014
1356
  if (pos > 0) {
1015
-
1016
1357
  // ------------------------------------------------------------------------------------------------------------------------------------------
1017
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)
1018
1359
  // and if there is not a space before the SLASH (in this it will be hidden)
@@ -1020,225 +1361,336 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1020
1361
 
1021
1362
  let beforeSlash = message.substr(pos - 1)
1022
1363
  let afterSlash = message.substr(pos + 1)
1023
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos);
1024
-
1025
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash', beforeSlash);
1026
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash', afterSlash);
1027
- var afterSlashParts = afterSlash.split("/")
1028
- var beforeSlashParts = beforeSlash.split("/")
1029
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash parts', afterSlashParts);
1030
- 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
+ )
1031
1387
 
1032
1388
  if (beforeSlashParts.length === 2) {
1033
- if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0] === '') {
1389
+ if (
1390
+ beforeSlashParts[0].indexOf(' ') >= 0 &&
1391
+ afterSlashParts[0] === ''
1392
+ ) {
1034
1393
  this.HIDE_CANNED_RESPONSES = false
1035
- 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
+ )
1036
1397
  // if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0].indexOf(' ') >= 0)
1037
- } else if (beforeSlashParts[0].indexOf(' ') < 0 && afterSlashParts[0] === '') {
1038
- this.HIDE_CANNED_RESPONSES = true;
1398
+ } else if (
1399
+ beforeSlashParts[0].indexOf(' ') < 0 &&
1400
+ afterSlashParts[0] === ''
1401
+ ) {
1402
+ this.HIDE_CANNED_RESPONSES = true
1039
1403
  this.tagsCannedFilter = []
1040
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After Not');
1041
- } else if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0] === ' ') {
1042
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After YES');
1043
- 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
1044
1415
  this.tagsCannedFilter = []
1045
1416
  }
1046
1417
  }
1047
1418
  }
1048
-
1049
-
1050
1419
  } else {
1051
- this.tagsCannedFilter = [];
1420
+ this.tagsCannedFilter = []
1052
1421
  }
1053
1422
  }
1054
- }, 300);
1055
-
1423
+ }, 300)
1056
1424
  }
1057
1425
  // ./ CANNED RESPONSES //
1058
-
1059
1426
  } catch (err) {
1060
- this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err);
1427
+ this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err)
1061
1428
  }
1062
1429
  }
1063
1430
 
1064
-
1065
-
1066
1431
  // ----------------------------------------------------------
1067
1432
  // @ CANNED RESPONSES methods
1068
1433
  // ----------------------------------------------------------
1069
1434
  loadTagsCanned(strSearch, conversationWith) {
1070
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned strSearch ", strSearch);
1071
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned groupDetail ", this.groupDetail);
1072
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned conversationWith ", conversationWith);
1073
-
1074
- const conversationWith_segments = conversationWith.split('-');
1075
- // Removes the last element of the array if is = to the separator
1076
- if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
1077
- 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()
1078
1451
  }
1079
1452
 
1080
1453
  if (conversationWith_segments.length === 4) {
1081
- const lastArrayElement = conversationWith_segments[conversationWith_segments.length - 1]
1082
- this.logger.log('[CONVS-DETAIL] - lastArrayElement ', lastArrayElement);
1083
- 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
+ )
1084
1461
  if (lastArrayElement.length !== 32) {
1085
- conversationWith_segments.pop();
1462
+ conversationWith_segments.pop()
1086
1463
  }
1087
1464
  }
1088
1465
 
1089
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ", conversationWith_segments);
1090
- let projectId = ""
1466
+ this.logger.log(
1467
+ '[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ',
1468
+ conversationWith_segments,
1469
+ )
1470
+ let projectId = ''
1091
1471
 
1092
1472
  if (conversationWith_segments.length === 4) {
1093
- projectId = conversationWith_segments[2];
1094
- this.logger.log("[CONVS-DETAIL] - loadTagsCanned projectId ", projectId);
1473
+ projectId = conversationWith_segments[2]
1474
+ this.logger.log('[CONVS-DETAIL] - loadTagsCanned projectId ', projectId)
1095
1475
 
1096
1476
  this.getAndShowCannedResponses(strSearch, projectId)
1097
-
1098
1477
  } else {
1099
1478
  this.getProjectIdByConversationWith(strSearch, this.conversationWith)
1100
1479
  }
1101
1480
  }
1102
1481
 
1103
1482
  getProjectIdByConversationWith(strSearch, conversationWith: string) {
1104
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
1105
-
1106
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe(res => {
1107
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res);
1108
- if (res) {
1109
- const projectId = res.id_project
1110
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId);
1111
- if (projectId) {
1112
- this.getAndShowCannedResponses(strSearch, projectId)
1113
- }
1114
- }
1115
-
1116
- }, (error) => {
1117
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error);
1118
-
1119
- }, () => {
1120
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *');
1121
-
1122
- });
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
+ )
1123
1516
  }
1124
1517
 
1125
1518
  getAndShowCannedResponses(strSearch, projectId) {
1126
-
1127
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
1128
- 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
+ )
1129
1524
  //if(this.tagsCanned.length <= 0 ){
1130
- this.tagsCanned = [];
1131
- this.cannedResponsesService.getCannedResponses(tiledeskToken, projectId).subscribe(res => {
1132
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses RES', res);
1133
-
1134
- this.tagsCanned = res
1135
- this.tagsCannedCount = res.length
1136
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses tagsCannedCount', this.tagsCannedCount);
1137
- if (this.HIDE_CANNED_RESPONSES === false) {
1138
- this.showTagsCanned(strSearch);
1139
- }
1140
-
1141
- }, (error) => {
1142
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned getCannedResponses - ERROR ', error);
1143
-
1144
- }, () => {
1145
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses * COMPLETE *');
1146
-
1147
- });
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
+ )
1148
1557
  }
1149
1558
 
1150
-
1151
1559
  showTagsCanned(strSearch) {
1152
- this.logger.log('[CONVS-DETAIL] - showTagsCanned strSearch ', strSearch);
1153
- this.tagsCannedFilter = [];
1154
- var tagsCannedClone = JSON.parse(JSON.stringify(this.tagsCanned));
1155
- 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
+ )
1156
1567
  //this.logger.log("that.contacts lenght:: ", strSearch);
1157
- this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch);
1158
- this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedFilter ', this.tagsCannedFilter);
1159
-
1160
- this.tagsCannedFilter.sort(compareValues('title', 'asc'));
1161
- 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
1162
1576
  if (strSearch.length > 0) {
1163
- strReplace = "<b class='highlight-search-string'>" + strSearch + "</b>";
1577
+ strReplace = "<b class='highlight-search-string'>" + strSearch + '</b>'
1164
1578
  }
1165
1579
  for (var i = 0; i < this.tagsCannedFilter.length; i++) {
1166
- const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(this.tagsCannedFilter[i].text) + "</div>";
1167
- 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>'
1168
1592
  }
1169
1593
  if (this.tagsCannedCount === 0) {
1170
- 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
+ }
1171
1603
  this.tagsCannedFilter.push(nocanned)
1172
1604
  }
1173
1605
  }
1174
1606
 
1175
1607
  filterItems(items, searchTerm) {
1176
- 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
+ )
1177
1614
  //this.logger.log("filterItems::: ",searchTerm);
1178
1615
  return items.filter((item) => {
1179
1616
  //this.logger.log("filterItems::: ", item.title.toString().toLowerCase());
1180
- this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item);
1181
- return item.title.toString().toLowerCase().indexOf(searchTerm.toString().toLowerCase()) > -1;
1182
- });
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
+ })
1183
1625
  }
1184
1626
 
1185
1627
  replacePlaceholderInCanned(str) {
1186
- this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str);
1187
- str = str.replace('$recipient_name', this.conversationWithFullname);
1628
+ this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
1629
+ str = str.replace('$recipient_name', this.conversationWithFullname)
1188
1630
  if (this.loggedUser && this.loggedUser.fullname) {
1189
- str = str.replace('$agent_name', this.loggedUser.fullname);
1631
+ str = str.replace('$agent_name', this.loggedUser.fullname)
1190
1632
  }
1191
- return str;
1633
+ return str
1192
1634
  }
1193
1635
 
1194
1636
  replaceTagInMessage(canned, event) {
1195
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage event ", event);
1196
- const elTextArea = this.rowTextArea['el'];
1197
- 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]
1198
1640
 
1199
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage textArea ", textArea);
1200
- 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
+ )
1201
1646
 
1202
1647
  // var lastChar = textArea.value.substr(-1); // Selects the last character
1203
- // if (lastChar === '/') {
1648
+ // if (lastChar === '/') {
1204
1649
  // textArea.value = textArea.value.substring(0, textArea.value.length() - 1);
1205
1650
  // }
1206
1651
  // this.insertAtCursor(this.textArea, textArea.value)
1207
1652
 
1208
-
1209
1653
  this.arrowkeyLocation = -1
1210
- this.tagsCannedFilter = [];
1211
- this.logger.log("[CONVS-DETAIL] replaceTagInMessage canned text ", canned.text);
1212
-
1654
+ this.tagsCannedFilter = []
1655
+ this.logger.log(
1656
+ '[CONVS-DETAIL] replaceTagInMessage canned text ',
1657
+ canned.text,
1658
+ )
1213
1659
 
1214
1660
  // replace text
1215
- var pos = textArea.value.lastIndexOf("/");
1216
- var strSearch = textArea.value.substr(pos);
1217
- 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)
1218
1664
 
1219
- var strTEMP = textArea.value.replace(strSearch, canned.text);
1220
- strTEMP = this.replacePlaceholderInCanned(strTEMP);
1221
- 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)
1222
1668
  // strTEMP = this.replacePlaceholderInCanned(strTEMP);
1223
1669
  // textArea.value = '';
1224
1670
  // that.messageString = strTEMP;
1225
- textArea.value = strTEMP;
1671
+ textArea.value = strTEMP
1226
1672
  setTimeout(() => {
1227
1673
  // textArea.focus();
1228
- textArea.setFocus();
1229
- this.resizeTextArea();
1230
- }, 200);
1674
+ textArea.setFocus()
1675
+ this.resizeTextArea()
1676
+ }, 200)
1231
1677
  }
1232
1678
 
1233
-
1234
1679
  hasClickedOpenCannedResponses($event) {
1235
1680
  this.logger.log('[CONVS-DETAIL] - hasClickedOpenCannedResponses ', $event)
1236
- const elTextArea = this.rowTextArea['el'];
1237
- const textArea = elTextArea.getElementsByTagName('ion-textarea')[0];
1238
-
1239
- this.logger.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea ", textArea);
1240
- this.logger.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea value", textArea.value)
1241
- this.insertAtCursor(textArea, '/');
1681
+ const elTextArea = this.rowTextArea['el']
1682
+ const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1683
+
1684
+ this.logger.log(
1685
+ '[CONVS-DETAIL] hasClickedOpenCannedResponses textArea ',
1686
+ textArea,
1687
+ )
1688
+ // console.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea value", textArea.value)
1689
+ var lastChar = textArea.value[textArea.value.length - 1]
1690
+ // console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses lastChar', lastChar)
1691
+ if (lastChar !== '/') {
1692
+ this.insertAtCursor(textArea, '/')
1693
+ }
1242
1694
  // console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea.value', textArea.value)
1243
1695
  // setTimeout(() => {
1244
1696
  // // if (textArea.value === '/') {
@@ -1252,13 +1704,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1252
1704
 
1253
1705
  setCaretPosition(ctrl) {
1254
1706
  ctrl.value.trim()
1255
- ctrl.setFocus();
1707
+ ctrl.setFocus()
1256
1708
  }
1257
1709
 
1258
1710
  insertAtCursor(myField, myValue) {
1259
- this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue);
1260
- this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField);
1261
-
1711
+ this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue)
1712
+ this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField)
1262
1713
 
1263
1714
  // myValue = ' ' + myValue;
1264
1715
 
@@ -1266,38 +1717,41 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1266
1717
  // console.log('[CONVS-DETAIL] - GET TEXT AREA - Here yes textArea value length', myField.value.length);
1267
1718
 
1268
1719
  if (myField.value.length > 0) {
1269
- myValue = ' ' + myValue;
1720
+ myValue = ' ' + myValue
1270
1721
  }
1271
1722
 
1272
1723
  //IE support
1273
1724
  if (myField.selection) {
1274
- myField.focus();
1275
- let sel = myField.selection.createRange();
1276
- sel.text = myValue;
1725
+ myField.focus()
1726
+ let sel = myField.selection.createRange()
1727
+ sel.text = myValue
1277
1728
  // this.cannedResponseMessage = sel.text;
1278
1729
  }
1279
1730
  //MOZILLA and others
1280
1731
  else if (myField.selectionStart || myField.selectionStart == '0') {
1281
- var startPos = myField.selectionStart;
1282
- this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos);
1732
+ var startPos = myField.selectionStart
1733
+ this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos)
1283
1734
 
1284
- var endPos = myField.selectionEnd;
1285
- this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos);
1735
+ var endPos = myField.selectionEnd
1736
+ this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos)
1286
1737
 
1287
- 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)
1288
1742
 
1289
1743
  // place cursor at end of text in text input element
1290
- myField.focus();
1291
- var val = myField.value; //store the value of the element
1292
- myField.value = ''; //clear the value of the element
1293
- 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.
1294
1748
 
1295
1749
  // this.cannedResponseMessage = myField.value;
1296
1750
 
1297
1751
  // this.texareaIsEmpty = false;
1298
1752
  // myField.select();
1299
1753
  } else {
1300
- myField.value += myValue;
1754
+ myField.value += myValue
1301
1755
  // this.cannedResponseMessage = myField.value;
1302
1756
  }
1303
1757
  }
@@ -1307,30 +1761,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1307
1761
  // this.logger.log("CONVERSATION-DETAIL handleKeyboardEvent event.key ", event.key);
1308
1762
 
1309
1763
  if (this.tagsCannedFilter.length > 0) {
1310
-
1311
1764
  if (event.key === 'ArrowDown') {
1312
-
1313
- this.arrowkeyLocation++;
1765
+ this.arrowkeyLocation++
1314
1766
  if (this.arrowkeyLocation === this.tagsCannedFilter.length) {
1315
1767
  this.arrowkeyLocation--
1316
1768
  }
1317
1769
  // this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
1318
- }
1319
- else if (event.key === 'ArrowUp') {
1320
-
1770
+ } else if (event.key === 'ArrowUp') {
1321
1771
  if (this.arrowkeyLocation > 0) {
1322
- this.arrowkeyLocation--;
1772
+ this.arrowkeyLocation--
1323
1773
  } else if (this.arrowkeyLocation < 0) {
1324
- this.arrowkeyLocation++;
1774
+ this.arrowkeyLocation++
1325
1775
  }
1326
1776
  // this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
1327
1777
  }
1328
1778
 
1329
1779
  if (event.key === 'Enter') {
1330
1780
  const canned_selected = this.tagsCannedFilter[this.arrowkeyLocation]
1331
- this.logger.log('[CONVS-DETAIL] replaceTagInMessage canned_selected ', canned_selected)
1781
+ this.logger.log(
1782
+ '[CONVS-DETAIL] replaceTagInMessage canned_selected ',
1783
+ canned_selected,
1784
+ )
1332
1785
  if (canned_selected) {
1333
-
1334
1786
  this.replaceTagInMessage(canned_selected, 'enter')
1335
1787
  // event.preventDefault();
1336
1788
  // return false;
@@ -1342,35 +1794,40 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1342
1794
  // ./end CANNED RESPONSES methods
1343
1795
  // ----------------------------------------------------------
1344
1796
 
1345
-
1346
-
1347
1797
  // ----------------------------------------------------------
1348
- // @ Rule of sound message
1798
+ // @ Rule of sound message
1349
1799
  // * if I send it -> NO SOUND
1350
1800
  // * if I'm not in the conversation -> SOUND
1351
1801
  // * if I'm in the conversation at the bottom of the page -> NO SOUND
1352
1802
  // * otherwise -> SOUND
1353
1803
  // ----------------------------------------------------------
1354
1804
  soundMessage() {
1355
- const that = this;
1356
- this.audio = new Audio();
1805
+ const that = this
1806
+ this.audio = new Audio()
1357
1807
  // this.audio.src = '/assets/sounds/pling.mp3';
1358
- this.audio.src = URL_SOUND_LIST_CONVERSATION;
1359
- this.audio.load();
1360
- this.logger.log('[CONVS-DETAIL] soundMessage conversation this.audio', this.audio);
1361
- 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)
1362
1815
  this.setTimeoutSound = setTimeout(function () {
1363
- that.audio.play().then(() => {
1364
- // Audio is playing.
1365
- this.logger.log('[CONVS-DETAIL] soundMessag that.audio.src ', that.audio.src);
1366
- }).catch(error => {
1367
- that.logger.error(error);
1368
- });
1369
- }, 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)
1370
1829
  }
1371
1830
 
1372
-
1373
-
1374
1831
  returnOnBeforeMessageRender(event) {
1375
1832
  //this.onBeforeMessageRender.emit(event)
1376
1833
  }
@@ -1383,86 +1840,83 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1383
1840
  // this.isMenuShow = event;
1384
1841
  }
1385
1842
 
1386
- returnOnScrollContent(event: boolean) {
1387
-
1388
- }
1843
+ returnOnScrollContent(event: boolean) {}
1389
1844
 
1390
1845
  returnOnAttachmentButtonClicked(event: any) {
1391
1846
  this.logger.debug('[CONV-COMP] eventbutton', event)
1392
1847
  if (!event || !event.target.type) {
1393
- return;
1848
+ return
1394
1849
  }
1395
1850
  switch (event.target.type) {
1396
1851
  case 'url':
1397
1852
  try {
1398
- this.openLink(event.target.button);
1853
+ this.openLink(event.target.button)
1399
1854
  } catch (err) {
1400
- this.logger.error('[CONV-COMP] url > Error :' + err);
1855
+ this.logger.error('[CONV-COMP] url > Error :' + err)
1401
1856
  }
1402
- return;
1857
+ return
1403
1858
  case 'action':
1404
1859
  try {
1405
- this.actionButton(event.target.button);
1860
+ this.actionButton(event.target.button)
1406
1861
  } catch (err) {
1407
- this.logger.error('[CONV-COMP] action > Error :' + err);
1862
+ this.logger.error('[CONV-COMP] action > Error :' + err)
1408
1863
  }
1409
- return false;
1864
+ return false
1410
1865
  case 'text':
1411
1866
  try {
1412
1867
  const text = event.target.button.value
1413
- const metadata = { 'button': true };
1414
- this.sendMessage(text, TYPE_MSG_TEXT, metadata);
1868
+ const metadata = { button: true }
1869
+ this.sendMessage(text, TYPE_MSG_TEXT, metadata)
1415
1870
  } catch (err) {
1416
- this.logger.error('[CONV-COMP] text > Error :' + err);
1871
+ this.logger.error('[CONV-COMP] text > Error :' + err)
1417
1872
  }
1418
- default: return;
1873
+ default:
1874
+ return
1419
1875
  }
1420
1876
  }
1421
1877
 
1422
1878
  onImageRenderedFN(event) {
1423
- const imageRendered = event;
1879
+ const imageRendered = event
1424
1880
  if (this.showButtonToBottom) {
1425
1881
  this.scrollBottom(0)
1426
1882
  }
1427
1883
  }
1428
1884
 
1429
-
1430
1885
  private openLink(event: any) {
1431
- const link = event.link ? event.link : '';
1432
- const target = event.target ? event.target : '';
1886
+ const link = event.link ? event.link : ''
1887
+ const target = event.target ? event.target : ''
1433
1888
  if (target === 'self' || target === 'parent') {
1434
- window.open(link, '_parent');
1889
+ window.open(link, '_parent')
1435
1890
  } else {
1436
- window.open(link, '_blank');
1891
+ window.open(link, '_blank')
1437
1892
  }
1438
1893
  }
1439
1894
 
1440
-
1441
1895
  private actionButton(event: any) {
1442
1896
  // console.log(event);
1443
- const action = event.action ? event.action : '';
1444
- const message = event.value ? event.value : '';
1445
- 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'
1446
1900
 
1447
1901
  const attributes = {
1448
1902
  action: action,
1449
- subtype: subtype
1450
- };
1451
- this.sendMessage(message, TYPE_MSG_TEXT, null, attributes);
1452
- 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 :')
1453
1907
  }
1454
1908
 
1455
1909
  addUploadingBubbleEvent(event: boolean) {
1456
- this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event);
1910
+ this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event)
1457
1911
  if (event === true) {
1458
- this.scrollBottom(0);
1912
+ this.scrollBottom(0)
1459
1913
  }
1460
1914
  }
1461
1915
 
1462
1916
  onPresentModalScrollToBottom(event: boolean) {
1463
- this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event);
1917
+ this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event)
1464
1918
  if (event === true) {
1465
- this.scrollBottom(0);
1919
+ this.scrollBottom(0)
1466
1920
  }
1467
1921
  }
1468
1922
 
@@ -1470,25 +1924,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1470
1924
  /** */
1471
1925
  resizeTextArea() {
1472
1926
  try {
1473
- const elTextArea = this.rowTextArea['el'];
1474
- const that = this;
1927
+ const elTextArea = this.rowTextArea['el']
1928
+ const that = this
1475
1929
  setTimeout(() => {
1476
- const textArea = elTextArea.getElementsByTagName('ion-textarea')[0];
1930
+ const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1477
1931
  if (textArea) {
1478
- this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea);
1479
- const txtValue = textArea.value;
1480
- textArea.value = ' ';
1481
- textArea.value = txtValue;
1932
+ this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea)
1933
+ const txtValue = textArea.value
1934
+ textArea.value = ' '
1935
+ textArea.value = txtValue
1482
1936
  }
1483
- }, 0);
1937
+ }, 0)
1484
1938
  setTimeout(() => {
1485
1939
  if (elTextArea) {
1486
- this.logger.log('[CONVS-DETAIL] resizeTextArea elTextArea.offsetHeight ', elTextArea.offsetHeight);
1487
- that.heightMessageTextArea = elTextArea.offsetHeight;
1940
+ this.logger.log(
1941
+ '[CONVS-DETAIL] resizeTextArea elTextArea.offsetHeight ',
1942
+ elTextArea.offsetHeight,
1943
+ )
1944
+ that.heightMessageTextArea = elTextArea.offsetHeight
1488
1945
  }
1489
- }, 100);
1946
+ }, 100)
1490
1947
  } catch (err) {
1491
- this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err);
1948
+ this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err)
1492
1949
  }
1493
1950
  }
1494
1951
 
@@ -1497,11 +1954,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1497
1954
  * @param time
1498
1955
  */
1499
1956
  private scrollBottom(time: number) {
1500
- this.showIonContent = true;
1957
+ this.showIonContent = true
1501
1958
  if (this.ionContentChatArea) {
1502
1959
  setTimeout(() => {
1503
- this.ionContentChatArea.scrollToBottom(time);
1504
- }, 0);
1960
+ this.ionContentChatArea.scrollToBottom(time)
1961
+ }, 0)
1505
1962
  // nota: se elimino il settimeout lo scrollToBottom non viene richiamato!!!!!
1506
1963
  }
1507
1964
  }
@@ -1510,14 +1967,17 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1510
1967
  * detectBottom
1511
1968
  */
1512
1969
  async detectBottom() {
1513
- const scrollElement = await this.ionContentChatArea.getScrollElement();
1970
+ const scrollElement = await this.ionContentChatArea.getScrollElement()
1514
1971
 
1515
- if (scrollElement.scrollTop < scrollElement.scrollHeight - scrollElement.clientHeight) {
1972
+ if (
1973
+ scrollElement.scrollTop <
1974
+ scrollElement.scrollHeight - scrollElement.clientHeight
1975
+ ) {
1516
1976
  //NON SONO ALLA FINE --> mostra badge
1517
- this.showButtonToBottom = true;
1977
+ this.showButtonToBottom = true
1518
1978
  } else {
1519
1979
  // SONO ALLA FINE --> non mostrare badge,
1520
- this.showButtonToBottom = false;
1980
+ this.showButtonToBottom = false
1521
1981
  }
1522
1982
  }
1523
1983
 
@@ -1526,149 +1986,203 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1526
1986
  * FIREBY BY: click event ScrollToBottom bottom-right icon button
1527
1987
  */
1528
1988
  public actionScrollBottom() {
1529
- this.logger.log('[CONVS-DETAIL] actionScrollBottom - ionContentChatArea: ', this.ionContentChatArea);
1989
+ this.logger.log(
1990
+ '[CONVS-DETAIL] actionScrollBottom - ionContentChatArea: ',
1991
+ this.ionContentChatArea,
1992
+ )
1530
1993
  // const that = this;
1531
- this.showButtonToBottom = false;
1994
+ this.showButtonToBottom = false
1532
1995
  this.updateConversationBadge()
1533
- this.NUM_BADGES = 0;
1996
+ this.NUM_BADGES = 0
1534
1997
  setTimeout(() => {
1535
- this.ionContentChatArea.scrollToBottom(0);
1998
+ this.ionContentChatArea.scrollToBottom(0)
1536
1999
  // this.conversationsHandlerService.readAllMessages.next(this.conversationWith);
1537
- }, 0);
2000
+ }, 0)
1538
2001
  }
1539
2002
 
1540
2003
  /**
1541
2004
  * Scroll to top of the page after a short delay.
1542
2005
  */
1543
2006
  scrollTop() {
1544
- this.logger.log('[CONVS-DETAIL] scrollTop');
1545
- this.ionContentChatArea.scrollToTop(100);
2007
+ this.logger.log('[CONVS-DETAIL] scrollTop')
2008
+ this.ionContentChatArea.scrollToTop(100)
1546
2009
  }
1547
2010
 
1548
2011
  /** */
1549
2012
  setHeightTextArea() {
1550
2013
  try {
1551
2014
  if (this.rowTextArea) {
1552
- this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight;
1553
- 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
+ )
1554
2020
  }
1555
2021
  } catch (e) {
1556
2022
  this.logger.error('[CONVS-DETAIL] setHeightTextArea - ERROR ', e)
1557
2023
  // this.heightMessageTextArea = '50';
1558
- this.heightMessageTextArea = '57'; // NK edited
2024
+ this.heightMessageTextArea = '57' // NK edited
1559
2025
  }
1560
2026
  }
1561
2027
  checkAcceptedFile(draggedFileMimeType) {
1562
- let isAcceptFile = false;
1563
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept: ', this.appConfigProvider.getConfig().fileUploadAccept);
1564
- const accept_files = this.appConfigProvider.getConfig().fileUploadAccept;
1565
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - mimeType: ', draggedFileMimeType);
1566
- if (accept_files === "*/*") {
1567
- 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
1568
2040
  return isAcceptFile
1569
- } else if (accept_files !== "*/*") {
1570
- 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
+ )
1571
2046
  const accept_files_array = accept_files.split(',')
1572
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array ', accept_files_array);
1573
- this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array typeof: ', typeof accept_files_array);
1574
-
1575
- accept_files_array.forEach(accept_file => {
1576
-
1577
- 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
+ )
1578
2061
  const accept_file_segment = accept_file.split('/')
1579
- 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
+ )
1580
2066
  if (accept_file_segment[1] === '*') {
1581
2067
  if (draggedFileMimeType.startsWith(accept_file_segment[0])) {
1582
- isAcceptFile = true;
1583
- 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
+ )
1584
2073
  return isAcceptFile
1585
-
1586
2074
  } else {
1587
- isAcceptFile = false;
1588
- 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
+ )
1589
2080
  return isAcceptFile
1590
-
1591
2081
  }
1592
2082
  } else if (accept_file_segment[1] !== '*') {
1593
2083
  if (draggedFileMimeType === accept_file) {
1594
- isAcceptFile = true;
1595
- 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
+ )
1596
2089
  return isAcceptFile
1597
2090
  }
1598
2091
  }
1599
2092
  return isAcceptFile
1600
- });
2093
+ })
1601
2094
  return isAcceptFile
1602
2095
  }
1603
2096
  }
1604
2097
  // -------------------------------------------------------------
1605
- // DRAG FILE
2098
+ // DRAG FILE
1606
2099
  // -------------------------------------------------------------
1607
2100
  // DROP (WHEN THE FILE IS RELEASED ON THE DROP ZONE)
1608
2101
  drop(ev: any) {
1609
- ev.preventDefault();
1610
- ev.stopPropagation();
1611
-
1612
- this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev ', ev);
1613
- const fileList = ev.dataTransfer.files;
1614
- this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev.dataTransfer.files ', fileList);
1615
- this.isHovering = false;
1616
- 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
+ )
1617
2116
  if (fileList.length > 0) {
1618
- const file: File = fileList[0];
1619
- 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)
1620
2119
 
1621
- var mimeType = fileList[0].type;
1622
- 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
+ )
1623
2125
 
1624
2126
  // if (mimeType.startsWith("image") || mimeType.startsWith("application")) {
1625
2127
  // this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files: ', this.appConfigProvider.getConfig().fileUploadAccept);
1626
2128
  // this.checkAcceptedFile(mimeType);
1627
- const isAccepted = this.checkAcceptedFile(mimeType);
1628
- 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
+ )
1629
2134
  if (isAccepted === true) {
1630
- this.handleDropEvent(ev);
1631
-
2135
+ this.handleDropEvent(ev)
1632
2136
  } else {
1633
- 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
+ )
1634
2142
  this.presentToastOnlyImageFilesAreAllowedToDrag()
1635
2143
  }
1636
2144
  }
1637
2145
  }
1638
2146
 
1639
2147
  handleDropEvent(ev) {
1640
- this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev);
2148
+ this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev)
1641
2149
  this.dropEvent = ev
1642
2150
  }
1643
2151
 
1644
2152
  // DRAG OVER (WHEN HOVER OVER ON THE "DROP ZONE")
1645
2153
  allowDrop(ev: any) {
1646
- ev.preventDefault();
1647
- ev.stopPropagation();
1648
- this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop ev ', ev);
1649
- this.isHovering = true;
1650
- 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
+ )
1651
2162
  }
1652
2163
 
1653
2164
  // DRAG LEAVE (WHEN LEAVE FROM THE DROP ZONE)
1654
2165
  drag(ev: any) {
1655
- ev.preventDefault();
1656
- ev.stopPropagation();
1657
- this.logger.log('[CONVS-DETAIL] ----> FILE - (dragleave) drag ev ', ev);
1658
- this.isHovering = false;
1659
- 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
+ )
1660
2174
  }
1661
2175
 
1662
2176
  async presentToastOnlyImageFilesAreAllowedToDrag() {
1663
2177
  const toast = await this.toastController.create({
1664
- 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
+ ),
1665
2181
  duration: 5000,
1666
- color: "danger",
2182
+ color: 'danger',
1667
2183
  cssClass: 'toast-custom-class',
1668
- });
1669
- toast.present();
2184
+ })
2185
+ toast.present()
1670
2186
  }
1671
-
1672
-
1673
2187
  }
1674
- // END ALL //
2188
+ // END ALL //