@chat21/chat21-ionic 3.0.59-rc7 → 3.0.60-rc2

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 (68) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +5 -0
  3. package/config.xml +2 -2
  4. package/env.sample +2 -1
  5. package/package.json +1 -1
  6. package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
  7. package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
  8. package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
  9. package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
  10. package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
  11. package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
  12. package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
  13. package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
  14. package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
  15. package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
  16. package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
  17. package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
  18. package/resources/Android/splash.png +0 -0
  19. package/src/app/app.component.scss +10 -5
  20. package/src/app/app.component.ts +356 -230
  21. package/src/app/app.module.ts +12 -7
  22. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
  23. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +3 -5
  24. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
  25. package/src/app/components/authentication/login/login.component.html +8 -8
  26. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +2 -4
  27. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +7 -2
  28. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +57 -39
  29. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +16 -3
  30. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +73 -89
  31. package/src/app/components/ddp-header/ddp-header.component.html +1 -1
  32. package/src/app/components/ddp-header/ddp-header.component.ts +1 -1
  33. package/src/app/components/project-item/project-item.component.html +26 -15
  34. package/src/app/components/project-item/project-item.component.scss +18 -18
  35. package/src/app/components/project-item/project-item.component.ts +76 -42
  36. package/src/app/pages/authentication/login/login.page.html +1 -2
  37. package/src/app/pages/conversation-detail/conversation-detail.module.ts +3 -2
  38. package/src/app/pages/conversation-detail/conversation-detail.page.html +1 -0
  39. package/src/app/pages/conversation-detail/conversation-detail.page.ts +62 -1
  40. package/src/app/pages/conversations-list/conversations-list.page.html +12 -7
  41. package/src/app/pages/conversations-list/conversations-list.page.scss +279 -261
  42. package/src/app/pages/conversations-list/conversations-list.page.ts +142 -15
  43. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +10 -2
  44. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
  45. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +47 -36
  46. package/src/app/services/app-config.ts +77 -5
  47. package/src/app/services/websocket/websocket-js.ts +19 -18
  48. package/src/app/services/websocket/websocket.service.ts +27 -9
  49. package/src/app/shared/shared.module.ts +5 -5
  50. package/src/assets/i18n/en.json +4 -1
  51. package/src/assets/i18n/it.json +4 -1
  52. package/src/assets/js/chat21client.js +144 -82
  53. package/src/assets/logo.png +0 -0
  54. package/src/assets/transparent.png +0 -0
  55. package/src/chat-config-pre-test.json +2 -2
  56. package/src/chat-config-template.json +3 -1
  57. package/src/chat-config.json +3 -2
  58. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
  59. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +1 -1
  60. package/src/chat21-core/providers/firebase/firebase-notifications.ts +31 -23
  61. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
  62. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +3 -5
  63. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
  64. package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
  65. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +12 -3
  66. package/src/chat21-core/utils/utils-message.ts +2 -2
  67. package/src/firebase-messaging-sw-template.js +1 -1
  68. package/src/assets/images/tiledesk_logo_50x50.png +0 -0
@@ -2,7 +2,7 @@ import { URL_SOUND_LIST_CONVERSATION } from './../chat21-core/utils/constants';
2
2
  import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service';
3
3
  import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
4
4
 
5
- import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, } from '@angular/core';
5
+ import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, AfterViewInit, } from '@angular/core';
6
6
  import { Config, Platform, IonRouterOutlet, IonSplitPane, NavController, MenuController, AlertController, IonNav, ToastController } from '@ionic/angular';
7
7
  import { ActivatedRoute, NavigationStart, Router } from '@angular/router';
8
8
  import { Subscription, VirtualTimeScheduler } from 'rxjs';
@@ -57,7 +57,7 @@ import { NetworkService } from './services/network-service/network.service';
57
57
  import * as PACKAGE from 'package.json';
58
58
  import { filter } from 'rxjs/operators'
59
59
  import { WebSocketJs } from './services/websocket/websocket-js';
60
-
60
+ import { Location } from '@angular/common'
61
61
  // import { filter } from 'rxjs/operators';
62
62
 
63
63
  @Component({
@@ -98,7 +98,7 @@ export class AppComponent implements OnInit {
98
98
  public missingConnectionToast: any
99
99
  public executedInitializeAppByWatchConnection: boolean = false;
100
100
  private version: string;
101
-
101
+
102
102
  // private isOnline: boolean = false;
103
103
 
104
104
  wsService: WebSocketJs;
@@ -108,7 +108,7 @@ export class AppComponent implements OnInit {
108
108
  private splashScreen: SplashScreen,
109
109
  private statusBar: StatusBar,
110
110
  private appConfigProvider: AppConfigProvider,
111
- private events: EventsService,
111
+ public events: EventsService,
112
112
  public config: Config,
113
113
  public chatManager: ChatManager,
114
114
  public translate: TranslateService,
@@ -139,86 +139,143 @@ export class AppComponent implements OnInit {
139
139
  // private tiledeskService: TiledeskService,
140
140
  private networkService: NetworkService,
141
141
  public webSocketJs: WebSocketJs,
142
+ public location: Location
142
143
  ) {
143
144
 
144
- // this.saveInStorageChatOpenedTab();
145
- // FOR TEST
146
- // const last_project = { "user_available": true, "number_assigned_requests": 59, "last_login_at": "2021-08-09T17:30:55.234Z", "status": "active", "_id": "6112bc8f58c958003495a2cb", "id_project": { "status": 100, "_id": "60ffe291f725db00347661ef", "name": "27-LUGLIO-21-STRIPE-TEST", "activeOperatingHours": false, "createdBy": "608ad02d3a4dc000344ade17", "profile": { "name": "pro", "trialDays": 30, "agents": 5, "type": "payment", "subStart": "2021-11-18T10:42:41.000Z", "subEnd": "2021-11-19T10:42:41.000Z", "subscriptionId": "sub_Jvf4kABe9t8JvX", "last_stripe_event": "invoice.payment_succeeded" }, "versions": 20115, "channels": [{ "name": "chat21" }], "createdAt": "2021-07-27T10:40:17.752Z", "updatedAt": "2021-11-18T11:55:01.346Z", "__v": 0, "widget": { "preChatForm": true, "preChatFormJson": [{ "name": "userFullname", "type": "text", "mandatory": true, "label": { "en": "Your name", "it": "Il tuo nome" } }, { "name": "userEmail", "type": "text", "mandatory": true, "regex": "/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/", "label": { "en": "Your email", "it": "La tua email" }, "errorLabel": { "en": "Invalid email address", "it": "Indirizzo email non valido" } }, { "name": "tel", "mandatory": true, "label": { "en": "Your phone number", "it": "Il tuo numero di telefono" } }], "preChatFormCustomFieldsEnabled": true }, "trialExpired": true, "trialDaysLeft": 84, "isActiveSubscription": true, "id": "60ffe291f725db00347661ef" }, "id_user": "60aa0fef1482fe00346854a7", "role": "admin", "createdBy": "608ad02d3a4dc000344ade17", "createdAt": "2021-08-10T17:51:11.318Z", "updatedAt": "2021-11-19T08:08:21.437Z", "__v": 0, "presence": { "status": "online", "changedAt": "2021-11-19T08:08:21.432Z" }, "isAuthenticated": true, "id": "6112bc8f58c958003495a2cb" }
147
- // localStorage.setItem('last_project', JSON.stringify(last_project))
145
+
146
+ this.saveInStorageNumberOfOpenedChatTab();
147
+ this.listenChatAlreadyOpenWithoutParamsInMobileMode()
148
+
149
+ // this.listenToUrlChanges();
150
+ // this.getPageState();
148
151
  }
149
- saveInStorageChatOpenedTab() {
150
- // if (+localStorage.tabCount > 0) {
151
- // alert('Already open!');
152
- // } else {
153
- // localStorage.tabCount = 0;
154
- // }
155
152
 
156
- // window.addEventListener('load', (event) => {
157
- // console.log('[CONVS-LIST-PAGE] page is fully loaded', event);
158
- // // let tab = + localStorage.getItem('tab')
159
- // // console.log('[CONVS-LIST-PAGE] page is fully loaded getItem tab', + tab);
160
- // // localStorage.setItem('tab', "1" )
161
- // localStorage.tabCount = +localStorage.tabCount + 1;
162
- // });
163
153
 
164
- // // https://developers.google.com/web/updates/2018/07/page-lifecycle-api#the-beforeunload-event
165
- // const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
166
- // window.addEventListener(terminationEvent, (event) => {
167
- // console.log('[CONVS-LIST-PAGE] page is terminationEvent', event);
168
- // localStorage.tabCount = +localStorage.tabCount - 1;
169
- // }, { capture: true });
170
- const getState = () => {
171
- if (document.visibilityState === 'hidden') {
172
- return 'hidden';
173
- }
174
- if (document.hasFocus()) {
175
- return 'active';
154
+
155
+ listenChatAlreadyOpenWithoutParamsInMobileMode() {
156
+ this.events.subscribe('noparams:mobile', (isAlreadyOpenInMobileMode) => {
157
+ // console.log('[APP-COMP] Chat is Already Open In Mobile Mode ', isAlreadyOpenInMobileMode)
158
+ if (isAlreadyOpenInMobileMode === true) {
159
+ this.checkPlatform()
176
160
  }
177
- return 'passive';
178
- };
161
+ });
162
+ }
179
163
 
180
- let state = getState();
181
- console.log('[CONVS-LIST-PAGE] page state ', state)
182
- if (state === 'hidden') {
183
- localStorage.setItem('hidden', 'true')
184
- }
164
+ // listenToUrlChanges() {
165
+ // const self = this;
166
+ // // window.addEventListener('hashchange', function () {
167
+ // window.addEventListener('locationchange', function () {
185
168
 
186
- const logStateChange = (nextState) => {
187
- const prevState = state;
188
- if (nextState !== prevState) {
189
- console.log(`State change: ${prevState} >>> ${nextState}`);
190
- state = nextState;
191
- }
192
- };
169
+ // console.log('location changed!');
193
170
 
194
- ['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
195
- window.addEventListener(type, () => logStateChange(getState()), { capture: true });
196
- });
171
+ // const convId = getParameterByName('convId')
172
+ // console.log('[APP-COMP] getParameterByName convId ', convId)
173
+ // if (convId) {
174
+ // setTimeout(() => {
175
+ // self.events.publish('supportconvid:haschanged', convId);
176
+ // }, 0);
177
+ // }
197
178
 
198
- // The next two listeners, on the other hand, can determine the next
199
- // state from the event itself.
200
- window.addEventListener('freeze', () => {
201
- // In the freeze event, the next state is always frozen.
202
- logStateChange('frozen');
203
- }, { capture: true });
179
+ // const contact_id = getParameterByName('contact_id')
180
+ // console.log('[APP-COMP] getParameterByName contact_id ', contact_id)
181
+ // const contact_fullname = getParameterByName('contact_fullname')
182
+ // console.log('[APP-COMP] getParameterByName contact_fullname ', contact_fullname)
183
+ // if (contact_id && contact_fullname) {
184
+ // setTimeout(() => {
185
+ // self.router.navigateByUrl('conversation-detail/' + contact_id + '/' + contact_fullname + '/new');
186
+ // self.events.publish('directconvid:haschanged', contact_id);
187
+ // }, 0);
188
+
189
+ // } else {
190
+ // // console.log('[APP-COMP] contact_id and contact_fullname are null')
191
+ // }
204
192
 
205
- window.addEventListener('pagehide', (event) => {
206
- if (event.persisted) {
207
- // If the event's persisted property is `true` the page is about
208
- // to enter the Back-Forward Cache, which is also in the frozen state.
209
- logStateChange('frozen');
210
- localStorage.setItem('terminated', 'true')
211
- } else {
212
- // If the event's persisted property is not `true` the page is
213
- // about to be unloaded.
214
- logStateChange('terminated');
215
- localStorage.setItem('terminated', 'true')
193
+ // const conversation_detail = getParameterByName('conversation_detail')
194
+ // // console.log('[APP-COMP] getParameterByName conversation_detail ', conversation_detail)
195
+ // if (conversation_detail) {
196
+ // setTimeout(() => {
197
+ // self.router.navigate(['conversation-detail/'])
198
+ // }, 0);
199
+ // }
200
+ // });
201
+ // }
202
+
203
+ // getPageState() {
204
+ // const getState = () => {
205
+
206
+ // console.log('[APP-COMP] getState')
207
+ // // localStorage.setItem('visibilityState', document.visibilityState)
208
+ // if (document.visibilityState === 'hidden') {
209
+ // return 'hidden';
210
+ // }
211
+ // if (document.hasFocus()) {
212
+ // return 'active';
213
+ // }
214
+ // return 'passive';
215
+ // };
216
+
217
+ // let state = getState();
218
+
219
+ // const logStateChange = (nextState) => {
220
+
221
+ // const prevState = state;
222
+ // if (nextState !== prevState) {
223
+ // console.log(`State change: ${prevState} >>> ${nextState}`);
224
+ // state = nextState;
225
+
226
+ // }
227
+ // };
228
+
229
+ // ['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
230
+ // window.addEventListener(type, () => logStateChange(getState()), { capture: true });
231
+ // });
232
+
233
+ // // The next two listeners, on the other hand, can determine the next
234
+ // // state from the event itself.
235
+ // window.addEventListener('freeze', () => {
236
+ // // In the freeze event, the next state is always frozen.
237
+ // logStateChange('frozen');
238
+ // }, { capture: true });
239
+
240
+ // window.addEventListener('pagehide', (event) => {
241
+ // if (event.persisted) {
242
+ // // If the event's persisted property is `true` the page is about
243
+ // // to enter the Back-Forward Cache, which is also in the frozen state.
244
+ // logStateChange('frozen');
245
+ // localStorage.setItem('state', 'frozen')
246
+ // } else {
247
+ // // If the event's persisted property is not `true` the page is
248
+ // // about to be unloaded.
249
+ // logStateChange('terminated');
250
+ // localStorage.setItem('state', 'terminated')
251
+ // localStorage.setItem('terminated', 'true')
252
+ // }
253
+ // }, { capture: true });
254
+
255
+ // }
256
+
257
+
258
+ saveInStorageNumberOfOpenedChatTab() {
259
+ this.logger.log('Calling saveInStorageChatOpenedTab!');
260
+
261
+ // https://jsfiddle.net/jjjs5wd3/3/å
262
+ if (+localStorage.tabCount > 0) {
263
+ this.logger.log('Chat IONIC Already open!');
264
+ } else {
265
+ localStorage.tabCount = 0;
266
+
267
+ localStorage.tabCount = +localStorage.tabCount + 1;
268
+ }
269
+ const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
270
+ window.addEventListener(terminationEvent, (event) => {
271
+ if (localStorage.tabCount > 0) {
272
+ localStorage.tabCount = +localStorage.tabCount - 1;
216
273
  }
217
274
  }, { capture: true });
218
-
219
275
  }
220
276
 
221
277
 
278
+
222
279
  // param() {
223
280
  // // PARAM
224
281
  // const url: URL = new URL(window.top.location.href);
@@ -252,16 +309,16 @@ export class AppComponent implements OnInit {
252
309
  this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN the current user already exist DON\'T SAVE ')
253
310
  }
254
311
  }
255
- this.initializeApp('oninit');
256
312
 
313
+
314
+ this.initializeApp('oninit');
257
315
  this.listenToPostMsgs();
258
316
  }
259
317
 
260
318
 
261
-
262
319
  listenToPostMsgs() {
263
320
  window.addEventListener("message", (event) => {
264
- // console.log("[APP-COMP] message event ", event);
321
+ this.logger.log("[APP-COMP] message event ", event);
265
322
 
266
323
  if (event && event.data && event.data.action && event.data.parameter) {
267
324
  if (event.data.action === 'openJoinConversationModal') {
@@ -270,6 +327,18 @@ export class AppComponent implements OnInit {
270
327
  this.presentAlertConfirmJoinRequest(event.data.parameter, event.data.calledBy)
271
328
  }
272
329
  }
330
+ // if (event && event.data && event.data.action && event.data.parameter) {
331
+ // if (event.data.action === 'hasArchived') {
332
+ // var iframeWin = <HTMLIFrameElement>document.getElementById("unassigned-convs-iframe")
333
+ // const isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
334
+ // input !== null && input.tagName === 'IFRAME';
335
+ // if (isIFrame(iframeWin) && iframeWin.contentWindow) {
336
+ // const msg = { action: "hasArchived", parameter: event.data.parameter, calledBy: event.data.calledBy }
337
+ // iframeWin.contentWindow.postMessage(msg, '*');
338
+ // }
339
+
340
+ // }
341
+ // }
273
342
  if (event && event.data && event.data.action && event.data.text) {
274
343
  if (event.data.action === "display_toast_join_complete") {
275
344
  this.presentToastJoinComplete(event.data.text)
@@ -345,11 +414,11 @@ export class AppComponent implements OnInit {
345
414
  /** */
346
415
  initializeApp(calledby: string) {
347
416
  // this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
348
- // this.logger.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
417
+ // console.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
349
418
 
350
- if (!this.platform.is('cordova')) {
351
- this.splashScreen.show();
352
- }
419
+ // if (!this.platform.is('cordova')) {
420
+ this.splashScreen.show();
421
+ // }
353
422
  this.tabTitle = document.title;
354
423
 
355
424
  this.getRouteParamsAndSetLoggerConfig();
@@ -367,12 +436,18 @@ export class AppComponent implements OnInit {
367
436
  this.notificationsEnabled = true;
368
437
  this.zone = new NgZone({}); // a cosa serve?
369
438
 
439
+ // ------------------------------------------
440
+ // Platform ready
441
+ // ------------------------------------------
370
442
  this.platform.ready().then(() => {
443
+ // console.log("Check platform");
444
+ this.getPlatformName();
445
+
371
446
  this.setLanguage();
372
447
 
373
- if (this.splashScreen) {
374
- this.splashScreen.hide();
375
- }
448
+ // if (this.splashScreen) {
449
+ this.splashScreen.hide();
450
+ // }
376
451
  this.statusBar.styleDefault();
377
452
  this.navService.init(this.sidebarNav, this.detailNav);
378
453
  // this.persistence = appconfig.authPersistence;
@@ -408,6 +483,59 @@ export class AppComponent implements OnInit {
408
483
  });
409
484
  }
410
485
 
486
+ getPlatformName() {
487
+ if (this.platform.is('cordova')) {
488
+ this.logger.log("the device running Cordova");
489
+ }
490
+ if (!this.platform.is('cordova')) {
491
+ this.logger.log("the device Not running Cordova");
492
+ }
493
+
494
+ if (this.platform.is('android')) {
495
+ this.logger.log("running on Android device!");
496
+ }
497
+ if (this.platform.is('ios')) {
498
+ this.logger.log("running on iOS device!");
499
+ }
500
+ if (this.platform.is('mobileweb')) {
501
+ this.logger.log("running in a browser on mobile!");
502
+ }
503
+ if (this.platform.is('desktop')) {
504
+ this.logger.log("running on desktop!");
505
+ }
506
+ }
507
+
508
+
509
+ getRouteParamsAndSetLoggerConfig() {
510
+ const appconfig = this.appConfigProvider.getConfig();
511
+ this.route.queryParams.subscribe(params => {
512
+ // this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
513
+ if (params.logLevel) {
514
+ this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
515
+ this.logger.setLoggerConfig(true, params.logLevel)
516
+ } else {
517
+ this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from appconfig: ', appconfig.logLevel)
518
+ this.logger.setLoggerConfig(true, appconfig.logLevel)
519
+ }
520
+ });
521
+ }
522
+
523
+ /** */
524
+ setLanguage() {
525
+ this.translate.setDefaultLang('en');
526
+ this.translate.use('en');
527
+ this.logger.debug('[APP-COMP] navigator.language: ', navigator.language);
528
+ let language;
529
+ if (navigator.language.indexOf('-') !== -1) {
530
+ language = navigator.language.substring(0, navigator.language.indexOf('-'));
531
+ } else if (navigator.language.indexOf('_') !== -1) {
532
+ language = navigator.language.substring(0, navigator.language.indexOf('_'));
533
+ } else {
534
+ language = navigator.language;
535
+ }
536
+ this.translate.use(language);
537
+ }
538
+
411
539
 
412
540
  watchToConnectionStatus() {
413
541
  this.networkService.checkInternetFunc().subscribe(isOnline => {
@@ -461,21 +589,6 @@ export class AppComponent implements OnInit {
461
589
  }
462
590
 
463
591
 
464
- getRouteParamsAndSetLoggerConfig() {
465
- const appconfig = this.appConfigProvider.getConfig();
466
- this.route.queryParams.subscribe(params => {
467
- // this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
468
- if (params.logLevel) {
469
- this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
470
- this.logger.setLoggerConfig(true, params.logLevel)
471
- } else {
472
- this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from appconfig: ', appconfig.logLevel)
473
- this.logger.setLoggerConfig(true, appconfig.logLevel)
474
- }
475
- });
476
- }
477
-
478
-
479
592
  translateToastMsgs() {
480
593
  this.translate.get('AnErrorOccurredWhileUnsubscribingFromNotifications')
481
594
  .subscribe((text: string) => {
@@ -530,116 +643,14 @@ export class AppComponent implements OnInit {
530
643
  // }
531
644
  // }
532
645
 
533
- connetWebsocket(tiledeskToken) {
534
- const appconfig = this.appConfigProvider.getConfig();
535
- this.logger.log('connetWebsocket appconfig wsUrl ', appconfig.wsUrl)
536
- const WS_URL = appconfig.wsUrl + '?token=' + tiledeskToken
537
- this.webSocketJs.init(
538
- WS_URL,
539
- undefined,
540
- undefined,
541
- undefined
542
- );
543
- }
544
-
545
- /**
546
- * goOnLine:
547
- * 1 - nascondo splashscreen
548
- * 2 - recupero il tiledeskToken e lo salvo in chat manager
549
- * 3 - carico in d
550
- * @param user
551
- */
552
- goOnLine = () => {
553
- // this.isOnline = true;
554
- // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
555
-
556
- // clearTimeout(this.timeModalLogin);
557
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
558
- this.connetWebsocket(tiledeskToken)
559
-
560
- const currentUser = this.tiledeskAuthService.getCurrentUser();
561
- // this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
562
- this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
563
- this.chatManager.setTiledeskToken(tiledeskToken);
564
- this.chatManager.setCurrentUser(currentUser);
565
- // ----------------------------------------------
566
- // PUSH NOTIFICATIONS
567
- // ----------------------------------------------
568
- const pushEngine = this.appConfigProvider.getConfig().pushEngine
569
-
570
- if (currentUser) {
571
- if (pushEngine && pushEngine !== 'none') {
572
- this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
573
- }
574
- this.presenceService.setPresence(currentUser.uid);
575
-
576
- this.initConversationsHandler(currentUser.uid);
577
- this.initArchivedConversationsHandler(currentUser.uid);
578
- }
579
- this.checkPlatform();
580
- try {
581
- this.logger.debug('[APP-COMP] ************** closeModal', this.authModal);
582
- if (this.authModal) {
583
- this.closeModal();
584
- }
585
- } catch (err) {
586
- this.logger.error('[APP-COMP] -> error:', err);
587
- }
588
- this.chatManager.startApp();
589
- }
590
-
591
646
 
592
- webSocketClose() {
593
- this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
594
- this.webSocketJs.close()
595
- }
596
-
597
- goOffLine = () => {
598
- this.logger.log('[APP-COMP] - GO-OFFLINE');
599
-
600
- this.webSocketClose()
601
- // this.isOnline = false;
602
- // this.conversationsHandlerService.conversations = [];
603
-
604
- this.chatManager.setTiledeskToken(null);
605
- this.chatManager.setCurrentUser(null);
606
- this.chatManager.goOffLine();
607
-
608
- this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
609
-
610
- // clearTimeout(this.timeModalLogin);
611
- // this.timeModalLogin = setTimeout(() => {
612
- if (!this.hadBeenCalledOpenModal) {
613
- this.authModal = this.presentModal('goOffLine');
614
- this.hadBeenCalledOpenModal = true
615
- }
616
- // }, 1000);
617
-
618
- // this.unsubscribe$.next();
619
- // this.unsubscribe$.complete();
620
-
621
- }
622
647
  /**------- AUTHENTICATION FUNCTIONS --> END <--- +*/
623
648
  /***************************************************+*/
624
649
 
625
- /** */
626
- setLanguage() {
627
- this.translate.setDefaultLang('en');
628
- this.translate.use('en');
629
- this.logger.debug('[APP-COMP] navigator.language: ', navigator.language);
630
- let language;
631
- if (navigator.language.indexOf('-') !== -1) {
632
- language = navigator.language.substring(0, navigator.language.indexOf('-'));
633
- } else if (navigator.language.indexOf('_') !== -1) {
634
- language = navigator.language.substring(0, navigator.language.indexOf('_'));
635
- } else {
636
- language = navigator.language;
637
- }
638
- this.translate.use(language);
639
- }
650
+
640
651
 
641
652
  checkPlatform() {
642
- this.logger.debug('[APP-COMP] checkPlatform');
653
+ // console.log('[APP-COMP] checkPlatform');
643
654
  // let pageUrl = '';
644
655
  // try {
645
656
  // const pathPage = this.route.snapshot.firstChild.routeConfig.path;
@@ -655,21 +666,31 @@ export class AppComponent implements OnInit {
655
666
  // }
656
667
 
657
668
  if (checkPlatformIsMobile()) {
669
+ this.chatManager.startApp();
670
+
671
+ this.logger.log('[APP-COMP] checkPlatformIsMobile', checkPlatformIsMobile());
658
672
  this.platformIs = PLATFORM_MOBILE;
659
673
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
660
- this.logger.log('[APP-COMP] PLATFORM_MOBILE2 navigateByUrl', PLATFORM_MOBILE, this.route.snapshot);
674
+
675
+ // console.log('[APP-COMP] platformIs', this.platformIs);
676
+ // console.log('[APP-COMP] PLATFORM', PLATFORM_MOBILE, 'route.snapshot', this.route.snapshot);
661
677
  if (!IDConv) {
662
678
  this.router.navigateByUrl('conversations-list')
663
679
  }
664
680
  // this.router.navigateByUrl(pageUrl);
665
681
  // this.navService.setRoot(ConversationListPage, {});
666
682
  } else {
683
+ this.chatManager.startApp();
684
+ this.logger.log('[APP-COMP] checkPlatformIsMobile', checkPlatformIsMobile());
667
685
  this.platformIs = PLATFORM_DESKTOP;
686
+ // console.log('[APP-COMP] platformIs', this.platformIs);
687
+ // console.log('[APP-COMP] PLATFORM', PLATFORM_DESKTOP, 'route.snapshot', this.route.snapshot);
668
688
  this.logger.log('[APP-COMP] PLATFORM_DESKTOP ', this.navService);
669
689
 
670
690
  this.navService.setRoot(ConversationListPage, {});
671
691
 
672
692
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
693
+
673
694
  const FullNameConv = this.route.snapshot.firstChild.paramMap.get('FullNameConv');
674
695
  const Convtype = this.route.snapshot.firstChild.paramMap.get('Convtype');
675
696
 
@@ -704,16 +725,23 @@ export class AppComponent implements OnInit {
704
725
  }
705
726
 
706
727
  private initAudio() {
728
+ // console.log('HERE IS initAudio ')
707
729
  // SET AUDIO
730
+ const href = window.location.href;
731
+ const hrefArray = href.split('/#/');
732
+ const chatBaseUrl = hrefArray[0]
733
+ // console.log('initAudio href', href)
734
+ // console.log('initAudio chatBaseUrl', chatBaseUrl)
735
+
708
736
  this.audio = new Audio();
709
- this.audio.src = URL_SOUND_LIST_CONVERSATION;
737
+ this.audio.src = chatBaseUrl + URL_SOUND_LIST_CONVERSATION;
710
738
  this.audio.load();
711
739
  }
712
740
 
713
741
  private manageTabNotification() {
714
742
  if (!this.isTabVisible) {
715
743
  // TAB IS HIDDEN --> manage title and SOUND
716
-
744
+ // console.log('HERE IS manageTabNotification ')
717
745
  let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
718
746
  badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
719
747
  document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
@@ -732,6 +760,7 @@ export class AppComponent implements OnInit {
732
760
  }
733
761
 
734
762
  soundMessage() {
763
+ // console.log('HERE IS soundMessage ')
735
764
  const that = this;
736
765
  // this.audio = new Audio();
737
766
  // // this.audio.src = '/assets/sounds/pling.mp3';
@@ -743,7 +772,7 @@ export class AppComponent implements OnInit {
743
772
  that.audio.play().then(() => {
744
773
  that.logger.debug('[APP-COMP] ****** soundMessage played *****');
745
774
  }).catch((error: any) => {
746
- that.logger.debug('[APP-COMP] ***soundMessage error*', error);
775
+ that.logger.error('[APP-COMP] ***soundMessage error*', error);
747
776
  });
748
777
  }, 1000);
749
778
  }
@@ -758,7 +787,6 @@ export class AppComponent implements OnInit {
758
787
  initSubscriptions() {
759
788
  this.logger.log('initialize FROM [APP-COMP] - initSubscriptions');
760
789
 
761
-
762
790
  // ---------------------------------------------------------------------------------------------------
763
791
  // Protecting from multiple subsciptions due to multiple app initializations (call to initializeApp())
764
792
  // Only one subscriber x application allowed
@@ -774,7 +802,7 @@ export class AppComponent implements OnInit {
774
802
  .pipe(filter((state) => state !== null))
775
803
  .subscribe((state: any) => {
776
804
  this.logger.log('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged state', state);
777
- // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged isOnline', this.isOnline);
805
+
778
806
  if (state && state === AUTH_STATE_ONLINE) {
779
807
  // const user = this.tiledeskAuthService.getCurrentUser();
780
808
  // if (this.isOnline === false) {
@@ -806,7 +834,7 @@ export class AppComponent implements OnInit {
806
834
 
807
835
  this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
808
836
 
809
- this.logger.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
837
+ // console.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
810
838
  const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
811
839
  this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
812
840
 
@@ -819,6 +847,128 @@ export class AppComponent implements OnInit {
819
847
  });
820
848
  }
821
849
 
850
+ /**
851
+ * goOnLine:
852
+ * 1 - nascondo splashscreen
853
+ * 2 - recupero il tiledeskToken e lo salvo in chat manager
854
+ * 3 - carico in d
855
+ * @param user
856
+ */
857
+ goOnLine = () => {
858
+ this.logger.log('[APP-COMP]- GO-ONLINE ');
859
+ // this.isOnline = true;
860
+ // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
861
+ // clearTimeout(this.timeModalLogin);
862
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
863
+
864
+ // const supportmode = this.appConfigProvider.getConfig().supportMode;
865
+ // this.logger.log('[APP-COMP] - GO-ONLINE - supportmode ', supportmode);
866
+ // if (supportmode === true) {
867
+ // this.connetWebsocket() // moved in the comp project-item
868
+ // }
869
+ this.events.publish('go:online', true);
870
+ const currentUser = this.tiledeskAuthService.getCurrentUser();
871
+ // this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
872
+ this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
873
+ this.chatManager.setTiledeskToken(tiledeskToken);
874
+ this.chatManager.setCurrentUser(currentUser);
875
+ // this.chatManager.startApp();
876
+
877
+ // ----------------------------------------------
878
+ // PUSH NOTIFICATIONS
879
+ // ----------------------------------------------
880
+ const pushEngine = this.appConfigProvider.getConfig().pushEngine
881
+
882
+ if (currentUser) {
883
+ if (pushEngine && pushEngine !== 'none') {
884
+ this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
885
+ }
886
+ this.presenceService.setPresence(currentUser.uid);
887
+
888
+ this.initConversationsHandler(currentUser.uid);
889
+ this.initArchivedConversationsHandler(currentUser.uid);
890
+ }
891
+ this.checkPlatform();
892
+ try {
893
+ this.logger.debug('[APP-COMP] ************** closeModal', this.authModal);
894
+ if (this.authModal) {
895
+ this.closeModal();
896
+ }
897
+ } catch (err) {
898
+ this.logger.error('[APP-COMP] -> error:', err);
899
+ }
900
+ }
901
+
902
+
903
+
904
+
905
+ goOffLine = () => {
906
+ this.logger.log('[APP-COMP] - GO-OFFLINE');
907
+ const supportmode = this.appConfigProvider.getConfig().supportMode;
908
+ this.logger.log('[APP-COMP] - GO-OFFINE - supportmode ', supportmode);
909
+ if (supportmode === true) {
910
+ this.webSocketClose()
911
+ }
912
+ // this.isOnline = false;
913
+ // this.conversationsHandlerService.conversations = [];
914
+ this.chatManager.setTiledeskToken(null);
915
+ this.chatManager.setCurrentUser(null);
916
+ this.chatManager.goOffLine();
917
+
918
+ this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
919
+
920
+ // clearTimeout(this.timeModalLogin);
921
+ // this.timeModalLogin = setTimeout(() => {
922
+ if (!this.hadBeenCalledOpenModal) {
923
+ this.authModal = this.presentModal('goOffLine');
924
+ this.hadBeenCalledOpenModal = true
925
+ }
926
+ // }, 1000);
927
+
928
+ // this.unsubscribe$.next();
929
+ // this.unsubscribe$.complete();
930
+
931
+ }
932
+
933
+
934
+ webSocketClose() {
935
+ this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
936
+ this.webSocketJs.close()
937
+ this.events.publish('go:offline', true);
938
+ }
939
+
940
+ // BEGIN RESIZE FUNCTIONS //
941
+ @HostListener('window:resize', ['$event'])
942
+ onResize(event: any) {
943
+ const that = this;
944
+ // this.logger.debug('this.doitResize)', this.doitResize)
945
+ // clearTimeout(this.doitResize);
946
+ // this.doitResize = setTimeout(() => {
947
+ let platformIsNow = PLATFORM_DESKTOP;
948
+ if (checkPlatformIsMobile()) {
949
+ platformIsNow = PLATFORM_MOBILE;
950
+ }
951
+ if (!this.platformIs || this.platformIs === '') {
952
+ this.platformIs = platformIsNow;
953
+ }
954
+ this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
955
+ this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
956
+ this.logger.debug('[APP-COMP] onResize width:::: this.platformIs', this.platformIs);
957
+ this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
958
+ if (platformIsNow !== this.platformIs) {
959
+ window.location.reload();
960
+ // this.checkPlatform();
961
+ // this.initializeApp('onresize')
962
+ this.checkPlatform();
963
+ // this.goOnLine()
964
+ // // this.initSubscriptions();
965
+
966
+ }
967
+
968
+ // }, 0);
969
+ }
970
+ // END RESIZE FUNCTIONS //
971
+
822
972
  /**
823
973
  * ::: subscribeChangedConversationSelected :::
824
974
  * evento richiamato quando si seleziona un utente nell'elenco degli user
@@ -853,9 +1003,8 @@ export class AppComponent implements OnInit {
853
1003
  that.removePresenceAndLogout();
854
1004
  // that.presentToast();
855
1005
  }
856
- })
1006
+ });
857
1007
  }
858
-
859
1008
  }
860
1009
  }
861
1010
 
@@ -973,29 +1122,6 @@ export class AppComponent implements OnInit {
973
1122
  this.archivedConversationsHandlerService.initialize(this.tenant, userId, translationMap);
974
1123
  }
975
1124
 
976
- // BEGIN RESIZE FUNCTIONS //
977
- @HostListener('window:resize', ['$event'])
978
- onResize(event: any) {
979
- const that = this;
980
- // this.logger.debug('this.doitResize)', this.doitResize)
981
- clearTimeout(this.doitResize);
982
- this.doitResize = setTimeout(() => {
983
- let platformIsNow = PLATFORM_DESKTOP;
984
- if (checkPlatformIsMobile()) {
985
- platformIsNow = PLATFORM_MOBILE;
986
- }
987
- if (!this.platformIs || this.platformIs === '') {
988
- this.platformIs = platformIsNow;
989
- }
990
- this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
991
- this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
992
- this.logger.debug('[APP-COMP] onResize width:::: platformIsNow this.platformIs', this.platformIs);
993
- if (platformIsNow !== this.platformIs) {
994
- window.location.reload();
995
- }
996
- }, 500);
997
- }
998
- // END RESIZE FUNCTIONS //
999
1125
 
1000
1126
  @HostListener('document:visibilitychange', [])
1001
1127
  visibilitychange() {
@@ -1015,7 +1141,7 @@ export class AppComponent implements OnInit {
1015
1141
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
1016
1142
  @HostListener('window:storage', ['$event'])
1017
1143
  onStorageChanged(event: any) {
1018
-
1144
+
1019
1145
  if (event.key !== 'chat_sv5__tiledeskToken') {
1020
1146
  return;
1021
1147
  }