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