@chat21/chat21-ionic 3.0.5-9.2 → 3.0.6-2.3

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 (178) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/LICENSE +661 -21
  3. package/README.md +13 -1
  4. package/angular.json +4 -0
  5. package/config.xml +4 -5
  6. package/deploy_pre.sh +44 -5
  7. package/deploy_prod.sh +36 -7
  8. package/env.sample +4 -2
  9. package/package.json +12 -8
  10. package/resources/{Android → android}/icon/drawable-hdpi-icon.png +0 -0
  11. package/resources/{Android → android}/icon/drawable-ldpi-icon.png +0 -0
  12. package/resources/{Android → android}/icon/drawable-mdpi-icon.png +0 -0
  13. package/resources/{Android → android}/icon/drawable-xhdpi-icon.png +0 -0
  14. package/resources/{Android → android}/icon/drawable-xxhdpi-icon.png +0 -0
  15. package/resources/{Android → android}/icon/drawable-xxxhdpi-icon.png +0 -0
  16. package/resources/{Android → android}/icon.png +0 -0
  17. package/resources/{Android → android}/splash/drawable-land-hdpi-screen.png +0 -0
  18. package/resources/{Android → android}/splash/drawable-land-ldpi-screen.png +0 -0
  19. package/resources/{Android → android}/splash/drawable-land-mdpi-screen.png +0 -0
  20. package/resources/{Android → android}/splash/drawable-land-xhdpi-screen.png +0 -0
  21. package/resources/{Android → android}/splash/drawable-land-xxhdpi-screen.png +0 -0
  22. package/resources/{Android → android}/splash/drawable-land-xxxhdpi-screen.png +0 -0
  23. package/resources/{Android → android}/splash/drawable-port-hdpi-screen.png +0 -0
  24. package/resources/{Android → android}/splash/drawable-port-ldpi-screen.png +0 -0
  25. package/resources/{Android → android}/splash/drawable-port-mdpi-screen.png +0 -0
  26. package/resources/{Android → android}/splash/drawable-port-xhdpi-screen.png +0 -0
  27. package/resources/{Android → android}/splash/drawable-port-xxhdpi-screen.png +0 -0
  28. package/resources/{Android → android}/splash/drawable-port-xxxhdpi-screen.png +0 -0
  29. package/resources/{Android → android}/splash.png +0 -0
  30. package/src/app/app-routing.module.ts +15 -0
  31. package/src/app/app.component.html +14 -4
  32. package/src/app/app.component.scss +18 -1
  33. package/src/app/app.component.ts +98 -37
  34. package/src/app/app.module.ts +14 -5
  35. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +36 -25
  36. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +160 -50
  37. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +108 -18
  38. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +21 -36
  39. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +19 -7
  40. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +63 -42
  41. package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.scss +1 -1
  42. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +7 -2
  43. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +141 -21
  44. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.ts +13 -10
  45. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +39 -36
  46. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +7 -1
  47. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +148 -63
  48. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +101 -39
  49. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +73 -2
  50. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +168 -98
  51. package/src/app/components/ddp-header/ddp-header.component.html +20 -6
  52. package/src/app/components/ddp-header/ddp-header.component.scss +4 -0
  53. package/src/app/components/ddp-header/ddp-header.component.ts +104 -10
  54. package/src/app/components/image-viewer/image-viewer.component.scss +2 -2
  55. package/src/app/components/project-item/project-item.component.html +141 -118
  56. package/src/app/components/project-item/project-item.component.scss +173 -91
  57. package/src/app/components/project-item/project-item.component.ts +59 -25
  58. package/src/app/components/sidebar/sidebar.component.html +275 -0
  59. package/src/app/components/sidebar/sidebar.component.scss +79 -0
  60. package/src/app/components/sidebar/sidebar.component.spec.ts +24 -0
  61. package/src/app/components/sidebar/sidebar.component.ts +541 -0
  62. package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +137 -0
  63. package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +389 -0
  64. package/src/app/components/sidebar-user-details/sidebar-user-details.component.spec.ts +24 -0
  65. package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +530 -0
  66. package/src/app/pages/conversation-detail/conversation-detail.module.ts +9 -2
  67. package/src/app/pages/conversation-detail/conversation-detail.page.html +53 -49
  68. package/src/app/pages/conversation-detail/conversation-detail.page.scss +28 -0
  69. package/src/app/pages/conversation-detail/conversation-detail.page.ts +1254 -753
  70. package/src/app/pages/conversations-list/conversations-list.module.ts +2 -1
  71. package/src/app/pages/conversations-list/conversations-list.page.html +24 -11
  72. package/src/app/pages/conversations-list/conversations-list.page.scss +20 -1
  73. package/src/app/pages/conversations-list/conversations-list.page.ts +687 -420
  74. package/src/app/pages/create-canned-response/create-canned-response-routing.module.ts +17 -0
  75. package/src/app/pages/create-canned-response/create-canned-response.module.ts +30 -0
  76. package/src/app/pages/create-canned-response/create-canned-response.page.html +150 -0
  77. package/src/app/pages/create-canned-response/create-canned-response.page.scss +55 -0
  78. package/src/app/pages/create-canned-response/create-canned-response.page.spec.ts +24 -0
  79. package/src/app/pages/create-canned-response/create-canned-response.page.ts +319 -0
  80. package/src/app/pages/create-requester/create-requester-routing.module.ts +17 -0
  81. package/src/app/pages/create-requester/create-requester.module.ts +28 -0
  82. package/src/app/pages/create-requester/create-requester.page.html +67 -0
  83. package/src/app/pages/create-requester/create-requester.page.scss +30 -0
  84. package/src/app/pages/create-requester/create-requester.page.spec.ts +24 -0
  85. package/src/app/pages/create-requester/create-requester.page.ts +138 -0
  86. package/src/app/pages/create-ticket/create-ticket-routing.module.ts +17 -0
  87. package/src/app/pages/create-ticket/create-ticket.module.ts +28 -0
  88. package/src/app/pages/create-ticket/create-ticket.page.html +171 -0
  89. package/src/app/pages/create-ticket/create-ticket.page.scss +52 -0
  90. package/src/app/pages/create-ticket/create-ticket.page.spec.ts +24 -0
  91. package/src/app/pages/create-ticket/create-ticket.page.ts +432 -0
  92. package/src/app/pages/loader-preview/loader-preview.page.ts +226 -166
  93. package/src/app/pages/profile-info/profile-info.page.html +4 -4
  94. package/src/app/pages/profile-info/profile-info.page.scss +13 -2
  95. package/src/app/pages/profile-info/profile-info.page.ts +23 -21
  96. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +16 -11
  97. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +157 -63
  98. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +51 -16
  99. package/src/app/services/app-config.ts +14 -14
  100. package/src/app/services/tiledesk/tiledesk.service.ts +209 -0
  101. package/src/app/shared/shared.module.ts +21 -7
  102. package/src/app/utils/scrollbar-theme.directive.ts +58 -24
  103. package/src/assets/i18n/de.json +266 -0
  104. package/src/assets/i18n/en.json +85 -10
  105. package/src/assets/i18n/es.json +266 -0
  106. package/src/assets/i18n/fr.json +266 -0
  107. package/src/assets/i18n/it.json +104 -37
  108. package/src/assets/i18n/pt.json +266 -0
  109. package/src/assets/i18n/ru.json +266 -0
  110. package/src/assets/i18n/sr.json +266 -0
  111. package/src/assets/i18n/tr.json +266 -0
  112. package/src/assets/images/default-avatar-x-select.png +0 -0
  113. package/src/assets/images/language_flag/ar.png +0 -0
  114. package/src/assets/images/language_flag/bg.png +0 -0
  115. package/src/assets/images/language_flag/ca.png +0 -0
  116. package/src/assets/images/language_flag/cs.png +0 -0
  117. package/src/assets/images/language_flag/da.png +0 -0
  118. package/src/assets/images/language_flag/de.png +0 -0
  119. package/src/assets/images/language_flag/el.png +0 -0
  120. package/src/assets/images/language_flag/en.png +0 -0
  121. package/src/assets/images/language_flag/es.png +0 -0
  122. package/src/assets/images/language_flag/fa.png +0 -0
  123. package/src/assets/images/language_flag/fi.png +0 -0
  124. package/src/assets/images/language_flag/fr.png +0 -0
  125. package/src/assets/images/language_flag/he.png +0 -0
  126. package/src/assets/images/language_flag/hi.png +0 -0
  127. package/src/assets/images/language_flag/hr.png +0 -0
  128. package/src/assets/images/language_flag/hu.png +0 -0
  129. package/src/assets/images/language_flag/id.png +0 -0
  130. package/src/assets/images/language_flag/it.png +0 -0
  131. package/src/assets/images/language_flag/ja.png +0 -0
  132. package/src/assets/images/language_flag/ko.png +0 -0
  133. package/src/assets/images/language_flag/ml-IN.png +0 -0
  134. package/src/assets/images/language_flag/ne-NP.png +0 -0
  135. package/src/assets/images/language_flag/nl.png +0 -0
  136. package/src/assets/images/language_flag/no.png +0 -0
  137. package/src/assets/images/language_flag/pl.png +0 -0
  138. package/src/assets/images/language_flag/pt-BR.png +0 -0
  139. package/src/assets/images/language_flag/pt.png +0 -0
  140. package/src/assets/images/language_flag/ro.png +0 -0
  141. package/src/assets/images/language_flag/ru.png +0 -0
  142. package/src/assets/images/language_flag/sk.png +0 -0
  143. package/src/assets/images/language_flag/sl.png +0 -0
  144. package/src/assets/images/language_flag/sr.png +0 -0
  145. package/src/assets/images/language_flag/sv-SE.png +0 -0
  146. package/src/assets/images/language_flag/ta.png +0 -0
  147. package/src/assets/images/language_flag/th.png +0 -0
  148. package/src/assets/images/language_flag/tr.png +0 -0
  149. package/src/assets/images/language_flag/uk.png +0 -0
  150. package/src/assets/images/language_flag/vi.png +0 -0
  151. package/src/assets/images/language_flag/zh-CN.png +0 -0
  152. package/src/assets/images/language_flag/zh-TW.png +0 -0
  153. package/src/assets/images/no_image_user.png +0 -0
  154. package/src/assets/images/priority_icons/high.svg +3 -0
  155. package/src/assets/images/priority_icons/high_v2.svg +14 -0
  156. package/src/assets/images/priority_icons/low.svg +10 -0
  157. package/src/assets/images/priority_icons/low_v2.svg +14 -0
  158. package/src/assets/images/priority_icons/medium.svg +16 -0
  159. package/src/assets/images/priority_icons/medium_v2.svg +11 -0
  160. package/src/assets/images/priority_icons/urgent.svg +4 -0
  161. package/src/assets/images/priority_icons/urgent_v2.svg +16 -0
  162. package/src/assets/js/chat21client.js +16 -3
  163. package/src/assets/tiledesk-solo-logo.png +0 -0
  164. package/src/chat-config-mqtt.json +27 -17
  165. package/src/chat-config-pre-test.json +5 -1
  166. package/src/chat-config-pre.json +15 -3
  167. package/src/chat-config-template.json +6 -2
  168. package/src/chat-config.json +5 -1
  169. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +61 -45
  170. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +23 -0
  171. package/src/chat21-core/providers/mqtt/mqtt-archivedconversations-handler.ts +1 -1
  172. package/src/chat21-core/utils/constants.ts +8 -1
  173. package/src/chat21-core/utils/utils-message.ts +19 -0
  174. package/src/chat21-core/utils/utils.ts +12 -1
  175. package/src/global.scss +408 -2
  176. package/src/index.html +7 -0
  177. package/publish_pre.sh +0 -33
  178. package/publish_prod.sh +0 -33
@@ -1,41 +1,48 @@
1
- import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service';
2
- import { Component, OnInit, ViewChild } from '@angular/core';
3
- import { IonContent, ModalController } from '@ionic/angular';
4
- import { ActivatedRoute, Router, NavigationExtras } from '@angular/router';
1
+ import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service'
2
+ import { Component, OnInit, ViewChild } from '@angular/core'
3
+ import { IonContent, ModalController } from '@ionic/angular'
4
+ import { ActivatedRoute, Router, NavigationExtras } from '@angular/router'
5
5
  // config
6
- import { environment } from '../../../environments/environment';
6
+ import { environment } from '../../../environments/environment'
7
7
 
8
8
  // models
9
- import { ConversationModel } from 'src/chat21-core/models/conversation';
10
- import { UserModel } from 'src/chat21-core/models/user';
9
+ import { ConversationModel } from 'src/chat21-core/models/conversation'
10
+ import { UserModel } from 'src/chat21-core/models/user'
11
11
 
12
12
  // utils
13
- import { isInArray, checkPlatformIsMobile, presentModal, closeModal, convertMessage, isGroup, } from '../../../chat21-core/utils/utils';
14
-
15
- import { EventsService } from '../../services/events-service';
16
- import PerfectScrollbar from 'perfect-scrollbar'; // https://github.com/mdbootstrap/perfect-scrollbar
13
+ import {
14
+ isInArray,
15
+ checkPlatformIsMobile,
16
+ presentModal,
17
+ closeModal,
18
+ convertMessage,
19
+ isGroup,
20
+ } from '../../../chat21-core/utils/utils'
21
+
22
+ import { EventsService } from '../../services/events-service'
23
+ import PerfectScrollbar from 'perfect-scrollbar' // https://github.com/mdbootstrap/perfect-scrollbar
17
24
 
18
25
  // services
19
- import { ConversationsHandlerService } from 'src/chat21-core/providers/abstract/conversations-handler.service';
20
- import { ChatManager } from 'src/chat21-core/providers/chat-manager';
21
- import { NavProxyService } from '../../services/nav-proxy.service';
22
- import { TiledeskService } from '../../services/tiledesk/tiledesk.service';
23
- import { ConversationDetailPage } from '../conversation-detail/conversation-detail.page';
24
- import { ContactsDirectoryPage } from '../contacts-directory/contacts-directory.page';
25
- import { UnassignedConversationsPage } from '../unassigned-conversations/unassigned-conversations.page';
26
- import { ProfileInfoPage } from '../profile-info/profile-info.page';
27
- import { MessagingAuthService } from 'src/chat21-core/providers/abstract/messagingAuth.service';
28
- import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
29
- import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service';
30
- import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
31
- import { AppConfigProvider } from '../../services/app-config';
32
- import { Subscription } from 'rxjs';
33
- import { Platform } from '@ionic/angular';
26
+ import { ConversationsHandlerService } from 'src/chat21-core/providers/abstract/conversations-handler.service'
27
+ import { ChatManager } from 'src/chat21-core/providers/chat-manager'
28
+ import { NavProxyService } from '../../services/nav-proxy.service'
29
+ import { TiledeskService } from '../../services/tiledesk/tiledesk.service'
30
+ import { ConversationDetailPage } from '../conversation-detail/conversation-detail.page'
31
+ import { ContactsDirectoryPage } from '../contacts-directory/contacts-directory.page'
32
+ import { UnassignedConversationsPage } from '../unassigned-conversations/unassigned-conversations.page'
33
+ import { ProfileInfoPage } from '../profile-info/profile-info.page'
34
+ import { MessagingAuthService } from 'src/chat21-core/providers/abstract/messagingAuth.service'
35
+ import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service'
36
+ import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service'
37
+ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service'
38
+ import { AppConfigProvider } from '../../services/app-config'
39
+ import { Subscription } from 'rxjs'
40
+ import { Platform } from '@ionic/angular'
34
41
  // Logger
35
- import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
36
- import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
37
- import { NetworkService } from 'src/app/services/network-service/network.service';
38
- import { Subject } from 'rxjs';
42
+ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'
43
+ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
44
+ import { NetworkService } from 'src/app/services/network-service/network.service'
45
+ import { Subject } from 'rxjs'
39
46
  import { takeUntil } from 'rxjs/operators'
40
47
 
41
48
  @Component({
@@ -44,42 +51,54 @@ import { takeUntil } from 'rxjs/operators'
44
51
  styleUrls: ['./conversations-list.page.scss'],
45
52
  })
46
53
  export class ConversationListPage implements OnInit {
47
-
48
- @ViewChild('ioncontentconvlist', { static: false }) ionContentConvList: IonContent;
49
-
50
- private unsubscribe$: Subject<any> = new Subject<any>();
51
- private subscriptions: Array<string>;
52
- public tenant: string;
53
- public loggedUserUid: string;
54
- public conversations: Array<ConversationModel> = [];
55
- public archivedConversations: Array<ConversationModel> = [];
56
- public uidConvSelected: string;
57
- public conversationSelected: ConversationModel;
58
- public uidReciverFromUrl: string;
59
- public showPlaceholder = true;
60
- public numberOpenConv = 0;
61
- public loadingIsActive = true;
62
- public supportMode: boolean;
63
-
64
- public convertMessage = convertMessage;
65
- private isShowMenuPage = false;
66
- private logger: LoggerService = LoggerInstance.getInstance();
67
- translationMapConversation: Map<string, string>;
68
- stylesMap: Map<string, string>;
54
+ @ViewChild('ioncontentconvlist', { static: false })
55
+ ionContentConvList: IonContent
56
+
57
+ private unsubscribe$: Subject<any> = new Subject<any>()
58
+ private subscriptions: Array<string>
59
+ public tenant: string
60
+ public loggedUserUid: string
61
+ public conversations: Array<ConversationModel> = []
62
+ public archivedConversations: Array<ConversationModel> = []
63
+ public uidConvSelected: string
64
+ public conversationSelected: ConversationModel
65
+ public uidReciverFromUrl: string
66
+ public showPlaceholder = true
67
+ public numberOpenConv = 0
68
+ public loadingIsActive = true
69
+ public supportMode: boolean
70
+ public writeto_btn: boolean
71
+ public archived_btn: boolean
72
+ public convertMessage = convertMessage
73
+ private isShowMenuPage = false
74
+ private logger: LoggerService = LoggerInstance.getInstance()
75
+ translationMapConversation: Map<string, string>
76
+ stylesMap: Map<string, string>
69
77
 
70
78
  public conversationType = 'active'
71
- headerTitle: string;
72
- subscription: Subscription;
79
+ headerTitle: string
80
+ subscription: Subscription
73
81
 
74
- public UNASSIGNED_CONVS_URL: any;
75
- public hasClickedOpenUnservedConvIframe: boolean = false;
76
- public lastProjectId: string;
77
- public isOnline: boolean = true;
78
- public checkInternet: boolean;
82
+ public UNASSIGNED_CONVS_URL: any
83
+ public PROJECTS_FOR_PANEL_URL: any
84
+ public IFRAME_URL: any
85
+ public hasClickedOpenUnservedConvIframe: boolean = false
86
+ public lastProjectId: string
87
+ public isOnline: boolean = true
88
+ public checkInternet: boolean
79
89
 
80
90
  public displayNewConvsItem: boolean = true
81
-
82
-
91
+ public archiveActionNotAllowed: boolean = false
92
+
93
+ tooltipOptions = {
94
+ 'show-delay': 1500,
95
+ 'tooltip-class': 'chat-tooltip',
96
+ theme: 'light',
97
+ shadow: false,
98
+ 'hide-delay-mobile': 0,
99
+ hideDelayAfterClick: 3000,
100
+ 'hide-delay': 200,
101
+ }
83
102
 
84
103
  constructor(
85
104
  private router: Router,
@@ -99,39 +118,50 @@ export class ConversationListPage implements OnInit {
99
118
  public appConfigProvider: AppConfigProvider,
100
119
  public platform: Platform,
101
120
  private networkService: NetworkService,
102
-
103
121
  ) {
104
- this.listenToAppCompConvsLengthOnInitConvs();
105
- this.listenToLogoutEvent();
106
- this.listenGoOnline();
107
- this.listenGoOffline();
108
- this.listenToSwPostMessage();
109
- this.listenSupportConvIdHasChanged();
122
+ this.listenToAppCompConvsLengthOnInitConvs()
123
+ this.listenToLogoutEvent()
124
+ this.listenGoOnline()
125
+ this.listenGoOffline()
126
+ this.listenToSwPostMessage()
127
+ this.listenSupportConvIdHasChanged()
110
128
  // this.listenDirectConvIdHasChanged();
129
+ this.listenToCloseConvFromHeaderConversation()
111
130
  }
112
131
 
113
132
  listenSupportConvIdHasChanged() {
114
133
  this.events.subscribe('supportconvid:haschanged', (IDConv) => {
115
- this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - convId', IDConv);
134
+ // console.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - convId', IDConv);
116
135
  if (IDConv) {
117
136
  // const conversationSelected = this.conversations.find(item => item.uid === convId);
118
137
  // this.onConversationSelected(conversationSelected)
119
- this.setUidConvSelected(IDConv, 'active');
138
+ this.setUidConvSelected(IDConv, 'active')
120
139
  }
121
140
  if (!IDConv) {
122
- this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - is the page without conv select');
141
+ this.logger.log(
142
+ '[CONVS-LIST-PAGE] - listen To convid:haschanged - is the page without conv select',
143
+ )
123
144
 
124
145
  const chatTabCount = +localStorage.getItem('tabCount')
125
- this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - chatTabCount ', chatTabCount);
146
+ this.logger.log(
147
+ '[CONVS-LIST-PAGE] - listen To convid:haschanged - chatTabCount ',
148
+ chatTabCount,
149
+ )
126
150
  if (chatTabCount && chatTabCount > 0) {
127
- this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - the chat is already open ', chatTabCount);
151
+ this.logger.log(
152
+ '[CONVS-LIST-PAGE] - listen To convid:haschanged - the chat is already open ',
153
+ chatTabCount,
154
+ )
128
155
  if (checkPlatformIsMobile()) {
129
- this.logger.log('[CONVS-LIST-PAGE] - the chat is in mobile mode ', checkPlatformIsMobile());
130
- this.events.publish('noparams:mobile', true);
156
+ this.logger.log(
157
+ '[CONVS-LIST-PAGE] - the chat is in mobile mode ',
158
+ checkPlatformIsMobile(),
159
+ )
160
+ this.events.publish('noparams:mobile', true)
131
161
  }
132
162
  }
133
163
  }
134
- });
164
+ })
135
165
  }
136
166
 
137
167
  // listenDirectConvIdHasChanged() {
@@ -143,13 +173,12 @@ export class ConversationListPage implements OnInit {
143
173
  // });
144
174
  // }
145
175
 
146
-
147
176
  // -----------------------------------------------
148
177
  // @ Lifehooks
149
178
  // -----------------------------------------------
150
179
  ngOnInit() {
151
- this.watchToConnectionStatus();
152
- this.getSupportMode();
180
+ this.watchToConnectionStatus()
181
+ this.getAppConfigToHideDiplayBtns()
153
182
 
154
183
  // const currentUrl = this.router.url;
155
184
  // this.logger.log('[CONVS-LIST-PAGE] current_url ngOnInit ', currentUrl);
@@ -192,238 +221,358 @@ export class ConversationListPage implements OnInit {
192
221
  // });
193
222
  }
194
223
 
224
+ ngOnChanges() {
225
+ this.getConversationListHeight()
226
+ }
195
227
 
228
+ getConversationListHeight() {
229
+ var scrollbar2element = document.getElementById('scrollbar2')
230
+ this.logger.log('[CONVS-LIST-PAGE] getConversationListHeight scrollbar2element', scrollbar2element)
231
+ }
232
+
233
+ // this.support_mode = null
234
+ // if( this.appConfigProvider.getConfig().supportMode === true || this.appConfigProvider.getConfig().supportMode === 'true') {
235
+ // this.support_mode = true
236
+ // } else if ( this.appConfigProvider.getConfig().supportMode === false || this.appConfigProvider.getConfig().supportMode === 'false') {
237
+ // this.support_mode = false
238
+ // } else if ( !this.appConfigProvider.getConfig().supportMode ) {
239
+ // this.support_mode = false
240
+ // }
196
241
 
197
- getSupportMode() {
198
- this.supportMode = this.appConfigProvider.getConfig().supportMode;
242
+ getAppConfigToHideDiplayBtns() {
243
+ const appConfig = this.appConfigProvider.getConfig()
244
+ // console.log('[CONVS-LIST-PAGE] - appConfig ', appConfig)
245
+ this.supportMode = null
246
+ if (appConfig && appConfig.supportMode === true || appConfig.supportMode === 'true') {
247
+ this.supportMode = true;
248
+ this.logger.log('[CONVS-LIST-PAGE] getAppConfigToHideDiplayBtns supportMode ', this.supportMode)
249
+ } else if (appConfig && appConfig.supportMode === false || appConfig.supportMode === 'false') {
250
+ this.supportMode = false
251
+ this.logger.log('[CONVS-LIST-PAGE] getAppConfigToHideDiplayBtns supportMode ', this.supportMode)
252
+ }
253
+ this.archived_btn = null
254
+ if (appConfig && appConfig.archivedButton === true || appConfig.archivedButton === 'true') {
255
+ this.archived_btn = true;
256
+ this.logger.log('[CONVS-LIST-PAGE] getAppConfigToHideDiplayBtns archived_btn ', this.archived_btn)
257
+ } else if (appConfig && appConfig.archivedButton === false || appConfig.archivedButton === 'false') {
258
+ this.archived_btn = false;
259
+ this.logger.log('[CONVS-LIST-PAGE] getAppConfigToHideDiplayBtns archived_btn ', this.archived_btn)
260
+ }
261
+ this.writeto_btn = null
262
+ if (appConfig && appConfig.writeToButton === true || appConfig.writeToButton === 'true') {
263
+ this.writeto_btn = true;
264
+ this.logger.log('[CONVS-LIST-PAGE] getAppConfigToHideDiplayBtns writeto_btn ', this.writeto_btn)
265
+ } else if (appConfig && appConfig.writeToButton === false || appConfig.writeToButton === 'false') {
266
+ this.writeto_btn = false;
267
+ this.logger.log('[CONVS-LIST-PAGE] getAppConfigToHideDiplayBtns writeto_btn ', this.writeto_btn)
268
+ }
199
269
  // console.log('[ION-LIST-CONVS-COMP] - supportMode ', this.supportMode)
200
270
  }
201
271
 
202
272
  watchToConnectionStatus() {
203
- this.networkService.checkInternetFunc().subscribe(isOnline => {
273
+ this.networkService.checkInternetFunc().subscribe((isOnline) => {
204
274
  this.checkInternet = isOnline
205
275
  this.logger.log('[ION-LIST-CONVS-COMP] - watchToConnectionStatus - isOnline', this.checkInternet)
206
276
 
207
277
  // checking internet connection
208
278
  if (this.checkInternet == true) {
209
-
210
- this.isOnline = true;
279
+ this.isOnline = true
211
280
  } else {
212
- this.isOnline = false;
281
+ this.isOnline = false
213
282
  }
214
- });
283
+ })
215
284
  }
216
285
 
217
-
218
286
  ionViewWillEnter() {
219
287
  this.logger.log('Called ionViewDidEnter')
220
- this.logger.log('[CONVS-LIST-PAGE] ionViewWillEnter uidConvSelected', this.uidConvSelected);
221
- this.listnerStart();
288
+ this.logger.log(
289
+ '[CONVS-LIST-PAGE] ionViewWillEnter uidConvSelected',
290
+ this.uidConvSelected,
291
+ )
292
+ this.listnerStart()
222
293
 
223
294
  // exit from app with hardware back button
224
295
  this.subscription = this.platform.backButton.subscribe(() => {
225
- navigator['app'].exitApp();
226
- });
296
+ navigator['app'].exitApp()
297
+ })
227
298
  }
228
299
 
229
300
  // unsubscribe backButton.subscribe method to not use from other page
230
301
  ionViewWillLeave() {
231
302
  this.logger.log('Called ionViewWillLeave')
232
- this.subscription.unsubscribe();
303
+ this.subscription.unsubscribe()
233
304
  }
234
305
 
235
306
  ionViewDidEnter() { }
236
307
 
237
308
  getLastProjectId(projectid: string) {
238
- this.logger.log('[CONVS-LIST-PAGE] - GET LAST PROJECT ID', projectid);
239
- this.lastProjectId = projectid;
309
+ this.logger.log('[CONVS-LIST-PAGE] - GET LAST PROJECT ID', projectid)
310
+ this.lastProjectId = projectid
240
311
  }
241
312
 
242
- openUnsevedConversationIframe() {
313
+ openUnsevedConversationIframe(event) {
314
+ this.logger.log('[CONVS-LIST-PAGE] openUnsevedConversationIframe ', event)
243
315
  this.hasClickedOpenUnservedConvIframe = true
244
- this.logger.log('[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME', this.hasClickedOpenUnservedConvIframe);
245
- const DASHBOARD_BASE_URL = this.appConfigProvider.getConfig().dashboardUrl;
246
- this.UNASSIGNED_CONVS_URL = DASHBOARD_BASE_URL + '#/project/' + this.lastProjectId + '/unserved-request-for-panel';
247
- this.logger.log('[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME > UNASSIGNED CONVS URL', this.UNASSIGNED_CONVS_URL);
248
- this.openUnassignedConversations(this.UNASSIGNED_CONVS_URL)
316
+ this.logger.log(
317
+ '[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME',
318
+ this.hasClickedOpenUnservedConvIframe,
319
+ )
320
+ const DASHBOARD_BASE_URL = this.appConfigProvider.getConfig().dashboardUrl
321
+ // http://localhost:4204/#/projects-for-panel
322
+ this.PROJECTS_FOR_PANEL_URL = DASHBOARD_BASE_URL + '#/projects-for-panel'
323
+ this.UNASSIGNED_CONVS_URL =
324
+ DASHBOARD_BASE_URL +
325
+ '#/project/' +
326
+ this.lastProjectId +
327
+ '/unserved-request-for-panel'
328
+
329
+ if (event === 'pinbtn') {
330
+ this.IFRAME_URL = this.PROJECTS_FOR_PANEL_URL
331
+ } else {
332
+ this.IFRAME_URL = this.UNASSIGNED_CONVS_URL
333
+ }
334
+
335
+ this.logger.log(
336
+ '[CONVS-LIST-PAGE] - HAS CLIKED OPEN UNSERVED REQUEST IFRAME > UNASSIGNED CONVS URL',
337
+ this.UNASSIGNED_CONVS_URL,
338
+ )
339
+ this.openUnassignedConversations(this.IFRAME_URL, event)
249
340
  }
250
341
 
251
342
  // ---------------------------------------------------------
252
343
  // Opens the Unassigned Conversations iframe
253
344
  // ---------------------------------------------------------
254
- openUnassignedConversations(UNASSIGNED_CONVS_URL) {
255
-
345
+ openUnassignedConversations(IFRAME_URL: string, event) {
256
346
  if (checkPlatformIsMobile()) {
257
- presentModal(this.modalController, UnassignedConversationsPage, { unassigned_convs_url: UNASSIGNED_CONVS_URL });
347
+ presentModal(this.modalController, UnassignedConversationsPage, {
348
+ iframe_URL: IFRAME_URL,
349
+ callerBtn: event,
350
+ })
258
351
  } else {
259
- this.navService.push(UnassignedConversationsPage, { unassigned_convs_url: UNASSIGNED_CONVS_URL });
352
+ this.navService.push(UnassignedConversationsPage, {
353
+ iframe_URL: IFRAME_URL,
354
+ callerBtn: event,
355
+ })
260
356
  }
261
357
  }
262
358
 
263
359
  _closeContactsDirectory() {
264
360
  try {
265
- closeModal(this.modalController);
361
+ closeModal(this.modalController)
266
362
  } catch (err) {
267
- this.logger.error('[CONVS-LIST-PAGE] closeContactsDirectory -> error:', err);
363
+ this.logger.error(
364
+ '[CONVS-LIST-PAGE] closeContactsDirectory -> error:',
365
+ err,
366
+ )
268
367
  }
269
368
  }
270
369
 
271
-
272
370
  listenToSwPostMessage() {
273
- this.logger.log('[CONVS-LIST-PAGE] listenToNotificationCLick - CALLED: ');
274
- const that = this;
371
+ this.logger.log('[CONVS-LIST-PAGE] listenToNotificationCLick - CALLED: ')
372
+ const that = this
275
373
  if (navigator && navigator.serviceWorker) {
276
-
277
374
  navigator.serviceWorker.addEventListener('message', function (event) {
278
-
279
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data: ', event.data);
280
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data: ', event.data['data']);
281
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data typeof: ', typeof event.data['data']);
375
+ that.logger.log(
376
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data: ',
377
+ event.data,
378
+ )
379
+ that.logger.log(
380
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data: ',
381
+ event.data['data'],
382
+ )
383
+ that.logger.log(
384
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event data data typeof: ',
385
+ typeof event.data['data'],
386
+ )
282
387
  let uidConvSelected = ''
283
388
  if (event.data && event.data['conversWith']) {
284
- uidConvSelected = event.data['conversWith'];
285
- }
286
- else {
287
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - DIFFERENT MSG');
288
- return;
389
+ uidConvSelected = event.data['conversWith']
390
+ } else {
391
+ that.logger.log(
392
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - DIFFERENT MSG',
393
+ )
394
+ return
289
395
  }
290
396
 
291
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event dataObjct uidConvSelected: ', uidConvSelected);
292
- that.logger.log('[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker that.conversations: ', that.conversations);
293
- const conversationSelected = that.conversations.find(item => item.uid === uidConvSelected);
397
+ that.logger.log(
398
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker event dataObjct uidConvSelected: ',
399
+ uidConvSelected,
400
+ )
401
+ that.logger.log(
402
+ '[CONVS-LIST-PAGE] FIREBASE-NOTIFICATION listenToNotificationCLick - Received a message from service worker that.conversations: ',
403
+ that.conversations,
404
+ )
405
+ const conversationSelected = that.conversations.find(
406
+ (item) => item.uid === uidConvSelected,
407
+ )
294
408
  if (conversationSelected) {
295
-
296
- that.conversationSelected = conversationSelected;
297
- that.logger.log('[CONVS-LIST-PAGE] listenToNotificationCLick- Received a message from service worker event conversationSelected: ', that.conversationSelected);
409
+ that.conversationSelected = conversationSelected
410
+ that.logger.log(
411
+ '[CONVS-LIST-PAGE] listenToNotificationCLick- Received a message from service worker event conversationSelected: ',
412
+ that.conversationSelected,
413
+ )
298
414
 
299
415
  that.navigateByUrl('active', uidConvSelected)
300
416
  }
301
- });
417
+ })
302
418
  }
303
419
  }
304
420
 
305
-
306
421
  private listnerStart() {
307
- const that = this;
308
- this.chatManager.BSStart
309
- .pipe(
310
- takeUntil(that.unsubscribe$)
311
- )
312
- .subscribe((data: any) => {
313
- this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR DATA - Current user *****', data);
422
+ const that = this
423
+ this.chatManager.BSStart.pipe(takeUntil(that.unsubscribe$)).subscribe(
424
+ (data: any) => {
425
+ this.logger.log(
426
+ '[CONVS-LIST-PAGE] - BSStart SUBSCR DATA - Current user *****',
427
+ data,
428
+ )
314
429
  if (data) {
315
- that.initialize();
430
+ that.initialize()
316
431
  }
317
- }, error => {
318
- this.logger.error('[CONVS-LIST-PAGE] - BSStart SUBSCR - ERROR: ', error);
319
- }, () => {
432
+ },
433
+ (error) => {
434
+ this.logger.error('[CONVS-LIST-PAGE] - BSStart SUBSCR - ERROR: ', error)
435
+ },
436
+ () => {
320
437
  this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR * COMPLETE *')
321
- });
438
+ },
439
+ )
322
440
  }
323
441
 
324
-
325
442
  // ------------------------------------------------------------------ //
326
443
  // Init convrsation handler
327
444
  // ------------------------------------------------------------------ //
328
445
  initConversationsHandler() {
329
- this.conversations = this.conversationsHandlerService.conversations;
446
+ this.conversations = this.conversationsHandlerService.conversations
330
447
  this.logger.log('[CONVS-LIST-PAGE] - CONVERSATIONS ', this.conversations)
331
448
  // save conversationHandler in chatManager
332
- this.chatManager.setConversationsHandler(this.conversationsHandlerService);
333
- this.showPlaceholder = false;
449
+ this.chatManager.setConversationsHandler(this.conversationsHandlerService)
450
+ this.showPlaceholder = false
334
451
  }
335
452
 
336
-
337
-
338
453
  initArchivedConversationsHandler() {
339
- const keysConversation = ['CLOSED'];
340
- this.translationMapConversation = this.translateService.translateLanguage(keysConversation);
454
+ const keysConversation = ['CLOSED', 'Resolve']
455
+ this.translationMapConversation = this.translateService.translateLanguage(
456
+ keysConversation,
457
+ )
341
458
 
342
459
  this.archivedConversationsHandlerService.subscribeToConversations(() => {
343
- this.logger.log('[CONVS-LIST-PAGE]-CONVS - conversations archived length ', this.archivedConversations.length)
344
-
345
- });
460
+ this.logger.log(
461
+ '[CONVS-LIST-PAGE]-CONVS - conversations archived length ',
462
+ this.archivedConversations.length,
463
+ )
464
+ })
346
465
 
347
- this.archivedConversations = this.archivedConversationsHandlerService.archivedConversations;
348
- this.logger.log('[CONVS-LIST-PAGE] archived conversation', this.archivedConversations)
466
+ this.archivedConversations = this.archivedConversationsHandlerService.archivedConversations
467
+ this.logger.log(
468
+ '[CONVS-LIST-PAGE] archived conversation',
469
+ this.archivedConversations,
470
+ )
349
471
 
350
472
  // save archivedConversationsHandlerService in chatManager
351
- this.chatManager.setArchivedConversationsHandler(this.archivedConversationsHandlerService);
352
-
353
- this.logger.log('[CONVS-LIST-PAGE]-CONVS SubscribeToConversations - conversations archived length ', this.archivedConversations.length)
354
- if (!this.archivedConversations || this.archivedConversations.length === 0) {
355
- this.loadingIsActive = false;
473
+ this.chatManager.setArchivedConversationsHandler(
474
+ this.archivedConversationsHandlerService,
475
+ )
476
+
477
+ this.logger.log(
478
+ '[CONVS-LIST-PAGE]-CONVS SubscribeToConversations - conversations archived length ',
479
+ this.archivedConversations.length,
480
+ )
481
+ if (
482
+ !this.archivedConversations ||
483
+ this.archivedConversations.length === 0
484
+ ) {
485
+ this.loadingIsActive = false
356
486
  }
357
487
  }
358
488
 
359
-
360
489
  // ----------------------------------------------------------------------------------------------------
361
- // To display "No conversation yet" MESSAGE in conversazion list
490
+ // To display "No conversation yet" MESSAGE in conversazion list
362
491
  // this.loadingIsActive is set to false only if on init there are not conversation
363
492
  // otherwise loadingIsActive remains set to true and the message "No conversation yet" is not displayed
364
493
  // to fix this
365
- // - for the direct conversation
366
- // ----------------------------------------------------------------------------------------------------
494
+ // - for the direct conversation
495
+ // ----------------------------------------------------------------------------------------------------
367
496
  listenToAppCompConvsLengthOnInitConvs() {
368
- this.events.subscribe('appcompSubscribeToConvs:loadingIsActive', (loadingIsActive) => {
369
- this.logger.log('[CONVS-LIST-PAGE]-CONVS loadingIsActive', loadingIsActive);
370
- if (loadingIsActive === false) {
371
- this.loadingIsActive = false
372
- }
373
- });
497
+ this.events.subscribe(
498
+ 'appcompSubscribeToConvs:loadingIsActive',
499
+ (loadingIsActive) => {
500
+ this.logger.log(
501
+ '[CONVS-LIST-PAGE]-CONVS loadingIsActive',
502
+ loadingIsActive,
503
+ )
504
+ if (loadingIsActive === false) {
505
+ this.loadingIsActive = false
506
+ }
507
+ },
508
+ )
374
509
  }
375
510
 
376
511
  listenGoOnline() {
377
512
  this.events.subscribe('go:online', (goonline) => {
378
- this.logger.info('[CONVS-LIST-PAGE] - listen To go:online - goonline', goonline);
513
+ this.logger.info(
514
+ '[CONVS-LIST-PAGE] - listen To go:online - goonline',
515
+ goonline,
516
+ )
379
517
  // this.events.unsubscribe('profileInfoButtonClick:logout')
380
518
  if (goonline === true) {
381
519
  this.displayNewConvsItem = true
382
520
  }
383
- });
521
+ })
384
522
  }
385
523
 
386
524
  listenGoOffline() {
387
-
388
525
  this.events.subscribe('go:offline', (offline) => {
389
- this.logger.info('[CONVS-LIST-PAGE] - listen To go:offline - offline', offline);
526
+ this.logger.info(
527
+ '[CONVS-LIST-PAGE] - listen To go:offline - offline',
528
+ offline,
529
+ )
390
530
  // this.events.unsubscribe('profileInfoButtonClick:logout')
391
531
  if (offline === true) {
392
532
  this.displayNewConvsItem = false
393
533
  }
394
- });
534
+ })
395
535
  }
396
536
 
397
537
  listenToLogoutEvent() {
398
- this.events.subscribe('profileInfoButtonClick:logout', (hasclickedlogout) => {
399
- this.logger.info('[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout', hasclickedlogout);
400
-
401
-
402
- this.conversations = []
403
- this.conversationsHandlerService.conversations = [];
404
- this.uidConvSelected = null;
405
-
406
- this.logger.log('[CONVS-LIST-PAGE] - listenToLogoutEvent - CONVERSATIONS ', this.conversations)
407
- this.logger.log('[CONVS-LIST-PAGE] - listenToLogoutEvent - uidConvSelected ', this.uidConvSelected)
408
- if (hasclickedlogout === true) {
409
- this.loadingIsActive = false
410
- }
411
- });
538
+ this.events.subscribe(
539
+ 'profileInfoButtonClick:logout',
540
+ (hasclickedlogout) => {
541
+ this.logger.info(
542
+ '[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout',
543
+ hasclickedlogout,
544
+ )
545
+
546
+ this.conversations = []
547
+ this.conversationsHandlerService.conversations = []
548
+ this.uidConvSelected = null
549
+
550
+ this.logger.log(
551
+ '[CONVS-LIST-PAGE] - listenToLogoutEvent - CONVERSATIONS ',
552
+ this.conversations,
553
+ )
554
+ this.logger.log(
555
+ '[CONVS-LIST-PAGE] - listenToLogoutEvent - uidConvSelected ',
556
+ this.uidConvSelected,
557
+ )
558
+ if (hasclickedlogout === true) {
559
+ this.loadingIsActive = false
560
+ }
561
+ },
562
+ )
412
563
  }
413
564
 
414
-
415
- // ------------------------------------------------------------------
565
+ // ------------------------------------------------------------------
416
566
  // SUBSCRIPTIONS
417
567
  // ------------------------------------------------------------------
418
568
  initSubscriptions() {
419
569
  this.logger.log('[CONVS-LIST-PAGE] - CALLING - initSubscriptions ')
420
- let key = '';
570
+ let key = ''
421
571
 
422
-
423
- key = 'loggedUser:logout';
572
+ key = 'loggedUser:logout'
424
573
  if (!isInArray(key, this.subscriptions)) {
425
- this.subscriptions.push(key);
426
- this.events.subscribe(key, this.subscribeLoggedUserLogout);
574
+ this.subscriptions.push(key)
575
+ this.events.subscribe(key, this.subscribeLoggedUserLogout)
427
576
  }
428
577
 
429
578
  // key = 'readAllMessages';
@@ -432,10 +581,10 @@ export class ConversationListPage implements OnInit {
432
581
  // this.events.subscribe(key, this.readAllMessages);
433
582
  // }
434
583
 
435
- key = 'profileInfoButtonClick:changed';
584
+ key = 'profileInfoButtonClick:changed'
436
585
  if (!isInArray(key, this.subscriptions)) {
437
- this.subscriptions.push(key);
438
- this.events.subscribe(key, this.subscribeProfileInfoButtonClicked);
586
+ this.subscriptions.push(key)
587
+ this.events.subscribe(key, this.subscribeProfileInfoButtonClicked)
439
588
  }
440
589
 
441
590
  // this.conversationsHandlerService.readAllMessages.subscribe((conversationId: string) => {
@@ -443,67 +592,89 @@ export class ConversationListPage implements OnInit {
443
592
  // this.readAllMessages(conversationId);
444
593
  // });
445
594
 
446
- this.conversationsHandlerService.conversationAdded.subscribe((conversation: ConversationModel) => {
447
- // this.logger.log('[CONVS-LIST-PAGE] ***** conversationsAdded *****', conversation);
448
- // that.conversationsChanged(conversations);
449
- if (conversation) {
450
- this.onImageLoaded(conversation)
451
- this.onConversationLoaded(conversation)
452
- }
453
- });
454
-
455
- this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
456
- // this.logger.log('[CONVS-LIST-PAGE] ***** subscribeConversationChanged *****', conversation);
457
- // that.conversationsChanged(conversations)
458
- if (conversation) {
459
- this.onImageLoaded(conversation)
460
- this.onConversationLoaded(conversation)
461
- }
462
- });
463
-
464
- this.conversationsHandlerService.conversationRemoved.subscribe((conversation: ConversationModel) => {
465
- this.logger.log('[CONVS-LIST-PAGE] ***** conversationsRemoved *****', conversation);
466
- });
467
-
468
- this.archivedConversationsHandlerService.archivedConversationAdded.subscribe((conversation: ConversationModel) => {
469
- this.logger.log('[CONVS-LIST-PAGE] ***** archivedConversationAdded *****', conversation);
470
- // that.conversationsChanged(conversations);
471
- if (conversation) {
472
- this.onImageLoaded(conversation)
473
- this.onConversationLoaded(conversation)
474
- }
475
- });
595
+ this.conversationsHandlerService.conversationAdded.subscribe(
596
+ (conversation: ConversationModel) => {
597
+ // this.logger.log('[CONVS-LIST-PAGE] ***** conversationsAdded *****', conversation);
598
+ // that.conversationsChanged(conversations);
599
+ if (conversation) {
600
+ this.onImageLoaded(conversation)
601
+ this.onConversationLoaded(conversation)
602
+ }
603
+ },
604
+ )
605
+
606
+ this.conversationsHandlerService.conversationChanged.subscribe(
607
+ (conversation: ConversationModel) => {
608
+ // this.logger.log('[CONVS-LIST-PAGE] ***** subscribeConversationChanged *****', conversation);
609
+ // that.conversationsChanged(conversations)
610
+ if (conversation) {
611
+ this.onImageLoaded(conversation)
612
+ this.onConversationLoaded(conversation)
613
+ }
614
+ },
615
+ )
616
+
617
+ this.conversationsHandlerService.conversationRemoved.subscribe(
618
+ (conversation: ConversationModel) => {
619
+ this.logger.log(
620
+ '[CONVS-LIST-PAGE] ***** conversationsRemoved *****',
621
+ conversation,
622
+ )
623
+ },
624
+ )
625
+
626
+ this.archivedConversationsHandlerService.archivedConversationAdded.subscribe(
627
+ (conversation: ConversationModel) => {
628
+ this.logger.log(
629
+ '[CONVS-LIST-PAGE] ***** archivedConversationAdded *****',
630
+ conversation,
631
+ )
632
+ // that.conversationsChanged(conversations);
633
+ if (conversation) {
634
+ this.onImageLoaded(conversation)
635
+ this.onConversationLoaded(conversation)
636
+ }
637
+ },
638
+ )
476
639
  }
477
640
 
478
641
  // ------------------------------------------------------------------------------------
479
642
  // @ SUBSCRIBE TO LOGGED USER LOGOUT ??????????? SEEMS NOT USED ?????????????????
480
643
  // ------------------------------------------------------------------------------------
481
644
  subscribeLoggedUserLogout = () => {
482
- this.conversations = [];
483
- this.uidConvSelected = null;
484
- this.logger.log('[CONVS-LIST-PAGE] - subscribeLoggedUserLogout conversations ', this.conversations);
485
- this.logger.log('[CONVS-LIST-PAGE] - subscribeLoggedUserLogout uidConvSelected ', this.uidConvSelected);
645
+ this.conversations = []
646
+ this.uidConvSelected = null
647
+ this.logger.log(
648
+ '[CONVS-LIST-PAGE] - subscribeLoggedUserLogout conversations ',
649
+ this.conversations,
650
+ )
651
+ this.logger.log(
652
+ '[CONVS-LIST-PAGE] - subscribeLoggedUserLogout uidConvSelected ',
653
+ this.uidConvSelected,
654
+ )
486
655
  }
487
656
 
488
-
489
-
490
657
  // ------------------------------------------------------------------------------------
491
658
  // @ SUBSCRIBE TO CONVERSATION CHANGED ??????????? SEEMS NOT USED ?????????????????
492
659
  // ------------------------------------------------------------------------------------
493
660
  conversationsChanged = (conversations: ConversationModel[]) => {
494
- this.numberOpenConv = this.conversationsHandlerService.countIsNew();
495
- this.logger.log('[CONVS-LIST-PAGE] - conversationsChanged - NUMB OF CONVERSATIONS: ', this.numberOpenConv);
661
+ this.numberOpenConv = this.conversationsHandlerService.countIsNew()
662
+ this.logger.log(
663
+ '[CONVS-LIST-PAGE] - conversationsChanged - NUMB OF CONVERSATIONS: ',
664
+ this.numberOpenConv,
665
+ )
496
666
  // console.log('conversationsChanged »»»»»»»»» uidConvSelected', that.conversations[0], that.uidConvSelected);
497
667
  if (this.uidConvSelected && !this.conversationSelected) {
498
- const conversationSelected = this.conversations.find(item => item.uid === this.uidConvSelected);
668
+ const conversationSelected = this.conversations.find(
669
+ (item) => item.uid === this.uidConvSelected,
670
+ )
499
671
  if (conversationSelected) {
500
- this.conversationSelected = conversationSelected;
501
- this.setUidConvSelected(this.uidConvSelected);
672
+ this.conversationSelected = conversationSelected
673
+ this.setUidConvSelected(this.uidConvSelected)
502
674
  }
503
675
  }
504
676
  }
505
677
 
506
-
507
678
  /**
508
679
  * ::: subscribeChangedConversationSelected :::
509
680
  * evento richiamato quando si seleziona un utente nell'elenco degli user
@@ -513,14 +684,27 @@ export class ConversationListPage implements OnInit {
513
684
  // !!!!!! IS USED? ?????
514
685
  // ------------------------------
515
686
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
516
- this.logger.log('[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl', user, type);
517
- this.uidConvSelected = user.uid;
518
- this.logger.log('[CONVS-LIST-PAGE] ************** uidConvSelected ', this.uidConvSelected);
687
+ this.logger.log(
688
+ '[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl',
689
+ user,
690
+ type,
691
+ )
692
+ this.uidConvSelected = user.uid
693
+ this.logger.log(
694
+ '[CONVS-LIST-PAGE] ************** uidConvSelected ',
695
+ this.uidConvSelected,
696
+ )
519
697
  // this.conversationsHandlerService.uidConvSelected = user.uid;
520
- const conversationSelected = this.conversations.find(item => item.uid === this.uidConvSelected);
698
+ const conversationSelected = this.conversations.find(
699
+ (item) => item.uid === this.uidConvSelected,
700
+ )
521
701
  if (conversationSelected) {
522
- this.logger.log('[CONVS-LIST-PAGE] --> uidConvSelected: ', this.conversationSelected, this.uidConvSelected);
523
- this.conversationSelected = conversationSelected;
702
+ this.logger.log(
703
+ '[CONVS-LIST-PAGE] --> uidConvSelected: ',
704
+ this.conversationSelected,
705
+ this.uidConvSelected,
706
+ )
707
+ this.conversationSelected = conversationSelected
524
708
  }
525
709
  // this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
526
710
  }
@@ -530,20 +714,28 @@ export class ConversationListPage implements OnInit {
530
714
  * evento richiamato quando si seleziona bottone profile-info-modal
531
715
  */
532
716
  subscribeProfileInfoButtonClicked = (event: string) => {
533
- this.logger.log('[CONVS-LIST-PAGE] ************** subscribeProfileInfoButtonClicked: ', event);
717
+ this.logger.log(
718
+ '[CONVS-LIST-PAGE] ************** subscribeProfileInfoButtonClicked: ',
719
+ event,
720
+ )
534
721
  if (event === 'displayArchived') {
535
- this.initArchivedConversationsHandler();
722
+ this.initArchivedConversationsHandler()
536
723
  // this.openArchivedConversationsModal()
537
724
  this.conversationType = 'archived'
538
725
 
539
726
  // let storedArchivedConv = localStorage.getItem('activeConversationSelected');
540
- const keys = ['LABEL_ARCHIVED'];
541
- this.headerTitle = this.translateService.translateLanguage(keys).get(keys[0]);
727
+ const keys = ['LABEL_ARCHIVED']
728
+ // const keys = ['History'];
542
729
 
730
+ this.headerTitle = this.translateService
731
+ .translateLanguage(keys)
732
+ .get(keys[0])
543
733
  } else if (event === 'displayContact') {
544
734
  this.conversationType = 'archived'
545
- const keys = ['LABEL_CONTACTS'];
546
- this.headerTitle = this.translateService.translateLanguage(keys).get(keys[0]);
735
+ const keys = ['LABEL_CONTACTS']
736
+ this.headerTitle = this.translateService
737
+ .translateLanguage(keys)
738
+ .get(keys[0])
547
739
  }
548
740
  }
549
741
 
@@ -557,12 +749,10 @@ export class ConversationListPage implements OnInit {
557
749
  // console.log('ConversationListPage - storedActiveConv Objct: ', storedActiveConvObjct);
558
750
  // this.navigateByUrl('active', storedActiveConvObjct.uid)
559
751
  // } else {
560
- // // da implementare se nn c'è stata nessuna conv attive selezionata
752
+ // // da implementare se nn c'è stata nessuna conv attive selezionata
561
753
  // }
562
-
563
754
  }
564
755
 
565
-
566
756
  // ------------------------------------------------------------------//
567
757
  // END SUBSCRIPTIONS
568
758
  // ------------------------------------------------------------------//
@@ -584,8 +774,6 @@ export class ConversationListPage implements OnInit {
584
774
  // })
585
775
  // }
586
776
 
587
-
588
-
589
777
  // ------------------------------------------------------------------//
590
778
  // BEGIN FUNCTIONS
591
779
  // ------------------------------------------------------------------//
@@ -593,22 +781,24 @@ export class ConversationListPage implements OnInit {
593
781
  * ::: initialize :::
594
782
  */
595
783
  initialize() {
596
- const appconfig = this.appConfigProvider.getConfig();
597
- this.tenant = appconfig.firebaseConfig.tenant;
598
- this.logger.log('[CONVS-LIST-PAGE] - initialize -> firebaseConfig tenant ', this.tenant);
784
+ const appconfig = this.appConfigProvider.getConfig()
785
+ this.tenant = appconfig.firebaseConfig.tenant
786
+ this.logger.log(
787
+ '[CONVS-LIST-PAGE] - initialize -> firebaseConfig tenant ',
788
+ this.tenant,
789
+ )
599
790
 
600
791
  if (this.tiledeskAuthService.getCurrentUser()) {
601
- this.loggedUserUid = this.tiledeskAuthService.getCurrentUser().uid;
792
+ this.loggedUserUid = this.tiledeskAuthService.getCurrentUser().uid
602
793
  }
603
- this.subscriptions = [];
604
- this.initConversationsHandler();
605
- this.initVariables();
606
- this.initSubscriptions();
794
+ this.subscriptions = []
795
+ this.initConversationsHandler()
796
+ this.initVariables()
797
+ this.initSubscriptions()
607
798
 
608
799
  // this.initHandlerEventEmitter();
609
800
  }
610
801
 
611
-
612
802
  /**
613
803
  * ::: initVariables :::
614
804
  * al caricamento della pagina:
@@ -623,46 +813,45 @@ export class ConversationListPage implements OnInit {
623
813
  // It only works on BSStart.subscribe! it is useful or can be eliminated
624
814
  // --------------------------------------------------------
625
815
  initVariables() {
626
- this.logger.log('[CONVS-LIST-PAGE] uidReciverFromUrl:: ' + this.uidReciverFromUrl);
627
- this.logger.log('[CONVS-LIST-PAGE] loggedUserUid:: ' + this.loggedUserUid);
628
- this.logger.log('[CONVS-LIST-PAGE] tenant:: ' + this.tenant);
629
- if (this.route.component['name'] !== "ConversationListPage") {
630
-
816
+ this.logger.log(
817
+ '[CONVS-LIST-PAGE] uidReciverFromUrl:: ' + this.uidReciverFromUrl,
818
+ )
819
+ this.logger.log('[CONVS-LIST-PAGE] loggedUserUid:: ' + this.loggedUserUid)
820
+ this.logger.log('[CONVS-LIST-PAGE] tenant:: ' + this.tenant)
821
+ if (this.route.component['name'] !== 'ConversationListPage') {
631
822
  if (this.route && this.route.snapshot && this.route.snapshot.firstChild) {
632
- const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
633
- this.logger.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv);
823
+ const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv')
824
+ this.logger.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv)
634
825
  if (IDConv) {
635
- this.setUidConvSelected(IDConv);
826
+ this.setUidConvSelected(IDConv)
636
827
  } else {
637
-
638
- this.logger.log('[CONVS-LIST-PAGE] conversationWith 2 (else): ', IDConv);
828
+ this.logger.log(
829
+ '[CONVS-LIST-PAGE] conversationWith 2 (else): ',
830
+ IDConv,
831
+ )
639
832
  }
640
833
  }
641
834
  }
642
835
  }
643
836
 
644
-
645
-
646
837
  /**
647
838
  * ::: setUidConvSelected :::
648
839
  */
649
- setUidConvSelected(uidConvSelected: string, conversationType?: string,) {
840
+ setUidConvSelected(uidConvSelected: string, conversationType?: string) {
650
841
  this.logger.log('[CONVS-LIST-PAGE] setuidCOnvSelected', uidConvSelected)
651
- this.uidConvSelected = uidConvSelected;
842
+ this.uidConvSelected = uidConvSelected
652
843
  this.logger.log('uidConvSelected', uidConvSelected)
653
844
  // this.conversationsHandlerService.uidConvSelected = uidConvSelected;
654
845
  if (uidConvSelected) {
655
- let conversationSelected;
846
+ let conversationSelected
656
847
  if (conversationType === 'active') {
657
- conversationSelected = this.conversations.find(item => item.uid === this.uidConvSelected);
658
- } else if (conversationType === 'archived') {
659
- conversationSelected = this.archivedConversations.find(item => item.uid === this.uidConvSelected);
660
- }
848
+ conversationSelected = this.conversations.find((item) => item.uid === this.uidConvSelected)
849
+ } else if (conversationType === 'archived') { conversationSelected = this.archivedConversations.find((item) => item.uid === this.uidConvSelected) }
661
850
  if (conversationSelected) {
662
- this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected);
663
- this.logger.log('[CONVS-LIST-PAGE] the conversation ', this.conversationSelected, ' has already been loaded');
664
- this.conversationSelected = conversationSelected;
665
- this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected: ', this.conversationSelected);
851
+ this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected,)
852
+ this.logger.log('[CONVS-LIST-PAGE] the conversation ', this.conversationSelected, ' has already been loaded')
853
+ this.conversationSelected = conversationSelected
854
+ this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected: ', this.conversationSelected)
666
855
  }
667
856
  }
668
857
  }
@@ -671,29 +860,31 @@ export class ConversationListPage implements OnInit {
671
860
  this.logger.log('onConversationSelected conversation', conversation)
672
861
  if (conversation.archived) {
673
862
  this.navigateByUrl('archived', conversation.uid)
674
- this.logger.log('[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ', conversation.uid)
863
+ this.logger.log('[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ', conversation.uid,
864
+ )
675
865
  } else {
676
866
  this.navigateByUrl('active', conversation.uid)
677
867
  this.logger.log('[CONVS-LIST-PAGE] onConversationSelected active conversation.uid ', conversation.uid)
678
868
  }
679
-
680
869
  }
681
870
 
682
871
  onImageLoaded(conversation: any) {
683
872
  // this.logger.log('[CONVS-LIST-PAGE] onImageLoaded', conversation)
684
- let conversation_with_fullname = conversation.sender_fullname;
685
- let conversation_with = conversation.sender;
873
+ let conversation_with_fullname = conversation.sender_fullname
874
+ let conversation_with = conversation.sender
686
875
  if (conversation.sender === this.loggedUserUid) {
687
- conversation_with = conversation.recipient;
688
- conversation_with_fullname = conversation.recipient_fullname;
876
+ conversation_with = conversation.recipient
877
+ conversation_with_fullname = conversation.recipient_fullname
689
878
  } else if (isGroup(conversation)) {
690
879
  // conversation_with_fullname = conv.sender_fullname;
691
880
  // conv.last_message_text = conv.last_message_text;
692
- conversation_with = conversation.recipient;
693
- conversation_with_fullname = conversation.recipient_fullname;
881
+ conversation_with = conversation.recipient
882
+ conversation_with_fullname = conversation.recipient_fullname
694
883
  }
695
- if (!conversation_with.startsWith("support-group")) {
696
- conversation.image = this.imageRepoService.getImagePhotoUrl(conversation_with)
884
+ if (!conversation_with.startsWith('support-group')) {
885
+ conversation.image = this.imageRepoService.getImagePhotoUrl(
886
+ conversation_with,
887
+ )
697
888
  }
698
889
  }
699
890
 
@@ -704,49 +895,42 @@ export class ConversationListPage implements OnInit {
704
895
  // this.ionContentConvList.scrollToTop(0);
705
896
  // }
706
897
 
707
- const keys = ['YOU', 'SENT_AN_IMAGE', 'SENT_AN_ATTACHMENT'];
708
- const translationMap = this.translateService.translateLanguage(keys);
898
+ const keys = ['YOU', 'SENT_AN_IMAGE', 'SENT_AN_ATTACHMENT']
899
+ const translationMap = this.translateService.translateLanguage(keys)
709
900
  // Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly in the convesations list
710
901
 
711
- var regex = /<br\s*[\/]?>/gi;
902
+ var regex = /<br\s*[\/]?>/gi
712
903
  if (conversation && conversation.last_message_text) {
713
- conversation.last_message_text = conversation.last_message_text.replace(regex, "")
904
+ conversation.last_message_text = conversation.last_message_text.replace(regex, '',)
714
905
 
715
906
  //FIX-BUG: 'YOU: YOU: YOU: text' on last-message-text in conversation-list
716
907
  if (conversation.sender === this.loggedUserUid && !conversation.last_message_text.includes(': ')) {
717
908
  // this.logger.log('[CONVS-LIST-PAGE] onConversationLoaded', conversation)
718
909
 
719
- if (conversation.type !== "image" && conversation.type !== "file") {
720
- conversation.last_message_text = translationMap.get('YOU') + ': ' + conversation.last_message_text;
721
-
722
- } else if (conversation.type === "image") {
723
-
910
+ if (conversation.type !== 'image' && conversation.type !== 'file') {
911
+ conversation.last_message_text = translationMap.get('YOU') + ': ' + conversation.last_message_text
912
+ } else if (conversation.type === 'image') {
724
913
  // this.logger.log('[CONVS-LIST-PAGE] HAS SENT AN IMAGE');
725
914
  // this.logger.log("[CONVS-LIST-PAGE] translationMap.get('YOU')")
726
- const SENT_AN_IMAGE = conversation['last_message_text'] = translationMap.get('SENT_AN_IMAGE')
727
-
728
- conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_IMAGE;
915
+ const SENT_AN_IMAGE = (conversation['last_message_text'] = translationMap.get('SENT_AN_IMAGE'))
729
916
 
730
- } else if (conversation.type === "file") {
917
+ conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_IMAGE
918
+ } else if (conversation.type === 'file') {
731
919
  // this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
732
- const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
733
- conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_ATTACHMENT;
920
+ const SENT_AN_ATTACHMENT = (conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT'))
921
+ conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_ATTACHMENT
734
922
  }
735
923
  } else {
736
- if (conversation.type === "image") {
737
-
924
+ if (conversation.type === 'image') {
738
925
  // this.logger.log('[CONVS-LIST-PAGE] HAS SENT AN IMAGE');
739
926
  // this.logger.log("[CONVS-LIST-PAGE] translationMap.get('YOU')")
740
- const SENT_AN_IMAGE = conversation['last_message_text'] = translationMap.get('SENT_AN_IMAGE')
741
-
742
- conversation.last_message_text = SENT_AN_IMAGE;
927
+ const SENT_AN_IMAGE = (conversation['last_message_text'] = translationMap.get('SENT_AN_IMAGE'))
743
928
 
744
- }
745
- else if (conversation.type === "file") {
929
+ conversation.last_message_text = SENT_AN_IMAGE
930
+ } else if (conversation.type === 'file') {
746
931
  // this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
747
- const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
748
- conversation.last_message_text = SENT_AN_ATTACHMENT;
749
-
932
+ const SENT_AN_ATTACHMENT = (conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT'))
933
+ conversation.last_message_text = SENT_AN_ATTACHMENT
750
934
  }
751
935
  }
752
936
  }
@@ -756,59 +940,65 @@ export class ConversationListPage implements OnInit {
756
940
  // this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 1')
757
941
  // var regex = /^(^|[\n\r])\s*1\.\s.*\s+1\.\s$/
758
942
  // let matchRegex = false
759
- // if (regex.test(last_message_text)) {
943
+ // if (regex.test(last_message_text)) {
760
944
  // this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 2')
761
945
  // matchRegex = true
762
946
  // return matchRegex
763
947
  // }
764
948
  // }
765
949
 
766
-
767
950
  navigateByUrl(converationType: string, uidConvSelected: string) {
768
- this.logger.log('[CONVS-LIST-PAGE] calling navigateByUrl: ');
769
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected);
770
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl run this.setUidConvSelected');
771
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.uidConvSelected ', this.uidConvSelected);
772
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected ', this.conversationSelected)
773
951
 
774
- this.setUidConvSelected(uidConvSelected, converationType);
952
+ this.logger.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected)
953
+
954
+ this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.uidConvSelected ', this.uidConvSelected)
955
+
956
+ this.setUidConvSelected(uidConvSelected, converationType)
775
957
  if (checkPlatformIsMobile()) {
776
- this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
777
- this.logger.log('[CONVS-LIST-PAGE] DESKTOP (window >= 768)', this.navService);
778
- let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
958
+ this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile())
959
+ this.logger.log('[CONVS-LIST-PAGE] DESKTOP (window < 768)', this.navService)
960
+ this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected conversation_with_fullname ', this.conversationSelected.conversation_with_fullname)
961
+ let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType
779
962
  this.logger.log('[CONVS-LIST-PAGE] pageURL', pageUrl)
780
- this.router.navigateByUrl(pageUrl);
963
+ // replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
964
+ this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'))
781
965
  } else {
782
- this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
783
- this.logger.log('[CONVS-LIST-PAGE] MOBILE (window < 768) ', this.navService);
784
- let pageUrl = 'conversation-detail/' + this.uidConvSelected;
966
+ this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected conversation_with_fullname ', this.conversationSelected.conversation_with_fullname)
967
+ this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile())
968
+ this.logger.log('[CONVS-LIST-PAGE] MOBILE (window >= 768) ', this.navService)
969
+ let pageUrl = 'conversation-detail/' + this.uidConvSelected
785
970
  if (this.conversationSelected && this.conversationSelected.conversation_with_fullname) {
786
- pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
971
+ pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType
787
972
  }
788
- this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected navigateByUrl--->: ', pageUrl);
789
- this.router.navigateByUrl(pageUrl);
973
+ this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected navigateByUrl--->: ', pageUrl)
974
+ // replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
975
+ this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'))
790
976
  }
791
977
  }
792
978
 
793
-
794
979
  // ---------------------------------------------------------
795
980
  // Opens the list of contacts for direct convs
796
981
  // ---------------------------------------------------------
797
982
  openContactsDirectory(event: any) {
798
- const TOKEN = this.tiledeskAuthService.getTiledeskToken();
799
- this.logger.log('[CONVS-LIST-PAGE] openContactsDirectory', TOKEN);
983
+ const TOKEN = this.tiledeskAuthService.getTiledeskToken()
984
+ this.logger.log('[CONVS-LIST-PAGE] openContactsDirectory', TOKEN)
800
985
  if (checkPlatformIsMobile()) {
801
- presentModal(this.modalController, ContactsDirectoryPage, { token: TOKEN });
986
+ presentModal(this.modalController, ContactsDirectoryPage, {
987
+ token: TOKEN,
988
+ })
802
989
  } else {
803
- this.navService.push(ContactsDirectoryPage, { token: TOKEN });
990
+ this.navService.push(ContactsDirectoryPage, { token: TOKEN })
804
991
  }
805
992
  }
806
993
 
807
994
  closeContactsDirectory() {
808
995
  try {
809
- closeModal(this.modalController);
996
+ closeModal(this.modalController)
810
997
  } catch (err) {
811
- this.logger.error('[CONVS-LIST-PAGE] closeContactsDirectory -> error:', err);
998
+ this.logger.error(
999
+ '[CONVS-LIST-PAGE] closeContactsDirectory -> error:',
1000
+ err,
1001
+ )
812
1002
  }
813
1003
  }
814
1004
 
@@ -816,8 +1006,8 @@ export class ConversationListPage implements OnInit {
816
1006
  // Opens logged user profile modal
817
1007
  // ---------------------------------------------------------
818
1008
  openProfileInfo(event: any) {
819
- const TOKEN = this.messagingAuthService.getToken();
820
- this.logger.log('[CONVS-LIST-PAGE] open ProfileInfoPage TOKEN ', TOKEN);
1009
+ const TOKEN = this.messagingAuthService.getToken()
1010
+ this.logger.log('[CONVS-LIST-PAGE] open ProfileInfoPage TOKEN ', TOKEN)
821
1011
  if (checkPlatformIsMobile()) {
822
1012
  presentModal(this.modalController, ProfileInfoPage, { token: TOKEN })
823
1013
  } else {
@@ -825,102 +1015,186 @@ export class ConversationListPage implements OnInit {
825
1015
  }
826
1016
  }
827
1017
 
1018
+ listenToCloseConvFromHeaderConversation() {
1019
+ this.events.subscribe('conversation:closed', (convId) => {
1020
+ this.logger.log('[CONVS-LIST-PAGE] hasclosedconversation convId', convId)
828
1021
 
1022
+ const conversation = this.conversations.find(
1023
+ (conv) => conv.uid === convId,
1024
+ )
1025
+ this.logger.log('[CONVS-LIST-PAGE] hasclosedconversation conversation', conversation)
1026
+ this.onCloseConversation(conversation)
1027
+ })
1028
+ }
829
1029
 
830
1030
  // ----------------------------------------------------------------------------------------------
831
1031
  // onCloseConversation
832
1032
  // https://github.com/chat21/chat21-cloud-functions/blob/master/docs/api.md#delete-a-conversation
833
1033
  // ----------------------------------------------------------------------------------------------
834
1034
  onCloseConversation(conversation: ConversationModel) {
1035
+ this.logger.log('[CONVS-LIST-PAGE] onCloseConversation conversation', conversation)
1036
+
835
1037
  // -------------------------------------------------------------------------------------
836
- // Fix the display of the message "No conversation yet" when a conversation is archived
837
- // but there are others in the list (happens when loadingIsActive is set to false because
1038
+ // Fix the display of the message "No conversation yet" when a conversation is archived
1039
+ // but there are others in the list (happens when loadingIsActive is set to false because
838
1040
  // when is called the initConversationsHandler method there is not conversations)
839
1041
  // -------------------------------------------------------------------------------------
840
- this.loadingIsActive = false;
1042
+ this.loadingIsActive = false
841
1043
  // console.log('CONVS - CONV-LIST-PAGE onCloseConversation CONVS: ', conversation)
842
1044
  this.logger.log('[CONVS-LIST-PAGE] onCloseConversation loadingIsActive: ', this.loadingIsActive)
1045
+ if (conversation) {
1046
+ const conversationId = conversation.uid
843
1047
 
844
- const conversationId = conversation.uid;
845
-
846
- this.logger.log('[CONVS-LIST-PAGE] onCloseConversation conversationId: ', conversationId)
1048
+ this.logger.log('[CONVS-LIST-PAGE] onCloseConversation conversationId: ', conversationId)
847
1049
 
848
- const conversationWith_segments = conversationId.split('-');
849
- this.logger.log('[CONVS-LIST-PAGE] - conversationId_segments: ', conversationWith_segments);
850
-
851
- // Removes the last element of the array if is = to the separator
852
- if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
853
- conversationWith_segments.pop();
854
- }
1050
+ const conversationWith_segments = conversationId.split('-')
1051
+ this.logger.log(
1052
+ '[CONVS-LIST-PAGE] - conversationId_segments: ',
1053
+ conversationWith_segments,
1054
+ )
855
1055
 
856
- if (conversationWith_segments.length === 4) {
857
- const lastArrayElement = conversationWith_segments[conversationWith_segments.length - 1]
858
- this.logger.log('[CONVS-LIST-PAGE] - lastArrayElement ', lastArrayElement);
859
- this.logger.log('[CONVS-LIST-PAGE] - lastArrayElement length', lastArrayElement.length);
860
- if (lastArrayElement.length !== 32) {
861
- conversationWith_segments.pop();
1056
+ // Removes the last element of the array if is = to the separator
1057
+ if (
1058
+ conversationWith_segments[conversationWith_segments.length - 1] === ''
1059
+ ) {
1060
+ conversationWith_segments.pop()
862
1061
  }
863
- }
864
1062
 
865
- if (conversationId.startsWith("support-group")) {
866
- let project_id = ''
867
1063
  if (conversationWith_segments.length === 4) {
868
- project_id = conversationWith_segments[2];
869
-
870
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
871
- this.archiveSupportGroupConv(tiledeskToken, project_id, conversationId);
1064
+ const lastArrayElement =
1065
+ conversationWith_segments[conversationWith_segments.length - 1]
1066
+ this.logger.log(
1067
+ '[CONVS-LIST-PAGE] - lastArrayElement ',
1068
+ lastArrayElement,
1069
+ )
1070
+ this.logger.log(
1071
+ '[CONVS-LIST-PAGE] - lastArrayElement length',
1072
+ lastArrayElement.length,
1073
+ )
1074
+ if (lastArrayElement.length !== 32) {
1075
+ conversationWith_segments.pop()
1076
+ }
1077
+ }
872
1078
 
1079
+ if (conversationId.startsWith('support-group')) {
1080
+ let project_id = ''
1081
+ if (conversationWith_segments.length === 4) {
1082
+ project_id = conversationWith_segments[2]
1083
+
1084
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1085
+ this.archiveSupportGroupConv(
1086
+ tiledeskToken,
1087
+ project_id,
1088
+ conversationId,
1089
+ )
1090
+ } else {
1091
+ this.getProjectIdByConversationWith(conversationId)
1092
+ }
873
1093
  } else {
874
- this.getProjectIdByConversationWith(conversationId)
1094
+ this.conversationsHandlerService.archiveConversation(conversationId)
875
1095
  }
876
- } else {
877
- this.conversationsHandlerService.archiveConversation(conversationId)
878
1096
  }
879
1097
  }
880
1098
 
881
1099
  getProjectIdByConversationWith(conversationId: string) {
882
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
883
-
884
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationId).subscribe(res => {
885
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT RES', res);
886
-
887
- if (res) {
888
- const project_id = res.id_project
889
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT project_id', project_id);
890
- this.archiveSupportGroupConv(tiledeskToken, project_id, conversationId);
891
- }
892
-
893
- }, (error) => {
894
- this.logger.error('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error);
895
-
896
- }, () => {
897
- this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *');
898
-
899
- });
1100
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1101
+
1102
+ this.tiledeskService
1103
+ .getProjectIdByConvRecipient(tiledeskToken, conversationId)
1104
+ .subscribe(
1105
+ (res) => {
1106
+ this.logger.log(
1107
+ '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT RES',
1108
+ res,
1109
+ )
1110
+
1111
+ if (res) {
1112
+ const project_id = res.id_project
1113
+ this.logger.log(
1114
+ '[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT project_id',
1115
+ project_id,
1116
+ )
1117
+ this.archiveSupportGroupConv(
1118
+ tiledeskToken,
1119
+ project_id,
1120
+ conversationId,
1121
+ )
1122
+ }
1123
+ },
1124
+ (error) => {
1125
+ this.logger.error(
1126
+ '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT - ERROR ',
1127
+ error,
1128
+ )
1129
+ },
1130
+ () => {
1131
+ this.logger.log(
1132
+ '[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
1133
+ )
1134
+ },
1135
+ )
900
1136
  }
901
1137
 
902
1138
  archiveSupportGroupConv(tiledeskToken, project_id, conversationId) {
903
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation projectId: ', project_id)
904
- this.tiledeskService.closeSupportGroup(tiledeskToken, project_id, conversationId).subscribe(res => {
905
-
906
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup RES', res);
907
- }, (error) => {
908
- this.logger.error('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR ', error);
909
- }, () => {
910
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup * COMPLETE *');
911
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS ', this.conversations)
912
- this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS LENGHT ', this.conversations.length)
913
- });
914
-
1139
+ this.logger.log(
1140
+ '[CONVS-LIST-PAGE] - onCloseConversation projectId: ',
1141
+ project_id,
1142
+ )
1143
+ this.tiledeskService
1144
+ .closeSupportGroup(tiledeskToken, project_id, conversationId)
1145
+ .subscribe(
1146
+ (res) => {
1147
+ this.archiveActionNotAllowed = false
1148
+ this.logger.log(
1149
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup RES',
1150
+ res,
1151
+ )
1152
+ },
1153
+ (error) => {
1154
+ this.logger.error(
1155
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR ',
1156
+ error,
1157
+ )
1158
+ this.logger.error(
1159
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR error.error.msg ',
1160
+ error.error.msg,
1161
+ )
1162
+ this.logger.error(
1163
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup - ERROR error.status ',
1164
+ error.status,
1165
+ )
1166
+ if (error.error.msg === 'you dont belong to the project.') {
1167
+ this.archiveActionNotAllowed = true
1168
+ }
1169
+ },
1170
+ () => {
1171
+ this.logger.log(
1172
+ '[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup * COMPLETE *',
1173
+ )
1174
+ this.logger.log(
1175
+ '[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS ',
1176
+ this.conversations,
1177
+ )
1178
+ this.logger.log(
1179
+ '[CONVS-LIST-PAGE] - onCloseConversation (closeSupportGroup) CONVS LENGHT ',
1180
+ this.conversations.length,
1181
+ )
1182
+ this.events.publish('conversationhasbeenclosed', conversationId)
1183
+ },
1184
+ )
915
1185
  }
916
1186
 
1187
+ onCloseAlert($event) {
1188
+ this.logger.log('[CONVS-LIST-PAGE] - onCloseAlert ', $event)
1189
+ this.archiveActionNotAllowed = false
1190
+ }
917
1191
 
918
1192
  public generateFake(count: number): Array<number> {
919
- const indexes = [];
1193
+ const indexes = []
920
1194
  for (let i = 0; i < count; i++) {
921
- indexes.push(i);
1195
+ indexes.push(i)
922
1196
  }
923
- return indexes;
1197
+ return indexes
924
1198
  }
925
1199
 
926
1200
  // ------------------------------------------------------------------
@@ -936,7 +1210,6 @@ export class ConversationListPage implements OnInit {
936
1210
  // this.logger.log('[CONVS-LIST-PAGE] openArchivedConversationsPage');
937
1211
  // }
938
1212
 
939
-
940
1213
  // // info page
941
1214
  // returnCloseInfoPage() {
942
1215
  // this.logger.log('[CONVS-LIST-PAGE] returnCloseInfoPage');
@@ -945,7 +1218,6 @@ export class ConversationListPage implements OnInit {
945
1218
 
946
1219
  // }
947
1220
 
948
-
949
1221
  // private navigatePage() {
950
1222
  // this.logger.log('[CONVS-LIST-PAGE] navigatePage:: >>>> conversationSelected ', this.conversationSelected);
951
1223
  // let urlPage = 'detail/';
@@ -966,7 +1238,6 @@ export class ConversationListPage implements OnInit {
966
1238
  // this.navService.openPage(urlPage, ConversationDetailPage, navigationExtras);
967
1239
  // }
968
1240
 
969
-
970
1241
  // openDetailsWithState(conversationSelected) {
971
1242
  // console.log('openDetailsWithState:: >>>> conversationSelected ', conversationSelected);
972
1243
  // let navigationExtras: NavigationExtras = {
@@ -995,8 +1266,6 @@ export class ConversationListPage implements OnInit {
995
1266
  // this.initialize();
996
1267
  // }
997
1268
 
998
-
999
-
1000
1269
  /**
1001
1270
  * ::: conversationsChanged :::
1002
1271
  * evento richiamato su add, change, remove dell'elenco delle conversazioni
@@ -1004,15 +1273,13 @@ export class ConversationListPage implements OnInit {
1004
1273
  * 2 - aggiorno il conto delle nuove conversazioni
1005
1274
  * 4 - se esiste un uidReciverFromUrl (passato nell'url)
1006
1275
  * e se esiste una conversazione con lo stesso id di uidReciverFromUrl
1007
- * imposto questa come conversazione attiva (operazione da fare una sola volta al caricamento delle conversazioni)
1276
+ * imposto questa come conversazione attiva (operazione da fare una sola volta al caricamento delle conversazioni)
1008
1277
  * e la carico nella pagina di dettaglio e azzero la variabile uidReciverFromUrl!!!
1009
1278
  * 5 - altrimenti se esiste una conversazione con lo stesso id della conversazione attiva
1010
- * e la pagina di dettaglio è vuota (placeholder), carico la conversazione attiva (uidConvSelected) nella pagina di dettaglio
1279
+ * e la pagina di dettaglio è vuota (placeholder), carico la conversazione attiva (uidConvSelected) nella pagina di dettaglio
1011
1280
  * (operazione da fare una sola volta al caricamento delle conversazioni)
1012
1281
  */
1013
1282
 
1014
-
1015
-
1016
1283
  // ------------------------------------------------------------------------------------
1017
1284
  // ::: readAllMessages ::: ??????????? SEEMS NOT USED ?????????????????
1018
1285
  // when all chat messages are displayed,