@chat21/chat21-ionic 3.0.60-rc8 → 3.0.61-rc11

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