@chat21/chat21-ionic 3.0.59-rc5 → 3.0.60-rc1

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 (69) hide show
  1. package/CHANGELOG.md +89 -1
  2. package/README.md +5 -0
  3. package/config.xml +2 -2
  4. package/env.sample +3 -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 +358 -233
  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 +8 -7
  24. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +2 -1
  25. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
  26. package/src/app/components/authentication/login/login.component.html +8 -8
  27. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +2 -4
  28. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +7 -2
  29. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +57 -39
  30. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +16 -3
  31. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +73 -89
  32. package/src/app/components/ddp-header/ddp-header.component.html +1 -1
  33. package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
  34. package/src/app/components/project-item/project-item.component.html +61 -16
  35. package/src/app/components/project-item/project-item.component.scss +165 -38
  36. package/src/app/components/project-item/project-item.component.ts +88 -46
  37. package/src/app/pages/authentication/login/login.page.html +1 -2
  38. package/src/app/pages/conversation-detail/conversation-detail.module.ts +3 -2
  39. package/src/app/pages/conversation-detail/conversation-detail.page.html +1 -0
  40. package/src/app/pages/conversation-detail/conversation-detail.page.ts +62 -1
  41. package/src/app/pages/conversations-list/conversations-list.page.html +12 -7
  42. package/src/app/pages/conversations-list/conversations-list.page.scss +279 -261
  43. package/src/app/pages/conversations-list/conversations-list.page.ts +152 -18
  44. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +10 -2
  45. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
  46. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +47 -36
  47. package/src/app/services/app-config.ts +77 -5
  48. package/src/app/services/websocket/websocket-js.ts +19 -18
  49. package/src/app/services/websocket/websocket.service.ts +27 -9
  50. package/src/app/shared/shared.module.ts +5 -5
  51. package/src/assets/i18n/en.json +4 -1
  52. package/src/assets/i18n/it.json +4 -1
  53. package/src/assets/js/chat21client.js +144 -82
  54. package/src/assets/logo.png +0 -0
  55. package/src/assets/transparent.png +0 -0
  56. package/src/chat-config-pre-test.json +3 -1
  57. package/src/chat-config-template.json +4 -1
  58. package/src/chat-config.json +4 -1
  59. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
  60. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +1 -1
  61. package/src/chat21-core/providers/firebase/firebase-notifications.ts +31 -23
  62. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
  63. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +3 -5
  64. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
  65. package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
  66. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +12 -3
  67. package/src/chat21-core/utils/utils-message.ts +2 -2
  68. package/src/firebase-messaging-sw-template.js +1 -1
  69. 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,24 +309,36 @@ 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') {
268
- console.log("[APP-COMP] message event action ", event.data.action);
269
- console.log("[APP-COMP] message event parameter ", event.data.parameter);
325
+ // console.log("[APP-COMP] message event action ", event.data.action);
326
+ // console.log("[APP-COMP] message event parameter ", event.data.parameter);
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,114 +643,14 @@ export class AppComponent implements OnInit {
530
643
  // }
531
644
  // }
532
645
 
533
- connetWebsocket(tiledeskToken) {
534
- const WS_URL = 'wss://tiledesk-server-pre.herokuapp.com/' + '?token=' + tiledeskToken
535
- this.webSocketJs.init(
536
- WS_URL,
537
- undefined,
538
- undefined,
539
- undefined
540
- );
541
- }
542
-
543
- /**
544
- * goOnLine:
545
- * 1 - nascondo splashscreen
546
- * 2 - recupero il tiledeskToken e lo salvo in chat manager
547
- * 3 - carico in d
548
- * @param user
549
- */
550
- goOnLine = () => {
551
- // this.isOnline = true;
552
- // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
553
-
554
- // clearTimeout(this.timeModalLogin);
555
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
556
- this.connetWebsocket(tiledeskToken)
557
-
558
- const currentUser = this.tiledeskAuthService.getCurrentUser();
559
- // this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
560
- this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
561
- this.chatManager.setTiledeskToken(tiledeskToken);
562
- this.chatManager.setCurrentUser(currentUser);
563
- // ----------------------------------------------
564
- // PUSH NOTIFICATIONS
565
- // ----------------------------------------------
566
- const pushEngine = this.appConfigProvider.getConfig().pushEngine
567
-
568
- if (currentUser) {
569
- if (pushEngine && pushEngine !== 'none') {
570
- this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
571
- }
572
- this.presenceService.setPresence(currentUser.uid);
573
-
574
- this.initConversationsHandler(currentUser.uid);
575
- this.initArchivedConversationsHandler(currentUser.uid);
576
- }
577
- this.checkPlatform();
578
- try {
579
- this.logger.debug('[APP-COMP] ************** closeModal', this.authModal);
580
- if (this.authModal) {
581
- this.closeModal();
582
- }
583
- } catch (err) {
584
- this.logger.error('[APP-COMP] -> error:', err);
585
- }
586
- this.chatManager.startApp();
587
- }
588
-
589
-
590
- webSocketClose() {
591
- this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
592
- this.webSocketJs.close()
593
- }
594
-
595
- goOffLine = () => {
596
- this.logger.log('[APP-COMP] - GO-OFFLINE');
597
-
598
- this.webSocketClose()
599
- // this.isOnline = false;
600
- // this.conversationsHandlerService.conversations = [];
601
-
602
- this.chatManager.setTiledeskToken(null);
603
- this.chatManager.setCurrentUser(null);
604
- this.chatManager.goOffLine();
605
-
606
- this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
607
-
608
- // clearTimeout(this.timeModalLogin);
609
- // this.timeModalLogin = setTimeout(() => {
610
- if (!this.hadBeenCalledOpenModal) {
611
- this.authModal = this.presentModal('goOffLine');
612
- this.hadBeenCalledOpenModal = true
613
- }
614
- // }, 1000);
615
-
616
- // this.unsubscribe$.next();
617
- // this.unsubscribe$.complete();
618
646
 
619
- }
620
647
  /**------- AUTHENTICATION FUNCTIONS --> END <--- +*/
621
648
  /***************************************************+*/
622
649
 
623
- /** */
624
- setLanguage() {
625
- this.translate.setDefaultLang('en');
626
- this.translate.use('en');
627
- this.logger.debug('[APP-COMP] navigator.language: ', navigator.language);
628
- let language;
629
- if (navigator.language.indexOf('-') !== -1) {
630
- language = navigator.language.substring(0, navigator.language.indexOf('-'));
631
- } else if (navigator.language.indexOf('_') !== -1) {
632
- language = navigator.language.substring(0, navigator.language.indexOf('_'));
633
- } else {
634
- language = navigator.language;
635
- }
636
- this.translate.use(language);
637
- }
650
+
638
651
 
639
652
  checkPlatform() {
640
- this.logger.debug('[APP-COMP] checkPlatform');
653
+ // console.log('[APP-COMP] checkPlatform');
641
654
  // let pageUrl = '';
642
655
  // try {
643
656
  // const pathPage = this.route.snapshot.firstChild.routeConfig.path;
@@ -653,21 +666,31 @@ export class AppComponent implements OnInit {
653
666
  // }
654
667
 
655
668
  if (checkPlatformIsMobile()) {
669
+ this.chatManager.startApp();
670
+
671
+ this.logger.log('[APP-COMP] checkPlatformIsMobile', checkPlatformIsMobile());
656
672
  this.platformIs = PLATFORM_MOBILE;
657
673
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
658
- 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);
659
677
  if (!IDConv) {
660
678
  this.router.navigateByUrl('conversations-list')
661
679
  }
662
680
  // this.router.navigateByUrl(pageUrl);
663
681
  // this.navService.setRoot(ConversationListPage, {});
664
682
  } else {
683
+ this.chatManager.startApp();
684
+ this.logger.log('[APP-COMP] checkPlatformIsMobile', checkPlatformIsMobile());
665
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);
666
688
  this.logger.log('[APP-COMP] PLATFORM_DESKTOP ', this.navService);
667
689
 
668
690
  this.navService.setRoot(ConversationListPage, {});
669
691
 
670
692
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
693
+
671
694
  const FullNameConv = this.route.snapshot.firstChild.paramMap.get('FullNameConv');
672
695
  const Convtype = this.route.snapshot.firstChild.paramMap.get('Convtype');
673
696
 
@@ -702,16 +725,23 @@ export class AppComponent implements OnInit {
702
725
  }
703
726
 
704
727
  private initAudio() {
728
+ // console.log('HERE IS initAudio ')
705
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
+
706
736
  this.audio = new Audio();
707
- this.audio.src = URL_SOUND_LIST_CONVERSATION;
737
+ this.audio.src = chatBaseUrl + URL_SOUND_LIST_CONVERSATION;
708
738
  this.audio.load();
709
739
  }
710
740
 
711
741
  private manageTabNotification() {
712
742
  if (!this.isTabVisible) {
713
743
  // TAB IS HIDDEN --> manage title and SOUND
714
-
744
+ // console.log('HERE IS manageTabNotification ')
715
745
  let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
716
746
  badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
717
747
  document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
@@ -730,6 +760,7 @@ export class AppComponent implements OnInit {
730
760
  }
731
761
 
732
762
  soundMessage() {
763
+ // console.log('HERE IS soundMessage ')
733
764
  const that = this;
734
765
  // this.audio = new Audio();
735
766
  // // this.audio.src = '/assets/sounds/pling.mp3';
@@ -741,7 +772,7 @@ export class AppComponent implements OnInit {
741
772
  that.audio.play().then(() => {
742
773
  that.logger.debug('[APP-COMP] ****** soundMessage played *****');
743
774
  }).catch((error: any) => {
744
- that.logger.debug('[APP-COMP] ***soundMessage error*', error);
775
+ that.logger.error('[APP-COMP] ***soundMessage error*', error);
745
776
  });
746
777
  }, 1000);
747
778
  }
@@ -756,7 +787,6 @@ export class AppComponent implements OnInit {
756
787
  initSubscriptions() {
757
788
  this.logger.log('initialize FROM [APP-COMP] - initSubscriptions');
758
789
 
759
-
760
790
  // ---------------------------------------------------------------------------------------------------
761
791
  // Protecting from multiple subsciptions due to multiple app initializations (call to initializeApp())
762
792
  // Only one subscriber x application allowed
@@ -772,7 +802,7 @@ export class AppComponent implements OnInit {
772
802
  .pipe(filter((state) => state !== null))
773
803
  .subscribe((state: any) => {
774
804
  this.logger.log('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged state', state);
775
- // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged isOnline', this.isOnline);
805
+
776
806
  if (state && state === AUTH_STATE_ONLINE) {
777
807
  // const user = this.tiledeskAuthService.getCurrentUser();
778
808
  // if (this.isOnline === false) {
@@ -804,7 +834,7 @@ export class AppComponent implements OnInit {
804
834
 
805
835
  this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
806
836
 
807
- this.logger.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
837
+ // console.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
808
838
  const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
809
839
  this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
810
840
 
@@ -817,6 +847,128 @@ export class AppComponent implements OnInit {
817
847
  });
818
848
  }
819
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
+
820
972
  /**
821
973
  * ::: subscribeChangedConversationSelected :::
822
974
  * evento richiamato quando si seleziona un utente nell'elenco degli user
@@ -851,9 +1003,8 @@ export class AppComponent implements OnInit {
851
1003
  that.removePresenceAndLogout();
852
1004
  // that.presentToast();
853
1005
  }
854
- })
1006
+ });
855
1007
  }
856
-
857
1008
  }
858
1009
  }
859
1010
 
@@ -971,29 +1122,6 @@ export class AppComponent implements OnInit {
971
1122
  this.archivedConversationsHandlerService.initialize(this.tenant, userId, translationMap);
972
1123
  }
973
1124
 
974
- // BEGIN RESIZE FUNCTIONS //
975
- @HostListener('window:resize', ['$event'])
976
- onResize(event: any) {
977
- const that = this;
978
- // this.logger.debug('this.doitResize)', this.doitResize)
979
- clearTimeout(this.doitResize);
980
- this.doitResize = setTimeout(() => {
981
- let platformIsNow = PLATFORM_DESKTOP;
982
- if (checkPlatformIsMobile()) {
983
- platformIsNow = PLATFORM_MOBILE;
984
- }
985
- if (!this.platformIs || this.platformIs === '') {
986
- this.platformIs = platformIsNow;
987
- }
988
- this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
989
- this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
990
- this.logger.debug('[APP-COMP] onResize width:::: platformIsNow this.platformIs', this.platformIs);
991
- if (platformIsNow !== this.platformIs) {
992
- window.location.reload();
993
- }
994
- }, 500);
995
- }
996
- // END RESIZE FUNCTIONS //
997
1125
 
998
1126
  @HostListener('document:visibilitychange', [])
999
1127
  visibilitychange() {
@@ -1013,7 +1141,7 @@ export class AppComponent implements OnInit {
1013
1141
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
1014
1142
  @HostListener('window:storage', ['$event'])
1015
1143
  onStorageChanged(event: any) {
1016
- // console.log('[APP-COMP] - onStorageChanged event ', event)
1144
+
1017
1145
  if (event.key !== 'chat_sv5__tiledeskToken') {
1018
1146
  return;
1019
1147
  }
@@ -1052,7 +1180,4 @@ export class AppComponent implements OnInit {
1052
1180
  }
1053
1181
  }
1054
1182
  }
1055
-
1056
-
1057
-
1058
1183
  }