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

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