@chat21/chat21-ionic 3.0.55-RC20 → 3.0.55-RC22

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.0.55-RC22
4
+ - Fixes the bug: if the chat is open in multiple browser tabs when the user log in the 'goOnline' method is activated several times
5
+ - Manages the message displayed in the conversation list when the sender sends a file (replace the markdown string with the string "sent an attachment")
6
+ - Fixes the bug: if the chat is open in multiple browser tabs when the user logs out, the conversation list remains visible
7
+ - Displays the "loading bubble" while uploading an image
8
+
9
+ ### 3.0.55-RC21
10
+ - Fixes the bug: if the chat is open in more than one browser tab, not all of them reconnect when the user accesses one of them
11
+
3
12
  ### 3.0.55-RC20
4
13
  - Improve the method that solves the bug: if the chat is open on more than one tab, the previous ones disconnect
5
14
  - Displays the message "sent an image" when the sender sends an image
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
- "version": "3.0.55-RC20",
3
+ "version": "3.0.55-RC22",
4
4
  "author": "Tiledesk SRL",
5
5
  "homepage": "https://ionicframework.com/",
6
6
  "scripts": {
@@ -56,6 +56,10 @@ import { TiledeskService } from './services/tiledesk/tiledesk.service';
56
56
  import { NetworkService } from './services/network-service/network.service';
57
57
  import * as PACKAGE from 'package.json';
58
58
 
59
+ import { Subject } from 'rxjs';
60
+ import { filter, takeUntil } from 'rxjs/operators'
61
+ // import { filter } from 'rxjs/operators';
62
+
59
63
  @Component({
60
64
  selector: 'app-root',
61
65
  templateUrl: 'app.component.html',
@@ -94,6 +98,8 @@ export class AppComponent implements OnInit {
94
98
  public missingConnectionToast: any
95
99
  public executedInitializeAppByWatchConnection: boolean = false;
96
100
  private version: string;
101
+ private unsubscribe$: Subject<any> = new Subject<any>();
102
+ private isOnline: boolean = false;
97
103
 
98
104
  constructor(
99
105
  private platform: Platform,
@@ -146,19 +152,16 @@ export class AppComponent implements OnInit {
146
152
  ngOnInit() {
147
153
  this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
148
154
  this.logger.info('[APP-COMP] ngOnInit -->', this.route.snapshot.params);
149
-
150
- this.initializeApp();
151
-
155
+ this.initializeApp('oninit');
152
156
  }
153
157
 
154
158
 
155
159
 
156
160
  /** */
157
- initializeApp() {
161
+ initializeApp(calledby: string) {
162
+ this.logger.info('[APP-COMP] - initializeApp !!! CALLED-BY: ', calledby);
158
163
 
159
- this.logger.log('[APP-COMP] - watchToConnectionStatus - initializeApp');
160
- this.logger.log('[APP-COMP] HELLO initializeApp !!!!!!!')
161
- this.logger.info('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
164
+ this.logger.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
162
165
 
163
166
  if (!this.platform.is('cordova')) {
164
167
  this.splashScreen.show();
@@ -221,9 +224,22 @@ export class AppComponent implements OnInit {
221
224
  // Watch to network status
222
225
  // ---------------------------------------
223
226
  this.watchToConnectionStatus();
227
+ // this.listenToUserIsSignedIn();
224
228
  });
225
229
  }
226
230
 
231
+ // listenToUserIsSignedIn() {
232
+ // this.tiledeskAuthService.isOnline$
233
+ // .pipe(filter((isOnline) => isOnline !== null))
234
+ // .subscribe((isOnline: any) => {
235
+ // console.log('[APP-COMP] user isOnline: ', isOnline);
236
+
237
+ // // if (isOnline === false) {
238
+ // // this.events.publish('profileInfoButtonClick:logout', true);
239
+ // // }
240
+ // });
241
+ // }
242
+
227
243
 
228
244
 
229
245
  watchToConnectionStatus() {
@@ -250,7 +266,7 @@ export class AppComponent implements OnInit {
250
266
  if (elemIonNavchildNodes.length === 0) {
251
267
  this.logger.log('[APP-COMP] - watchToConnectionStatus - elemIonNavchildNodes HERE YES', elemIonNavchildNodes);
252
268
 
253
- this.initializeApp();
269
+ this.initializeApp('checkinternet');
254
270
  this.executedInitializeAppByWatchConnection = true;
255
271
  }
256
272
  }, 2000);
@@ -264,7 +280,7 @@ export class AppComponent implements OnInit {
264
280
  const childElementCount = elemIonRouterOutlet.childElementCount;
265
281
  this.logger.log('[APP-COMP] - watchToConnectionStatus - mobile * childElementCount *', childElementCount)
266
282
  if (childElementCount === 1) {
267
- this.initializeApp();
283
+ this.initializeApp('checkinternet');
268
284
  this.executedInitializeAppByWatchConnection = true;
269
285
  }
270
286
  }, 2000);
@@ -277,29 +293,6 @@ export class AppComponent implements OnInit {
277
293
  });
278
294
  }
279
295
 
280
- // checkInternetFunc() {
281
- // if (!window || !navigator || !('onLine' in navigator)) return;
282
-
283
- // this.appIsOnline$ = Observable.create(observer => {
284
- // observer.next(true);
285
- // }).pipe(mapTo(true));
286
-
287
- // if (this.platform.is('cordova')) {
288
- // // on Device - when platform is cordova
289
- // this.appIsOnline$ = merge(
290
- // this.network.onConnect().pipe(mapTo(true)),
291
- // this.network.onDisconnect().pipe(mapTo(false))
292
- // );
293
- // } else {
294
- // // on Browser - when platform is Browser
295
- // this.appIsOnline$ = merge(
296
- // of(navigator.onLine),
297
- // fromEvent(window, 'online').pipe(mapTo(true)),
298
- // fromEvent(window, 'offline').pipe(mapTo(false))
299
- // );
300
- // }
301
- // return this.appIsOnline$
302
- // }
303
296
 
304
297
  getRouteParamsAndSetLoggerConfig() {
305
298
  const appconfig = this.appConfigProvider.getConfig();
@@ -315,30 +308,6 @@ export class AppComponent implements OnInit {
315
308
  });
316
309
  }
317
310
 
318
- async presentMissingConnectionToast() {
319
- this.missingConnectionToast = await this.toastController.create({
320
- // header: '<ion-icon name="bicycle"></ion-icon>' + this.toastMsgWaitingForNetwork,
321
- message: '<ion-spinner class="spinner-middle"></ion-spinner> <span part="message-text" class="waiting-for-network-msg">&nbsp;&nbsp; Waiting for network</span> ',
322
- position: 'top',
323
- cssClass: 'missing-connection-toast',
324
- // buttons: [
325
- // {
326
- // text: this.toastMsgCloseToast,
327
- // role: 'cancel',
328
-
329
- // }
330
- // ]
331
- });
332
- await this.missingConnectionToast.present()
333
-
334
- // const { role } = await toast.onDidDismiss();
335
- // console.log('onDidDismiss resolved with role', role);
336
- }
337
-
338
- async dismissMissingConnectionToast() {
339
- this.missingConnectionToast = await this.toastController.dismiss()
340
- }
341
-
342
311
 
343
312
  translateToastMsgs() {
344
313
  this.translate.get('AnErrorOccurredWhileUnsubscribingFromNotifications')
@@ -360,6 +329,7 @@ export class AppComponent implements OnInit {
360
329
  /**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
361
330
  private initAuthentication() {
362
331
  const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
332
+ this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
363
333
  this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
364
334
 
365
335
  const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
@@ -368,6 +338,7 @@ export class AppComponent implements OnInit {
368
338
  this.logger.log('[APP-COMP] >>> initAuthentication I LOG IN WITH A TOKEN EXISTING IN THE LOCAL STORAGE OR WITH A TOKEN PASSED IN THE URL PARAMETERS <<<')
369
339
 
370
340
  this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
341
+ this.logger.log('[APP-COMP] >>> initAuthentication user ', user)
371
342
  this.messagingAuthService.createCustomToken(tiledeskToken)
372
343
  }).catch(error => { this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::' + error) })
373
344
 
@@ -394,7 +365,7 @@ export class AppComponent implements OnInit {
394
365
 
395
366
  authenticate() {
396
367
  let token = this.appStorageService.getItem('tiledeskToken');
397
- this.logger.debug('[APP-COMP] ***** authenticate - stored token *****', token);
368
+ this.logger.info('[APP-COMP] ***** authenticate - stored token *****', token);
398
369
  if (!token) {
399
370
  this.goOffLine()
400
371
  }
@@ -408,13 +379,17 @@ export class AppComponent implements OnInit {
408
379
  * @param user
409
380
  */
410
381
  goOnLine = () => {
382
+ this.isOnline = true;
383
+ this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO ONLINE isOnline ', this.isOnline);
384
+
385
+
411
386
  clearTimeout(this.timeModalLogin);
412
387
  const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
413
388
  const currentUser = this.tiledeskAuthService.getCurrentUser();
414
389
  // this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
415
390
  this.logger.log('[APP-COMP] - goOnLine****', currentUser);
416
391
  this.chatManager.setTiledeskToken(tiledeskToken);
417
-
392
+ this.chatManager.setCurrentUser(currentUser);
418
393
  // ----------------------------------------------
419
394
  // PUSH NOTIFICATIONS
420
395
  // ----------------------------------------------
@@ -425,7 +400,7 @@ export class AppComponent implements OnInit {
425
400
  this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
426
401
  }
427
402
 
428
- this.chatManager.setCurrentUser(currentUser);
403
+
429
404
  this.presenceService.setPresence(currentUser.uid);
430
405
  this.initConversationsHandler(currentUser.uid);
431
406
  this.initArchivedConversationsHandler(currentUser.uid);
@@ -444,6 +419,7 @@ export class AppComponent implements OnInit {
444
419
 
445
420
  goOffLine = () => {
446
421
  this.logger.log('[APP-COMP] ************** goOffLine:', this.authModal);
422
+ this.isOnline = false;
447
423
  // this.conversationsHandlerService.conversations = [];
448
424
 
449
425
  this.chatManager.setTiledeskToken(null);
@@ -459,6 +435,10 @@ export class AppComponent implements OnInit {
459
435
  this.hadBeenCalledOpenModal = true
460
436
  }
461
437
  }, 1000);
438
+
439
+ // this.unsubscribe$.next();
440
+ // this.unsubscribe$.complete();
441
+
462
442
  }
463
443
  /**------- AUTHENTICATION FUNCTIONS --> END <--- +*/
464
444
  /***************************************************+*/
@@ -593,47 +573,35 @@ export class AppComponent implements OnInit {
593
573
 
594
574
 
595
575
  // BEGIN SUBSCRIPTIONS //
596
- /** */
576
+ /** .pipe(
577
+ takeUntil(this.unsubscribe$)
578
+ ) */
597
579
  initSubscriptions() {
598
- const that = this;
599
-
600
- this.messagingAuthService.BSAuthStateChanged.subscribe((state: any) => {
601
- this.logger.log('[APP-COMP] ***** BSAuthStateChanged ***** state', state);
602
- if (state && state === AUTH_STATE_ONLINE) {
603
- const user = that.tiledeskAuthService.getCurrentUser();
604
- that.goOnLine();
605
- } else if (state === AUTH_STATE_OFFLINE) {
606
- // that.goOffLine();
607
- that.authenticate() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
608
- }
609
- });
610
-
611
- // this.authService.BSSignOut.subscribe((data: any) => {
612
- // this.logger.debug('***** BSSignOut *****', data);
613
- // if (data) {
614
- // that.presenceService.removePresence();
615
- // }
616
- // });
617
-
618
-
619
- // this.currentUserService.BScurrentUser.subscribe((currentUser: any) => {
620
- // this.logger.debug('***** app comp BScurrentUser *****', currentUser);
621
- // if (currentUser) {
622
- // that.chatManager.setCurrentUser(currentUser);
623
- // }
624
- // });
580
+ this.logger.log('initialize FROM [APP-COMP] - initSubscriptions');
581
+
582
+
583
+ this.messagingAuthService.BSAuthStateChanged
584
+ .pipe(takeUntil(this.unsubscribe$))
585
+ .pipe(filter((state) => state !== null))
586
+ .subscribe((state: any) => {
587
+ this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged state', state);
588
+ this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged isOnline', this.isOnline);
589
+ if (state && state === AUTH_STATE_ONLINE) {
590
+ const user = this.tiledeskAuthService.getCurrentUser();
591
+ if (this.isOnline === false) {
592
+ this.goOnLine();
593
+ }
594
+ } else if (state === AUTH_STATE_OFFLINE) {
595
+ // that.goOffLine();
596
+ this.authenticate() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
597
+ }
598
+ }, error => {
599
+ this.logger.error('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged * error * ', error)
600
+ }, () => {
601
+ this.logger.log('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged *** complete *** ')
602
+ });
625
603
 
626
604
 
627
- // this.events.subscribe('go-off-line', this.goOffLine);
628
- // this.events.subscribe('go-on-line', this.goOnLine);
629
- // this.events.subscribe('sign-in', this.signIn);
630
- // dopo il login quando ho completato il profilo utente corrente
631
- // this.events.subscribe('loaded-current-user', null);
632
- // this.events.subscribe('firebase-sign-in-with-custom-token', this.firebaseSignInWithCustomToken);
633
- // this.events.subscribe('firebase-create-user-with-email-and-password', this.firebaseCreateUserWithEmailAndPassword);
634
- // this.events.subscribe('firebase-current-user-delete', this.firebaseCurrentUserDelete);
635
- // this.events.subscribe('firebase-send-password-reset-email', this.firebaseSendPasswordResetEmail);
636
- // this.events.subscribe('firebase-sign-out', this.firebaseSignOut);
637
605
  this.events.subscribe('uidConvSelected:changed', this.subscribeChangedConversationSelected);
638
606
  this.events.subscribe('profileInfoButtonClick:logout', this.subscribeProfileInfoButtonLogOut);
639
607
 
@@ -678,6 +646,7 @@ export class AppComponent implements OnInit {
678
646
  // this.removePresenceAndLogout()
679
647
  // }
680
648
 
649
+
681
650
  if (hasClickedLogout === true) {
682
651
  // ----------------------------------------------
683
652
  // PUSH NOTIFICATIONS
@@ -783,7 +752,7 @@ export class AppComponent implements OnInit {
783
752
  const keys = ['YOU'];
784
753
  const translationMap = this.translateService.translateLanguage(keys);
785
754
 
786
- this.logger.debug('[APP-COMP] initConversationsHandler ------------->', userId, this.tenant);
755
+ this.logger.log('[APP-COMP] initConversationsHandler ------------->', userId, this.tenant);
787
756
  // 1 - init chatConversationsHandler and archviedConversationsHandler
788
757
  this.conversationsHandlerService.initialize(this.tenant, userId, translationMap);
789
758
 
@@ -792,7 +761,7 @@ export class AppComponent implements OnInit {
792
761
  this.logger.log('[APP-COMP]-CONVS- INIT CONV')
793
762
 
794
763
  const conversations = this.conversationsHandlerService.conversations;
795
- this.logger.log('[APP-COMP]-CONVS - INIT CONV CONVS', conversations)
764
+ this.logger.info('initialize FROM [APP-COMP] - [APP-COMP]-CONVS - INIT CONV CONVS', conversations)
796
765
 
797
766
  // this.logger.printDebug('SubscribeToConversations (convs-list-page) - conversations')
798
767
  if (!conversations || conversations.length === 0) {
@@ -856,50 +825,30 @@ export class AppComponent implements OnInit {
856
825
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
857
826
  @HostListener('window:storage', ['$event'])
858
827
  onStorageChanged(event: any) {
859
- // console.log('[APP-COMP] - onStorageChanged event', event)
860
- // console.log('[APP-COMP] - onStorageChanged tiledeskToken', this.appStorageService.getItem('tiledeskToken'))
861
- // const storage = event.storageArea;
862
- // console.log('[APP-COMP] - onStorageChanged event storage', storage)
863
-
864
- // setTimeout(() => {
865
- // if (storage && storage['chat_sv5__tiledeskToken'] === undefined) {
866
- // this.logger.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken', storage['chat_sv5__tiledeskToken'])
867
- // this.tiledeskAuthService.logOut()
868
- // this.messagingAuthService.logout();
869
- // // this.events.publish('profileInfoButtonClick:logout', true);
870
- // this.conversationsHandlerService.conversations = [];
871
- // } else if (storage && storage['chat_sv5__tiledeskToken']) {
872
-
873
- // this.logger.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken * IS DEFINED *')
874
- // const currentUser = this.tiledeskAuthService.getCurrentUser();
875
-
876
- // if (!currentUser) {
877
- // window.location.reload();
878
- // }
879
-
880
- // }
881
- // }, 1000);
882
-
883
- // else {
884
- // console.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken', storage['chat_sv5__tiledeskToken'])
885
- // }
886
828
 
887
- // setTimeout(() => {
888
- if (this.appStorageService.getItem('tiledeskToken') === null) {
889
- this.tiledeskAuthService.logOut()
890
- this.messagingAuthService.logout();
891
- }
892
- else {
829
+ if (event.key !== 'chat_sv5__tiledeskToken') {
830
+ return;
831
+ }
832
+
833
+ if (this.appStorageService.getItem('tiledeskToken') === null) {
834
+ this.logger.log('[APP-COMP] - onStorageChanged tiledeskToken is null - RUN LOGOUT')
835
+ this.tiledeskAuthService.logOut()
836
+ this.messagingAuthService.logout();
837
+ this.events.publish('profileInfoButtonClick:logout', true);
838
+ }
839
+ else {
840
+ const currentUser = this.tiledeskAuthService.getCurrentUser();
841
+
842
+ if (!currentUser && this.appStorageService.getItem('tiledeskToken') !== null) {
843
+ this.logger.log('[APP-COMP] - onStorageChanged currentUser', currentUser)
844
+ // console.log('[APP-COMP] - onStorageChanged wentOnline 2', this.wentOnline)
845
+
846
+ this.initializeApp('onstoragechanged');
893
847
 
894
- const currentUser = this.tiledeskAuthService.getCurrentUser();
895
- if (currentUser) {
896
- console.log('[APP-COMP] - onStorageChanged currentUser', currentUser)
897
- } else {
898
- // this.initializeApp();
899
- window.location.reload();
900
- }
901
848
  }
902
- // }, 1000);
849
+ }
903
850
  }
904
851
 
852
+
853
+
905
854
  }
@@ -117,7 +117,8 @@ export class ConversationContentComponent implements OnInit {
117
117
  listenToUploadFileProgress() {
118
118
  this.uploadService.BSStateUpload.subscribe((data: any) => {
119
119
  this.logger.log('[CONV-CONTENT-W] BSStateUpload', data);
120
- if (data && data.type.startsWith("application")) {
120
+ // && data.type.startsWith("application")
121
+ if (data ) {
121
122
  data.upload === 100 || isNaN(data.upload) ? this.showUploadProgress = false : this.showUploadProgress = true
122
123
  this.uploadProgress = data.upload
123
124
  this.fileType = 'file'
@@ -119,8 +119,10 @@
119
119
  </chat-message-attachment>
120
120
  </div>
121
121
  </div>
122
+ <!-- (fileType === 'file' && uploadProgress !== 100) -->
122
123
 
123
- <div *ngIf="(fileType === 'file' && uploadProgress !== 100)" class="msg_container base_sent"
124
+ <!-- uploadProgress -> {{ uploadProgress }} -->
125
+ <div *ngIf="uploadProgress !== 100" class="msg_container base_sent"
124
126
  style="margin-right: 20px;">
125
127
  <div class="messages msg_sent">
126
128
  <div class="spinner">
@@ -22,7 +22,7 @@ export class IonConversationDetailComponent extends ConversationContentComponent
22
22
  @Output() onAddUploadingBubble = new EventEmitter<boolean>();
23
23
 
24
24
 
25
- public uploadProgress: number
25
+ public uploadProgress: number = 100
26
26
  public fileType: any
27
27
 
28
28
  isMine = isMine;
@@ -45,10 +45,12 @@ export class IonConversationDetailComponent extends ConversationContentComponent
45
45
  public uploadService: UploadService
46
46
  ) {
47
47
  super(cdref, uploadService)
48
- this.listenToUploadFileProgress()
48
+
49
49
  }
50
50
 
51
- ngOnInit() { }
51
+ ngOnInit() {
52
+ this.listenToUploadFileProgress()
53
+ }
52
54
 
53
55
  listenToUploadFileProgress() {
54
56
  this.logger.log('[CONVS-DETAIL][ION-CONVS-DETAIL] FIREBASE-UPLOAD - calling BSStateUpload ');
@@ -65,14 +67,14 @@ export class IonConversationDetailComponent extends ConversationContentComponent
65
67
  this.uploadProgress = 100
66
68
  }
67
69
  // if (data.type.startsWith("application")) {
68
- if (!data.type.startsWith("image")) {
70
+ // if (!data.type.startsWith("image")) {
69
71
 
70
- this.fileType = 'file'
72
+ // this.fileType = 'file'
71
73
 
72
74
  this.addUploadingBubblePlaceholder(true)
73
75
 
74
- this.logger.log('[CONVS-DETAIL][ION-CONVS-DETAIL] FIREBASE-UPLOAD - BSStateUpload this.fileType', this.fileType);
75
- }
76
+ // this.logger.log('[CONVS-DETAIL][ION-CONVS-DETAIL] FIREBASE-UPLOAD - BSStateUpload this.fileType', this.fileType);
77
+ // }
76
78
  }
77
79
  });
78
80
  }
@@ -9,8 +9,9 @@ img {
9
9
  }
10
10
 
11
11
  .isLoadingImage {
12
- position: relative;
13
- top: 6px;
12
+ // position: relative;
13
+ // top: 6px;
14
+ display:none
14
15
  }
15
16
 
16
17
  .loader {
@@ -32,7 +32,7 @@ export class ImageComponent implements OnInit {
32
32
  }
33
33
  getBrowserLanguageAndTranslateTooltipMsg() {
34
34
  var userLang = navigator.language;
35
- console.log('Image COMP - userLang ', userLang)
35
+ // console.log('Image COMP - userLang ', userLang)
36
36
  if (userLang === 'en') {
37
37
  this.tooltipMessage = "Click to download"
38
38
  } else {
@@ -89,7 +89,7 @@ export class ContactsDirectoryPage implements OnInit {
89
89
  this.logger.log('[CONTACT-DIRECTORY-PAGE] DSHBRD STORED USER: ', user);
90
90
  if (user.token) {
91
91
  token = user.token;
92
- console.log('[CONTACTS-DIRECTORY] DSHBRD STORED USER > TOKEN: ', user.token);
92
+ this.logger.log('[CONTACTS-DIRECTORY] DSHBRD STORED USER > TOKEN: ', user.token);
93
93
  }
94
94
  }
95
95
  return token;
@@ -12,7 +12,7 @@
12
12
  </app-option-header>
13
13
  </ion-header>
14
14
 
15
- <ion-content class="list-avatar-page" appScrollbarTheme>
15
+ <ion-content #ioncontentconvlist class="list-avatar-page" appScrollbarTheme>
16
16
 
17
17
  <div id="scrollbar2">
18
18
  <ion-list>
@@ -1,6 +1,6 @@
1
1
  import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service';
2
- import { Component, OnInit } from '@angular/core';
3
- import { ModalController } from '@ionic/angular';
2
+ import { Component, OnInit, ViewChild } from '@angular/core';
3
+ import { IonContent, ModalController } from '@ionic/angular';
4
4
  import { ActivatedRoute, Router, NavigationExtras } from '@angular/router';
5
5
  // config
6
6
  import { environment } from '../../../environments/environment';
@@ -39,6 +39,7 @@ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
39
39
  styleUrls: ['./conversations-list.page.scss'],
40
40
  })
41
41
  export class ConversationListPage implements OnInit {
42
+ @ViewChild('ioncontentconvlist', { static: false }) ionContentConvList: IonContent;
42
43
  private subscriptions: Array<string>;
43
44
  public tenant: string;
44
45
  public loggedUserUid: string;
@@ -199,8 +200,8 @@ export class ConversationListPage implements OnInit {
199
200
 
200
201
  listenToLogoutEvent() {
201
202
  this.events.subscribe('profileInfoButtonClick:logout', (hasclickedlogout) => {
202
- this.logger.log('[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout', hasclickedlogout);
203
-
203
+ this.logger.info('[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout', hasclickedlogout);
204
+ this.conversations = []
204
205
  this.conversationsHandlerService.conversations = [];
205
206
  this.uidConvSelected = null;
206
207
 
@@ -493,6 +494,11 @@ export class ConversationListPage implements OnInit {
493
494
 
494
495
  onConversationLoaded(conversation: ConversationModel) {
495
496
  this.logger.log('[CONVS-LIST-PAGE] onConversationLoaded ', conversation)
497
+ this.logger.log('[CONVS-LIST-PAGE] onConversationLoaded is new? ', conversation.is_new)
498
+ // if (conversation.is_new === false) {
499
+ // this.ionContentConvList.scrollToTop(0);
500
+ // }
501
+
496
502
  const keys = ['YOU', 'SENT_AN_IMAGE', 'SENT_AN_ATTACHMENT'];
497
503
  const translationMap = this.translateService.translateLanguage(keys);
498
504
  // Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly in the convesations list
@@ -530,27 +536,27 @@ export class ConversationListPage implements OnInit {
530
536
 
531
537
  conversation.last_message_text = SENT_AN_IMAGE;
532
538
 
533
- }
534
- // else if (conversation.type !== "text" && conversation.type !== "image") {
535
- // // this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
536
- // const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
537
- // conversation.last_message_text = SENT_AN_ATTACHMENT;
539
+ }
540
+ else if (conversation.type === "file") {
541
+ // this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
542
+ const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
543
+ conversation.last_message_text = SENT_AN_ATTACHMENT;
538
544
 
539
- // }
545
+ }
540
546
  }
541
547
  }
542
548
  }
543
549
 
544
- // isMarkdownLink(last_message_text) {
545
- // this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 1')
546
- // var regex = /^(^|[\n\r])\s*1\.\s.*\s+1\.\s$/
547
- // let matchRegex = false
548
- // if (regex.test(last_message_text)) {
549
- // this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 2')
550
- // matchRegex = true
551
- // return matchRegex
552
- // }
553
- // }
550
+ // isMarkdownLink(last_message_text) {
551
+ // this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 1')
552
+ // var regex = /^(^|[\n\r])\s*1\.\s.*\s+1\.\s$/
553
+ // let matchRegex = false
554
+ // if (regex.test(last_message_text)) {
555
+ // this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 2')
556
+ // matchRegex = true
557
+ // return matchRegex
558
+ // }
559
+ // }
554
560
 
555
561
 
556
562
  navigateByUrl(converationType: string, uidConvSelected: string) {
@@ -52,7 +52,7 @@ export class NavProxyService {
52
52
 
53
53
  // !!!! SEEMS NOT USED
54
54
  pushSidebar(page: any, pageName: string, navExtra?) {
55
- console.log('push2:', pageName, 'navExtra():', navExtra, 'this.sidebarNav', this.sidebarNav);
55
+ this.logger.log('push2:', pageName, 'navExtra():', navExtra, 'this.sidebarNav', this.sidebarNav);
56
56
  if (checkPlatformIsMobile()) {
57
57
  this.router.navigate([pageName], navExtra);
58
58
  } else {
@@ -64,7 +64,7 @@ export class NavProxyService {
64
64
 
65
65
  // !!!! SEEMS NOT USED
66
66
  closePage(pageName: string) {
67
- console.log('closePage:', pageName, 'checkPlatformIsMobile():', checkPlatformIsMobile());
67
+ this.logger.log('closePage:', pageName, 'checkPlatformIsMobile():', checkPlatformIsMobile());
68
68
  if (checkPlatformIsMobile()) {
69
69
  const navigationExtras: NavigationExtras = {
70
70
  state: {
@@ -25,6 +25,6 @@
25
25
  },
26
26
  "apiUrl": "https://tiledesk-server-pre.herokuapp.com/",
27
27
  "baseImageUrl": "https://firebasestorage.googleapis.com/v0/b/",
28
- "dashboardUrl": "https://support-pre.tiledesk.com/dashboard/"
28
+ "dashboardUrl": "http://localhost:4204/"
29
29
  }
30
30
 
@@ -17,7 +17,6 @@ import { LoggerService } from './abstract/logger.service';
17
17
  import { LoggerInstance } from './logger/loggerInstance';
18
18
 
19
19
 
20
-
21
20
  @Injectable({ providedIn: 'root' })
22
21
 
23
22
  export class ChatManager {
@@ -58,6 +57,7 @@ export class ChatManager {
58
57
  * setTiledeskToken
59
58
  */
60
59
  public setTiledeskToken(tiledeskToken: string) {
60
+ this.logger.info('initialize FROM [APP-COMP] - [CHAT MANAGER] - initialize -> firebaseConfig tenant ', this.tenant);
61
61
  this.tiledeskToken = tiledeskToken;
62
62
  }
63
63
 
@@ -72,6 +72,7 @@ export class ChatManager {
72
72
  * setCurrentUser
73
73
  */
74
74
  public setCurrentUser(currentUser: UserModel) {
75
+ this.logger.info('initialize FROM [APP-COMP] - [CHAT MANAGER] setCurrentUser currentUser ', currentUser)
75
76
  this.currentUser = currentUser;
76
77
  }
77
78
 
@@ -64,7 +64,7 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
64
64
  * inizializzo conversations handler
65
65
  */
66
66
  initialize(tenant: string, userId: string, translationMap: Map<string, string>) {
67
- this.logger.info('[FIREBASEArchivedConversationsHandlerSERVICE] tenant ', tenant, ' - userId: ', userId, ' - translationMap: ', translationMap)
67
+ this.logger.info('[initialize FROM [APP-COMP] - FIREBASEArchivedConversationsHandlerSERVICE] tenant ', tenant, ' - userId: ', userId, ' - translationMap: ', translationMap)
68
68
  this.tenant = tenant;
69
69
  this.loggedUserId = userId;
70
70
  this.translationMap = translationMap;
@@ -179,12 +179,15 @@ export class FirebaseAuthService extends MessagingAuthService {
179
179
  onAuthStateChanged() {
180
180
  const that = this;
181
181
  firebase.auth().onAuthStateChanged(user => {
182
- this.logger.log('[FIREBASEAuthSERVICE] onAuthStateChanged', user)
182
+ this.logger.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged', user)
183
183
  if (!user) {
184
184
  this.logger.log('[FIREBASEAuthSERVICE] 1 - PASSO OFFLINE AL CHAT MANAGER')
185
+ // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged user ', user)
186
+
185
187
  that.BSAuthStateChanged.next('offline');
186
188
  } else {
187
189
  this.logger.log('[FIREBASEAuthSERVICE] 2 - PASSO ONLINE AL CHAT MANAGER')
190
+ // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged user ', user)
188
191
  that.BSAuthStateChanged.next('online');
189
192
  }
190
193
  });
@@ -217,7 +220,8 @@ export class FirebaseAuthService extends MessagingAuthService {
217
220
  }
218
221
  }
219
222
  return firebase.auth().setPersistence(firebasePersistence).then(async () => {
220
- return firebase.auth().signInWithCustomToken(token).then(async () => {
223
+ return firebase.auth().signInWithCustomToken(token).then(async (user) => {
224
+
221
225
  // that.firebaseSignInWithCustomToken.next(response);
222
226
  }).catch((error) => {
223
227
  that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
@@ -317,6 +321,7 @@ export class FirebaseAuthService extends MessagingAuthService {
317
321
 
318
322
  logout() {
319
323
  this.logger.log('[FIREBASEAuthSERVICE] logout');
324
+ this.BSAuthStateChanged.next(null);
320
325
  // cancello token firebase dal local storage e da firebase
321
326
  // dovrebbe scattare l'evento authchangeStat
322
327
  this.signOut();
@@ -63,10 +63,10 @@ export class FirebaseNotifications extends NotificationsService {
63
63
 
64
64
  getNotificationPermissionAndSaveToken(currentUserUid) {
65
65
  // this.tenant = this.getTenant();
66
- this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - tenant ', this.tenant)
67
- this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - currentUserUid ', currentUserUid)
66
+ this.logger.log('initialize FROM [APP-COMP] - [FIREBASE-NOTIFICATIONS] calling requestPermission - tenant ', this.tenant, ' currentUserUid ', currentUserUid)
67
+ // this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - currentUserUid ', currentUserUid)
68
68
  this.userId = currentUserUid;
69
- // Service Worker explicit registration to explicitly define sw location at a path
69
+ // Service Worker explicit registration to explicitly define sw location at a path,
70
70
  // const swRegistration = async () => {
71
71
  // try {
72
72
  // await navigator.serviceWorker.register('http://localhost:8101/firebase-messaging-sw.js');
@@ -76,9 +76,9 @@ export class FirebaseNotifications extends NotificationsService {
76
76
  // }
77
77
 
78
78
 
79
-
79
+
80
80
  if (firebase.messaging.isSupported()) {
81
- const messaging = firebase.messaging();
81
+ const messaging = firebase.messaging();
82
82
  // messaging.requestPermission()
83
83
  Notification.requestPermission().then((permission) => {
84
84
  if (permission === 'granted') {
@@ -165,7 +165,7 @@ export class FirebaseNotifications extends NotificationsService {
165
165
  self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.userId', self.userId);
166
166
  self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > FCMcurrentToken', self.FCMcurrentToken);
167
167
  // this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.tenant', this.tenant);
168
-
168
+
169
169
 
170
170
  } else {
171
171
  self.logger.debug('[FIREBASE-NOTIFICATIONS] - No FB user is signed in. ', user)
@@ -194,7 +194,7 @@ export class FirebaseNotifications extends NotificationsService {
194
194
  })
195
195
  }
196
196
 
197
-
197
+
198
198
  }
199
199
 
200
200
  // removeNotificationsInstance() {
@@ -129,6 +129,7 @@ export class FirebasePresenceService extends PresenceService {
129
129
  * @param userid
130
130
  */
131
131
  public setPresence(userid: string): void {
132
+ this.logger.info('initialize FROM [APP-COMP] - [FIREBASEPresenceSERVICE] - SET PRESENCE userid ', userid)
132
133
  this.onlineConnectionsRef = this.referenceOnlineForUser(userid);
133
134
  this.lastOnlineConnectionsRef = this.referenceLastOnlineForUser(userid);
134
135
  const connectedRefURL = '/.info/connected';
@@ -5,12 +5,16 @@ import { UserModel } from 'src/chat21-core/models/user';
5
5
  import { avatarPlaceholder, getColorBck } from 'src/chat21-core/utils/utils-user';
6
6
  import { AppStorageService } from '../abstract/app-storage.service';
7
7
  import { LoggerInstance } from '../logger/loggerInstance';
8
+ // import { BehaviorSubject } from 'rxjs';
9
+ // import { EventsService } from 'src/app/services/events-service';
10
+
8
11
 
9
12
  @Injectable({
10
13
  providedIn: 'root'
11
14
  })
12
15
  export class TiledeskAuthService {
13
16
 
17
+ // public isOnline$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(null);
14
18
  // private persistence: string;
15
19
  public SERVER_BASE_URL: string;
16
20
 
@@ -23,8 +27,11 @@ export class TiledeskAuthService {
23
27
  private currentUser: UserModel;
24
28
  private logger: LoggerService = LoggerInstance.getInstance()
25
29
 
26
- constructor(public http: HttpClient,
27
- public appStorage: AppStorageService) { }
30
+ constructor(
31
+ public http: HttpClient,
32
+ public appStorage: AppStorageService,
33
+ // private events: EventsService,
34
+ ) { }
28
35
 
29
36
 
30
37
  initialize(serverBaseUrl: string) {
@@ -125,10 +132,12 @@ export class TiledeskAuthService {
125
132
  }
126
133
 
127
134
  logOut() {
128
- this.logger.debug('[TILEDESK-AUTH] logOut()')
135
+ this.logger.log('[TILEDESK-AUTH] - LOGOUT')
129
136
  this.appStorage.removeItem('tiledeskToken')
130
137
  this.appStorage.removeItem('currentUser')
131
138
  this.setCurrentUser(null);
139
+ // this.isOnline$.next(false)
140
+
132
141
  }
133
142
 
134
143
 
@@ -155,8 +164,9 @@ export class TiledeskAuthService {
155
164
  member.avatar = avatar;
156
165
  member.color = color;
157
166
  this.currentUser = member;
158
- this.logger.debug('[TILEDESK-AUTH] - createCompleteUser member ', member);
167
+ this.logger.log('[TILEDESK-AUTH] - createCompleteUser member ', member);
159
168
  this.appStorage.setItem('currentUser', JSON.stringify(this.currentUser));
169
+ // this.isOnline$.next(true)
160
170
  } catch (err) {
161
171
  this.logger.error('[TILEDESK-AUTH]- createCompleteUser ERR ', err)
162
172
  }
@@ -171,7 +181,7 @@ export class TiledeskAuthService {
171
181
  this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken TOKEN DOES NOT EXIST - RUN SET ')
172
182
  this.appStorage.setItem('tiledeskToken', tiledeskToken);
173
183
  } else if (storedTiledeskToken && storedTiledeskToken !== tiledeskToken) {
174
- console.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken STORED-TOKEN EXIST BUT IS != FROM TOKEN - RUN SET ')
184
+ this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken STORED-TOKEN EXIST BUT IS != FROM TOKEN - RUN SET ')
175
185
  this.appStorage.setItem('tiledeskToken', tiledeskToken);
176
186
  } else if (storedTiledeskToken && storedTiledeskToken === tiledeskToken){
177
187
  this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken STORED-TOKEN EXIST AND IS = TO TOKEN ')
package/src/index.html CHANGED
@@ -30,7 +30,7 @@
30
30
  // console.log("index.html Hey script watchToConnectionAtStartUp! ");
31
31
  // // ononline version
32
32
  window.ononline = (event) => {
33
- console.log("index.html You are now connected to the network.");
33
+ // console.log("index.html You are now connected to the network.");
34
34
  };
35
35
 
36
36
  // // onoffline version