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

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