@chat21/chat21-ionic 3.0.55-RC15 → 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 +24 -0
- package/package.json +1 -1
- package/src/app/app.component.ts +90 -109
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +2 -1
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +3 -1
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +9 -7
- package/src/app/chatlib/conversation-detail/message/image/image.component.scss +3 -2
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/text/text.component.html +2 -3
- package/src/app/pages/contacts-directory/contacts-directory.page.ts +1 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +12 -12
- package/src/app/pages/conversations-list/conversations-list.page.html +1 -1
- package/src/app/pages/conversations-list/conversations-list.page.ts +53 -18
- package/src/app/services/nav-proxy.service.ts +2 -2
- package/src/chat-config-pre-test.json +1 -1
- package/src/chat21-core/providers/chat-manager.ts +2 -1
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +8 -3
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +24 -19
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +1 -0
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +41 -12
- package/src/index.html +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
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
|
+
|
|
12
|
+
### 3.0.55-RC20
|
|
13
|
+
- Improve the method that solves the bug: if the chat is open on more than one tab, the previous ones disconnect
|
|
14
|
+
- Displays the message "sent an image" when the sender sends an image
|
|
15
|
+
- Removes the "setTimeout" set on the onStorageChanged event
|
|
16
|
+
|
|
17
|
+
### 3.0.55-RC19
|
|
18
|
+
- Fixes the bug: opening the "conversations info" side panel for support type conversations causes the chat to log out
|
|
19
|
+
|
|
20
|
+
### 3.0.55-RC18
|
|
21
|
+
- Fixes the bug: if the chat is open on more than one tab, the previous ones logging out
|
|
22
|
+
|
|
23
|
+
### 3.0.55-RC16
|
|
24
|
+
- Removes the image name displayed at the bottom of the image
|
|
25
|
+
- Removes the adaptation of the image caption width to the image size
|
|
26
|
+
|
|
3
27
|
### 3.0.55-RC15
|
|
4
28
|
- Fixes the bug: "ion-spinner" throws an error when the chat is offline
|
|
5
29
|
- Fixes the bug: in the component "info-group-component" if groupDetail is not defined throws the error "Cannot read hasOwnProperty of undefined"
|
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -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,18 +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
|
|
|
159
|
+
|
|
155
160
|
/** */
|
|
156
|
-
initializeApp() {
|
|
161
|
+
initializeApp(calledby: string) {
|
|
162
|
+
this.logger.info('[APP-COMP] - initializeApp !!! CALLED-BY: ', calledby);
|
|
157
163
|
|
|
158
|
-
this.logger.log('[APP-COMP]
|
|
159
|
-
this.logger.log('[APP-COMP] HELLO initializeApp !!!!!!!')
|
|
160
|
-
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'))
|
|
161
165
|
|
|
162
166
|
if (!this.platform.is('cordova')) {
|
|
163
167
|
this.splashScreen.show();
|
|
@@ -220,9 +224,22 @@ export class AppComponent implements OnInit {
|
|
|
220
224
|
// Watch to network status
|
|
221
225
|
// ---------------------------------------
|
|
222
226
|
this.watchToConnectionStatus();
|
|
227
|
+
// this.listenToUserIsSignedIn();
|
|
223
228
|
});
|
|
224
229
|
}
|
|
225
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
|
+
|
|
226
243
|
|
|
227
244
|
|
|
228
245
|
watchToConnectionStatus() {
|
|
@@ -249,7 +266,7 @@ export class AppComponent implements OnInit {
|
|
|
249
266
|
if (elemIonNavchildNodes.length === 0) {
|
|
250
267
|
this.logger.log('[APP-COMP] - watchToConnectionStatus - elemIonNavchildNodes HERE YES', elemIonNavchildNodes);
|
|
251
268
|
|
|
252
|
-
this.initializeApp();
|
|
269
|
+
this.initializeApp('checkinternet');
|
|
253
270
|
this.executedInitializeAppByWatchConnection = true;
|
|
254
271
|
}
|
|
255
272
|
}, 2000);
|
|
@@ -263,7 +280,7 @@ export class AppComponent implements OnInit {
|
|
|
263
280
|
const childElementCount = elemIonRouterOutlet.childElementCount;
|
|
264
281
|
this.logger.log('[APP-COMP] - watchToConnectionStatus - mobile * childElementCount *', childElementCount)
|
|
265
282
|
if (childElementCount === 1) {
|
|
266
|
-
this.initializeApp();
|
|
283
|
+
this.initializeApp('checkinternet');
|
|
267
284
|
this.executedInitializeAppByWatchConnection = true;
|
|
268
285
|
}
|
|
269
286
|
}, 2000);
|
|
@@ -276,29 +293,6 @@ export class AppComponent implements OnInit {
|
|
|
276
293
|
});
|
|
277
294
|
}
|
|
278
295
|
|
|
279
|
-
// checkInternetFunc() {
|
|
280
|
-
// if (!window || !navigator || !('onLine' in navigator)) return;
|
|
281
|
-
|
|
282
|
-
// this.appIsOnline$ = Observable.create(observer => {
|
|
283
|
-
// observer.next(true);
|
|
284
|
-
// }).pipe(mapTo(true));
|
|
285
|
-
|
|
286
|
-
// if (this.platform.is('cordova')) {
|
|
287
|
-
// // on Device - when platform is cordova
|
|
288
|
-
// this.appIsOnline$ = merge(
|
|
289
|
-
// this.network.onConnect().pipe(mapTo(true)),
|
|
290
|
-
// this.network.onDisconnect().pipe(mapTo(false))
|
|
291
|
-
// );
|
|
292
|
-
// } else {
|
|
293
|
-
// // on Browser - when platform is Browser
|
|
294
|
-
// this.appIsOnline$ = merge(
|
|
295
|
-
// of(navigator.onLine),
|
|
296
|
-
// fromEvent(window, 'online').pipe(mapTo(true)),
|
|
297
|
-
// fromEvent(window, 'offline').pipe(mapTo(false))
|
|
298
|
-
// );
|
|
299
|
-
// }
|
|
300
|
-
// return this.appIsOnline$
|
|
301
|
-
// }
|
|
302
296
|
|
|
303
297
|
getRouteParamsAndSetLoggerConfig() {
|
|
304
298
|
const appconfig = this.appConfigProvider.getConfig();
|
|
@@ -314,30 +308,6 @@ export class AppComponent implements OnInit {
|
|
|
314
308
|
});
|
|
315
309
|
}
|
|
316
310
|
|
|
317
|
-
async presentMissingConnectionToast() {
|
|
318
|
-
this.missingConnectionToast = await this.toastController.create({
|
|
319
|
-
// header: '<ion-icon name="bicycle"></ion-icon>' + this.toastMsgWaitingForNetwork,
|
|
320
|
-
message: '<ion-spinner class="spinner-middle"></ion-spinner> <span part="message-text" class="waiting-for-network-msg"> Waiting for network</span> ',
|
|
321
|
-
position: 'top',
|
|
322
|
-
cssClass: 'missing-connection-toast',
|
|
323
|
-
// buttons: [
|
|
324
|
-
// {
|
|
325
|
-
// text: this.toastMsgCloseToast,
|
|
326
|
-
// role: 'cancel',
|
|
327
|
-
|
|
328
|
-
// }
|
|
329
|
-
// ]
|
|
330
|
-
});
|
|
331
|
-
await this.missingConnectionToast.present()
|
|
332
|
-
|
|
333
|
-
// const { role } = await toast.onDidDismiss();
|
|
334
|
-
// console.log('onDidDismiss resolved with role', role);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
async dismissMissingConnectionToast() {
|
|
338
|
-
this.missingConnectionToast = await this.toastController.dismiss()
|
|
339
|
-
}
|
|
340
|
-
|
|
341
311
|
|
|
342
312
|
translateToastMsgs() {
|
|
343
313
|
this.translate.get('AnErrorOccurredWhileUnsubscribingFromNotifications')
|
|
@@ -359,6 +329,7 @@ export class AppComponent implements OnInit {
|
|
|
359
329
|
/**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
|
|
360
330
|
private initAuthentication() {
|
|
361
331
|
const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
332
|
+
this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
|
|
362
333
|
this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
|
|
363
334
|
|
|
364
335
|
const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
@@ -367,6 +338,7 @@ export class AppComponent implements OnInit {
|
|
|
367
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 <<<')
|
|
368
339
|
|
|
369
340
|
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
|
|
341
|
+
this.logger.log('[APP-COMP] >>> initAuthentication user ', user)
|
|
370
342
|
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
371
343
|
}).catch(error => { this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::' + error) })
|
|
372
344
|
|
|
@@ -393,7 +365,7 @@ export class AppComponent implements OnInit {
|
|
|
393
365
|
|
|
394
366
|
authenticate() {
|
|
395
367
|
let token = this.appStorageService.getItem('tiledeskToken');
|
|
396
|
-
this.logger.
|
|
368
|
+
this.logger.info('[APP-COMP] ***** authenticate - stored token *****', token);
|
|
397
369
|
if (!token) {
|
|
398
370
|
this.goOffLine()
|
|
399
371
|
}
|
|
@@ -407,13 +379,17 @@ export class AppComponent implements OnInit {
|
|
|
407
379
|
* @param user
|
|
408
380
|
*/
|
|
409
381
|
goOnLine = () => {
|
|
382
|
+
this.isOnline = true;
|
|
383
|
+
this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO ONLINE isOnline ', this.isOnline);
|
|
384
|
+
|
|
385
|
+
|
|
410
386
|
clearTimeout(this.timeModalLogin);
|
|
411
387
|
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
|
|
412
388
|
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
413
389
|
// this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
|
|
414
390
|
this.logger.log('[APP-COMP] - goOnLine****', currentUser);
|
|
415
391
|
this.chatManager.setTiledeskToken(tiledeskToken);
|
|
416
|
-
|
|
392
|
+
this.chatManager.setCurrentUser(currentUser);
|
|
417
393
|
// ----------------------------------------------
|
|
418
394
|
// PUSH NOTIFICATIONS
|
|
419
395
|
// ----------------------------------------------
|
|
@@ -424,7 +400,7 @@ export class AppComponent implements OnInit {
|
|
|
424
400
|
this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
|
|
425
401
|
}
|
|
426
402
|
|
|
427
|
-
|
|
403
|
+
|
|
428
404
|
this.presenceService.setPresence(currentUser.uid);
|
|
429
405
|
this.initConversationsHandler(currentUser.uid);
|
|
430
406
|
this.initArchivedConversationsHandler(currentUser.uid);
|
|
@@ -443,6 +419,7 @@ export class AppComponent implements OnInit {
|
|
|
443
419
|
|
|
444
420
|
goOffLine = () => {
|
|
445
421
|
this.logger.log('[APP-COMP] ************** goOffLine:', this.authModal);
|
|
422
|
+
this.isOnline = false;
|
|
446
423
|
// this.conversationsHandlerService.conversations = [];
|
|
447
424
|
|
|
448
425
|
this.chatManager.setTiledeskToken(null);
|
|
@@ -458,6 +435,10 @@ export class AppComponent implements OnInit {
|
|
|
458
435
|
this.hadBeenCalledOpenModal = true
|
|
459
436
|
}
|
|
460
437
|
}, 1000);
|
|
438
|
+
|
|
439
|
+
// this.unsubscribe$.next();
|
|
440
|
+
// this.unsubscribe$.complete();
|
|
441
|
+
|
|
461
442
|
}
|
|
462
443
|
/**------- AUTHENTICATION FUNCTIONS --> END <--- +*/
|
|
463
444
|
/***************************************************+*/
|
|
@@ -592,47 +573,35 @@ export class AppComponent implements OnInit {
|
|
|
592
573
|
|
|
593
574
|
|
|
594
575
|
// BEGIN SUBSCRIPTIONS //
|
|
595
|
-
/**
|
|
576
|
+
/** .pipe(
|
|
577
|
+
takeUntil(this.unsubscribe$)
|
|
578
|
+
) */
|
|
596
579
|
initSubscriptions() {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
// if (currentUser) {
|
|
621
|
-
// that.chatManager.setCurrentUser(currentUser);
|
|
622
|
-
// }
|
|
623
|
-
// });
|
|
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
|
+
});
|
|
624
603
|
|
|
625
604
|
|
|
626
|
-
// this.events.subscribe('go-off-line', this.goOffLine);
|
|
627
|
-
// this.events.subscribe('go-on-line', this.goOnLine);
|
|
628
|
-
// this.events.subscribe('sign-in', this.signIn);
|
|
629
|
-
// dopo il login quando ho completato il profilo utente corrente
|
|
630
|
-
// this.events.subscribe('loaded-current-user', null);
|
|
631
|
-
// this.events.subscribe('firebase-sign-in-with-custom-token', this.firebaseSignInWithCustomToken);
|
|
632
|
-
// this.events.subscribe('firebase-create-user-with-email-and-password', this.firebaseCreateUserWithEmailAndPassword);
|
|
633
|
-
// this.events.subscribe('firebase-current-user-delete', this.firebaseCurrentUserDelete);
|
|
634
|
-
// this.events.subscribe('firebase-send-password-reset-email', this.firebaseSendPasswordResetEmail);
|
|
635
|
-
// this.events.subscribe('firebase-sign-out', this.firebaseSignOut);
|
|
636
605
|
this.events.subscribe('uidConvSelected:changed', this.subscribeChangedConversationSelected);
|
|
637
606
|
this.events.subscribe('profileInfoButtonClick:logout', this.subscribeProfileInfoButtonLogOut);
|
|
638
607
|
|
|
@@ -677,6 +646,7 @@ export class AppComponent implements OnInit {
|
|
|
677
646
|
// this.removePresenceAndLogout()
|
|
678
647
|
// }
|
|
679
648
|
|
|
649
|
+
|
|
680
650
|
if (hasClickedLogout === true) {
|
|
681
651
|
// ----------------------------------------------
|
|
682
652
|
// PUSH NOTIFICATIONS
|
|
@@ -691,7 +661,7 @@ export class AppComponent implements OnInit {
|
|
|
691
661
|
that.removePresenceAndLogout();
|
|
692
662
|
} else {
|
|
693
663
|
that.removePresenceAndLogout();
|
|
694
|
-
that.presentToast();
|
|
664
|
+
// that.presentToast();
|
|
695
665
|
}
|
|
696
666
|
})
|
|
697
667
|
}
|
|
@@ -782,7 +752,7 @@ export class AppComponent implements OnInit {
|
|
|
782
752
|
const keys = ['YOU'];
|
|
783
753
|
const translationMap = this.translateService.translateLanguage(keys);
|
|
784
754
|
|
|
785
|
-
this.logger.
|
|
755
|
+
this.logger.log('[APP-COMP] initConversationsHandler ------------->', userId, this.tenant);
|
|
786
756
|
// 1 - init chatConversationsHandler and archviedConversationsHandler
|
|
787
757
|
this.conversationsHandlerService.initialize(this.tenant, userId, translationMap);
|
|
788
758
|
|
|
@@ -791,7 +761,7 @@ export class AppComponent implements OnInit {
|
|
|
791
761
|
this.logger.log('[APP-COMP]-CONVS- INIT CONV')
|
|
792
762
|
|
|
793
763
|
const conversations = this.conversationsHandlerService.conversations;
|
|
794
|
-
this.logger.
|
|
764
|
+
this.logger.info('initialize FROM [APP-COMP] - [APP-COMP]-CONVS - INIT CONV CONVS', conversations)
|
|
795
765
|
|
|
796
766
|
// this.logger.printDebug('SubscribeToConversations (convs-list-page) - conversations')
|
|
797
767
|
if (!conversations || conversations.length === 0) {
|
|
@@ -850,24 +820,35 @@ export class AppComponent implements OnInit {
|
|
|
850
820
|
}
|
|
851
821
|
}
|
|
852
822
|
|
|
823
|
+
// Storage event not firing: This won't work on the same page that is making the changes
|
|
824
|
+
// https://stackoverflow.com/questions/35865481/storage-event-not-firing
|
|
825
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
|
|
853
826
|
@HostListener('window:storage', ['$event'])
|
|
854
827
|
onStorageChanged(event: any) {
|
|
855
|
-
|
|
828
|
+
|
|
829
|
+
if (event.key !== 'chat_sv5__tiledeskToken') {
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
|
|
856
833
|
if (this.appStorageService.getItem('tiledeskToken') === null) {
|
|
834
|
+
this.logger.log('[APP-COMP] - onStorageChanged tiledeskToken is null - RUN LOGOUT')
|
|
857
835
|
this.tiledeskAuthService.logOut()
|
|
858
836
|
this.messagingAuthService.logout();
|
|
837
|
+
this.events.publish('profileInfoButtonClick:logout', true);
|
|
859
838
|
}
|
|
860
839
|
else {
|
|
861
|
-
|
|
862
|
-
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
863
|
-
if (currentUser) {
|
|
864
|
-
console.log('[APP-COMP] - onStorageChanged currentUser', currentUser)
|
|
865
|
-
} else {
|
|
866
|
-
this.initializeApp()
|
|
867
|
-
}
|
|
868
|
-
}, 1000);
|
|
840
|
+
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
869
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');
|
|
847
|
+
|
|
848
|
+
}
|
|
870
849
|
}
|
|
871
850
|
}
|
|
872
851
|
|
|
852
|
+
|
|
853
|
+
|
|
873
854
|
}
|
package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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 {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
<!-- [ngStyle] = "{ 'width': media_width +'px' }" -->
|
|
2
|
-
|
|
3
|
-
<p #messageEl class="message_innerhtml marked" [ngStyle] = "{ 'width': message.type === 'image' ? media_width +'px' : '' }"
|
|
1
|
+
<!-- [ngStyle] = "{ 'width': message.type === 'image' ? media_width +'px' : '' }" -->
|
|
2
|
+
<p #messageEl class="message_innerhtml marked"
|
|
4
3
|
[innerHTML]="printMessage(text, messageEl, this) | htmlEntiesEncode | marked"
|
|
5
4
|
[ngStyle]="{'color': '$'+ color }">
|
|
6
5
|
</p>
|
|
@@ -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
|
-
|
|
92
|
+
this.logger.log('[CONTACTS-DIRECTORY] DSHBRD STORED USER > TOKEN: ', user.token);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
return token;
|
|
@@ -204,7 +204,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
204
204
|
|
|
205
205
|
this.networkService.checkInternetFunc().subscribe(isOnline => {
|
|
206
206
|
this.checkInternet = isOnline
|
|
207
|
-
console.log('[CONVS-LIST-PAGE] - watchToConnectionStatus - isOnline', this.checkInternet)
|
|
207
|
+
// console.log('[CONVS-LIST-PAGE] - watchToConnectionStatus - isOnline', this.checkInternet)
|
|
208
208
|
|
|
209
209
|
// checking internet connection
|
|
210
210
|
if (this.checkInternet == true) {
|
|
@@ -627,20 +627,20 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
627
627
|
// msg =  + [${metadata.name}](${metadata.src})
|
|
628
628
|
msg = `[${metadata.name}](${metadata.src})`
|
|
629
629
|
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// else if (type === 'image') {
|
|
633
|
+
// if (msg) {
|
|
634
|
+
// // msg = msg + '<br>' + 'File: ' + metadata.src;
|
|
635
|
+
// msg = metadata.name + '\n' + msg
|
|
634
636
|
|
|
635
|
-
|
|
637
|
+
// } else {
|
|
636
638
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
+
// msg = metadata.name
|
|
640
|
+
// }
|
|
641
|
+
|
|
642
|
+
// }
|
|
639
643
|
|
|
640
|
-
}
|
|
641
|
-
// <a href="/images/myw3schoolsimage.jpg" download>
|
|
642
|
-
// <img src="/images/myw3schoolsimage.jpg" alt="W3Schools" width="104" height="142">
|
|
643
|
-
// </a>
|
|
644
644
|
|
|
645
645
|
(metadata) ? metadata = metadata : metadata = '';
|
|
646
646
|
this.logger.log('[CONVS-DETAIL] - SEND MESSAGE msg: ', msg, ' - messages: ', this.messages, ' - loggedUser: ', this.loggedUser);
|
|
@@ -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;
|
|
@@ -60,7 +61,7 @@ export class ConversationListPage implements OnInit {
|
|
|
60
61
|
|
|
61
62
|
public conversationType = 'active'
|
|
62
63
|
headerTitle: string;
|
|
63
|
-
|
|
64
|
+
|
|
64
65
|
|
|
65
66
|
constructor(
|
|
66
67
|
private router: Router,
|
|
@@ -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.
|
|
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
|
|
|
@@ -245,7 +246,7 @@ export class ConversationListPage implements OnInit {
|
|
|
245
246
|
// });
|
|
246
247
|
|
|
247
248
|
this.conversationsHandlerService.conversationAdded.subscribe((conversation: ConversationModel) => {
|
|
248
|
-
this.logger.log('[CONVS-LIST-PAGE] ***** conversationsAdded *****', conversation);
|
|
249
|
+
// this.logger.log('[CONVS-LIST-PAGE] ***** conversationsAdded *****', conversation);
|
|
249
250
|
// that.conversationsChanged(conversations);
|
|
250
251
|
if (conversation) {
|
|
251
252
|
this.onImageLoaded(conversation)
|
|
@@ -254,7 +255,7 @@ export class ConversationListPage implements OnInit {
|
|
|
254
255
|
});
|
|
255
256
|
|
|
256
257
|
this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
|
|
257
|
-
this.logger.log('[CONVS-LIST-PAGE] ***** subscribeConversationChanged *****', conversation);
|
|
258
|
+
// this.logger.log('[CONVS-LIST-PAGE] ***** subscribeConversationChanged *****', conversation);
|
|
258
259
|
// that.conversationsChanged(conversations)
|
|
259
260
|
if (conversation) {
|
|
260
261
|
this.onImageLoaded(conversation)
|
|
@@ -423,13 +424,15 @@ export class ConversationListPage implements OnInit {
|
|
|
423
424
|
this.logger.log('[CONVS-LIST-PAGE] tenant:: ' + this.tenant);
|
|
424
425
|
if (this.route.component['name'] !== "ConversationListPage") {
|
|
425
426
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
427
|
+
if (this.route && this.route.snapshot && this.route.snapshot.firstChild) {
|
|
428
|
+
const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
|
|
429
|
+
this.logger.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv);
|
|
430
|
+
if (IDConv) {
|
|
431
|
+
this.setUidConvSelected(IDConv);
|
|
432
|
+
} else {
|
|
431
433
|
|
|
432
|
-
|
|
434
|
+
this.logger.log('[CONVS-LIST-PAGE] conversationWith 2 (else): ', IDConv);
|
|
435
|
+
}
|
|
433
436
|
}
|
|
434
437
|
}
|
|
435
438
|
}
|
|
@@ -490,7 +493,12 @@ export class ConversationListPage implements OnInit {
|
|
|
490
493
|
}
|
|
491
494
|
|
|
492
495
|
onConversationLoaded(conversation: ConversationModel) {
|
|
493
|
-
|
|
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
|
+
|
|
494
502
|
const keys = ['YOU', 'SENT_AN_IMAGE', 'SENT_AN_ATTACHMENT'];
|
|
495
503
|
const translationMap = this.translateService.translateLanguage(keys);
|
|
496
504
|
// Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly in the convesations list
|
|
@@ -515,14 +523,41 @@ export class ConversationListPage implements OnInit {
|
|
|
515
523
|
conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_IMAGE;
|
|
516
524
|
|
|
517
525
|
} else if (conversation.type === "file") {
|
|
518
|
-
this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
|
|
526
|
+
// this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
|
|
519
527
|
const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
|
|
520
528
|
conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_ATTACHMENT;
|
|
521
529
|
}
|
|
522
|
-
}
|
|
530
|
+
} else {
|
|
531
|
+
if (conversation.type === "image") {
|
|
532
|
+
|
|
533
|
+
// this.logger.log('[CONVS-LIST-PAGE] HAS SENT AN IMAGE');
|
|
534
|
+
// this.logger.log("[CONVS-LIST-PAGE] translationMap.get('YOU')")
|
|
535
|
+
const SENT_AN_IMAGE = conversation['last_message_text'] = translationMap.get('SENT_AN_IMAGE')
|
|
536
|
+
|
|
537
|
+
conversation.last_message_text = SENT_AN_IMAGE;
|
|
538
|
+
|
|
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;
|
|
544
|
+
|
|
545
|
+
}
|
|
546
|
+
}
|
|
523
547
|
}
|
|
524
548
|
}
|
|
525
549
|
|
|
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
|
+
// }
|
|
560
|
+
|
|
526
561
|
|
|
527
562
|
navigateByUrl(converationType: string, uidConvSelected: string) {
|
|
528
563
|
this.logger.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected);
|
|
@@ -652,11 +687,11 @@ export class ConversationListPage implements OnInit {
|
|
|
652
687
|
|
|
653
688
|
}, () => {
|
|
654
689
|
this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *');
|
|
655
|
-
|
|
690
|
+
|
|
656
691
|
});
|
|
657
692
|
}
|
|
658
693
|
|
|
659
|
-
archiveSupportGroupConv(tiledeskToken, project_id,conversationId) {
|
|
694
|
+
archiveSupportGroupConv(tiledeskToken, project_id, conversationId) {
|
|
660
695
|
this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation projectId: ', project_id)
|
|
661
696
|
this.tiledeskService.closeSupportGroup(tiledeskToken, project_id, conversationId).subscribe(res => {
|
|
662
697
|
|
|
@@ -52,7 +52,7 @@ export class NavProxyService {
|
|
|
52
52
|
|
|
53
53
|
// !!!! SEEMS NOT USED
|
|
54
54
|
pushSidebar(page: any, pageName: string, navExtra?) {
|
|
55
|
-
|
|
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
|
-
|
|
67
|
+
this.logger.log('closePage:', pageName, 'checkPlatformIsMobile():', checkPlatformIsMobile());
|
|
68
68
|
if (checkPlatformIsMobile()) {
|
|
69
69
|
const navigationExtras: NavigationExtras = {
|
|
70
70
|
state: {
|
|
@@ -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;
|
|
@@ -88,7 +88,7 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
88
88
|
// this.onAuthStateChanged();
|
|
89
89
|
// }
|
|
90
90
|
// })
|
|
91
|
-
this.checkInternetConnection()
|
|
91
|
+
// this.checkInternetConnection()
|
|
92
92
|
|
|
93
93
|
this.onAuthStateChanged();
|
|
94
94
|
}
|
|
@@ -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') {
|
|
@@ -158,38 +158,43 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
158
158
|
removeNotificationsInstance(callback: (string) => void) {
|
|
159
159
|
var self = this;
|
|
160
160
|
firebase.auth().onAuthStateChanged(function (user) {
|
|
161
|
+
|
|
161
162
|
if (user) {
|
|
162
|
-
self.logger.debug('[FIREBASE-NOTIFICATIONS] - User is signed in. ', user)
|
|
163
|
+
self.logger.debug('[FIREBASE-NOTIFICATIONS] - FB User is signed in. ', user)
|
|
164
|
+
|
|
165
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.userId', self.userId);
|
|
166
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > FCMcurrentToken', self.FCMcurrentToken);
|
|
167
|
+
// this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.tenant', this.tenant);
|
|
168
|
+
|
|
163
169
|
|
|
164
170
|
} else {
|
|
165
|
-
self.logger.debug('[FIREBASE-NOTIFICATIONS] - No user is signed in. ', user)
|
|
171
|
+
self.logger.debug('[FIREBASE-NOTIFICATIONS] - No FB user is signed in. ', user)
|
|
166
172
|
}
|
|
167
173
|
});
|
|
168
174
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const urlNodeFirebase = '/apps/' + this.tenant
|
|
173
|
-
const connectionsRefinstancesId = urlNodeFirebase + '/users/' + this.userId + '/instances/'
|
|
174
|
-
this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
|
|
175
|
+
const urlNodeFirebase = '/apps/' + self.tenant
|
|
176
|
+
const connectionsRefinstancesId = urlNodeFirebase + '/users/' + self.userId + '/instances/'
|
|
177
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
|
|
175
178
|
let connectionsRefURL = '';
|
|
176
179
|
if (connectionsRefinstancesId) {
|
|
177
|
-
connectionsRefURL = connectionsRefinstancesId +
|
|
180
|
+
connectionsRefURL = connectionsRefinstancesId + self.FCMcurrentToken;
|
|
178
181
|
const connectionsRef = firebase.database().ref().child(connectionsRefURL);
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef ', connectionsRef);
|
|
183
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef url ', connectionsRefURL);
|
|
181
184
|
connectionsRef.off()
|
|
182
185
|
connectionsRef.remove()
|
|
183
186
|
.then(() => {
|
|
184
|
-
|
|
187
|
+
self.logger.log("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > Remove succeeded.")
|
|
185
188
|
callback('success')
|
|
186
189
|
}).catch((error) => {
|
|
187
|
-
|
|
190
|
+
self.logger.error("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance Remove failed: " + error.message)
|
|
188
191
|
callback('error')
|
|
189
192
|
}).finally(() => {
|
|
190
|
-
|
|
193
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] COMPLETED');
|
|
191
194
|
})
|
|
192
195
|
}
|
|
196
|
+
|
|
197
|
+
|
|
193
198
|
}
|
|
194
199
|
|
|
195
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
|
|
|
@@ -22,9 +26,12 @@ export class TiledeskAuthService {
|
|
|
22
26
|
private tiledeskToken: string;
|
|
23
27
|
private currentUser: UserModel;
|
|
24
28
|
private logger: LoggerService = LoggerInstance.getInstance()
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
public http: HttpClient,
|
|
32
|
+
public appStorage: AppStorageService,
|
|
33
|
+
// private events: EventsService,
|
|
34
|
+
) { }
|
|
28
35
|
|
|
29
36
|
|
|
30
37
|
initialize(serverBaseUrl: string) {
|
|
@@ -57,7 +64,8 @@ export class TiledeskAuthService {
|
|
|
57
64
|
if (data['success'] && data['token']) {
|
|
58
65
|
that.tiledeskToken = data['token'];
|
|
59
66
|
that.createCompleteUser(data['user']);
|
|
60
|
-
that.appStorage.setItem('tiledeskToken', that.tiledeskToken);
|
|
67
|
+
// that.appStorage.setItem('tiledeskToken', that.tiledeskToken);
|
|
68
|
+
this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
|
|
61
69
|
resolve(that.tiledeskToken)
|
|
62
70
|
}
|
|
63
71
|
}, (error) => {
|
|
@@ -86,7 +94,8 @@ export class TiledeskAuthService {
|
|
|
86
94
|
if (data['success'] && data['token']) {
|
|
87
95
|
that.tiledeskToken = data['token'];
|
|
88
96
|
that.createCompleteUser(data['user']);
|
|
89
|
-
that.appStorage.setItem('tiledeskToken', that.tiledeskToken);
|
|
97
|
+
// that.appStorage.setItem('tiledeskToken', that.tiledeskToken);
|
|
98
|
+
this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
|
|
90
99
|
resolve(that.tiledeskToken)
|
|
91
100
|
}
|
|
92
101
|
}, (error) => {
|
|
@@ -111,7 +120,9 @@ export class TiledeskAuthService {
|
|
|
111
120
|
if (data['success'] && data['token']) {
|
|
112
121
|
that.tiledeskToken = data['token'];
|
|
113
122
|
that.createCompleteUser(data['user']);
|
|
114
|
-
|
|
123
|
+
|
|
124
|
+
// that.appStorage.setItem('tiledeskToken', that.tiledeskToken); // salvarlo esternamente nell'app.component
|
|
125
|
+
this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
|
|
115
126
|
resolve(this.currentUser)
|
|
116
127
|
}
|
|
117
128
|
}, (error) => {
|
|
@@ -120,11 +131,13 @@ export class TiledeskAuthService {
|
|
|
120
131
|
});
|
|
121
132
|
}
|
|
122
133
|
|
|
123
|
-
logOut(){
|
|
124
|
-
this.logger.
|
|
134
|
+
logOut() {
|
|
135
|
+
this.logger.log('[TILEDESK-AUTH] - LOGOUT')
|
|
125
136
|
this.appStorage.removeItem('tiledeskToken')
|
|
126
137
|
this.appStorage.removeItem('currentUser')
|
|
127
138
|
this.setCurrentUser(null);
|
|
139
|
+
// this.isOnline$.next(false)
|
|
140
|
+
|
|
128
141
|
}
|
|
129
142
|
|
|
130
143
|
|
|
@@ -150,13 +163,29 @@ export class TiledeskAuthService {
|
|
|
150
163
|
member.fullname = fullname;
|
|
151
164
|
member.avatar = avatar;
|
|
152
165
|
member.color = color;
|
|
153
|
-
this.currentUser = member;
|
|
154
|
-
this.logger.
|
|
166
|
+
this.currentUser = member;
|
|
167
|
+
this.logger.log('[TILEDESK-AUTH] - createCompleteUser member ', member);
|
|
155
168
|
this.appStorage.setItem('currentUser', JSON.stringify(this.currentUser));
|
|
169
|
+
// this.isOnline$.next(true)
|
|
156
170
|
} catch (err) {
|
|
157
|
-
this.logger.error('[TILEDESK-AUTH]- createCompleteUser ERR ', err)
|
|
171
|
+
this.logger.error('[TILEDESK-AUTH]- createCompleteUser ERR ', err)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
private checkAndSetInStorageTiledeskToken(tiledeskToken) {
|
|
177
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken tiledeskToken from request', tiledeskToken)
|
|
178
|
+
const storedTiledeskToken = this.appStorage.getItem('tiledeskToken');
|
|
179
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken storedTiledeskToken ', storedTiledeskToken)
|
|
180
|
+
if (!storedTiledeskToken) {
|
|
181
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken TOKEN DOES NOT EXIST - RUN SET ')
|
|
182
|
+
this.appStorage.setItem('tiledeskToken', tiledeskToken);
|
|
183
|
+
} else if (storedTiledeskToken && storedTiledeskToken !== tiledeskToken) {
|
|
184
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken STORED-TOKEN EXIST BUT IS != FROM TOKEN - RUN SET ')
|
|
185
|
+
this.appStorage.setItem('tiledeskToken', tiledeskToken);
|
|
186
|
+
} else if (storedTiledeskToken && storedTiledeskToken === tiledeskToken){
|
|
187
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken STORED-TOKEN EXIST AND IS = TO TOKEN ')
|
|
158
188
|
}
|
|
159
|
-
|
|
160
189
|
}
|
|
161
190
|
|
|
162
191
|
|
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
|