@chat21/chat21-ionic 3.0.55-RC6 → 3.0.57

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 (73) hide show
  1. package/CHANGELOG.md +95 -1
  2. package/package.json +1 -1
  3. package/src/app/app.component.scss +1 -0
  4. package/src/app/app.component.ts +615 -515
  5. package/src/app/app.module.ts +1 -1
  6. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +2 -1
  7. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +44 -24
  8. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +7 -8
  9. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +9 -7
  10. package/src/app/chatlib/conversation-detail/message/avatar/avatar.component.ts +1 -1
  11. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +22 -14
  12. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +85 -45
  13. package/src/app/chatlib/conversation-detail/message/buttons/action-button/action-button.component.scss +1 -1
  14. package/src/app/chatlib/conversation-detail/message/buttons/action-button/action-button.component.ts +1 -1
  15. package/src/app/chatlib/conversation-detail/message/buttons/link-button/link-button.component.scss +4 -4
  16. package/src/app/chatlib/conversation-detail/message/buttons/link-button/link-button.component.ts +1 -1
  17. package/src/app/chatlib/conversation-detail/message/buttons/text-button/text-button.component.scss +1 -1
  18. package/src/app/chatlib/conversation-detail/message/buttons/text-button/text-button.component.ts +1 -1
  19. package/src/app/chatlib/conversation-detail/message/frame/frame.component.ts +4 -2
  20. package/src/app/chatlib/conversation-detail/message/image/image.component.html +9 -8
  21. package/src/app/chatlib/conversation-detail/message/image/image.component.scss +3 -2
  22. package/src/app/chatlib/conversation-detail/message/image/image.component.ts +35 -3
  23. package/src/app/chatlib/conversation-detail/message/info-message/info-message.component.ts +1 -1
  24. package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.html +56 -0
  25. package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.scss +169 -0
  26. package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.spec.ts +33 -0
  27. package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.ts +80 -0
  28. package/src/app/chatlib/conversation-detail/message/return-receipt/return-receipt.component.ts +1 -1
  29. package/src/app/chatlib/conversation-detail/message/text/text.component.html +2 -1
  30. package/src/app/chatlib/conversation-detail/message/text/text.component.ts +4 -4
  31. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +40 -13
  32. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +147 -1
  33. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +47 -2
  34. package/src/app/components/authentication/login/login.component.scss +1 -1
  35. package/src/app/components/contacts-directory/contacts-directory.component.html +3 -2
  36. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +2 -2
  37. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +28 -13
  38. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +1 -2
  39. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +10 -6
  40. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +46 -43
  41. package/src/app/components/conversation-info/advanced-info-accordion/advanced-info-accordion.component.html +2 -2
  42. package/src/app/components/conversation-info/info-content/info-content.component.ts +15 -5
  43. package/src/app/components/conversation-info/info-group/info-group.component.ts +4 -4
  44. package/src/app/components/utils/avatar-profile/avatar-profile.component.html +2 -1
  45. package/src/app/components/utils/user-presence/user-presence.component.ts +8 -6
  46. package/src/app/pages/contacts-directory/contacts-directory.page.ts +1 -1
  47. package/src/app/pages/conversation-detail/conversation-detail.page.html +4 -1
  48. package/src/app/pages/conversation-detail/conversation-detail.page.ts +218 -42
  49. package/src/app/pages/conversations-list/conversations-list.page.html +1 -1
  50. package/src/app/pages/conversations-list/conversations-list.page.ts +135 -45
  51. package/src/app/pages/loader-preview/loader-preview.page.html +1 -1
  52. package/src/app/pages/loader-preview/loader-preview.page.ts +18 -5
  53. package/src/app/pages/profile-info/profile-info.page.html +2 -0
  54. package/src/app/services/nav-proxy.service.ts +2 -2
  55. package/src/app/services/network-service/network.service.spec.ts +12 -0
  56. package/src/app/services/network-service/network.service.ts +46 -0
  57. package/src/app/shared/shared.module.ts +2 -0
  58. package/src/assets/i18n/en.json +4 -2
  59. package/src/assets/i18n/it.json +5 -3
  60. package/src/chat21-core/providers/abstract/app-storage.service.ts +2 -2
  61. package/src/chat21-core/providers/chat-manager.ts +2 -1
  62. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +3 -2
  63. package/src/chat21-core/providers/firebase/firebase-auth-service.ts +112 -69
  64. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +4 -4
  65. package/src/chat21-core/providers/firebase/firebase-image-repo.ts +1 -1
  66. package/src/chat21-core/providers/firebase/firebase-notifications.ts +29 -29
  67. package/src/chat21-core/providers/firebase/firebase-presence.service.ts +1 -0
  68. package/src/chat21-core/providers/localSessionStorage.ts +155 -154
  69. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +42 -12
  70. package/src/chat21-core/utils/user-typing/user-typing.component.html +6 -11
  71. package/src/chat21-core/utils/utils.ts +3 -3
  72. package/src/global.scss +17 -0
  73. package/src/index.html +27 -59
@@ -33,6 +33,7 @@ import { LoggerService } from '../abstract/logger.service';
33
33
  import { Observable, Observer, fromEvent, merge } from 'rxjs';
34
34
  import { map } from 'rxjs/operators'
35
35
  import { Network } from '@ionic-native/network/ngx';
36
+
36
37
  // @Injectable({ providedIn: 'root' })
37
38
  @Injectable()
38
39
  export class FirebaseAuthService extends MessagingAuthService {
@@ -60,40 +61,58 @@ export class FirebaseAuthService extends MessagingAuthService {
60
61
 
61
62
  status = 'ONLINE';
62
63
  isConnected = true;
63
-
64
+ unsubscribe: any;
64
65
  constructor(
65
66
  public http: HttpClient,
66
67
  private network: Network,
67
68
  private connectionService: ConnectionService
68
69
  ) {
69
70
  super();
71
+ // this.initialize()
70
72
  }
71
73
 
72
74
  /**
73
75
  *
74
76
  */
75
77
  initialize() {
76
-
78
+ console.log('initialize FROM [APP-COMP] [FIREBASEAuthSERVICE]')
77
79
  this.SERVER_BASE_URL = this.getBaseUrl();
78
80
  this.URL_TILEDESK_CREATE_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'chat21/firebase/auth/createCustomToken';
79
81
  this.logger.info('[FIREBASEAuthSERVICE] - initialize URL_TILEDESK_CREATE_CUSTOM_TOKEN ', this.URL_TILEDESK_CREATE_CUSTOM_TOKEN)
80
- // this.URL_TILEDESK_SIGNIN = this.SERVER_BASE_URL + 'auth/signin';
81
- // this.URL_TILEDESK_SIGNIN_ANONYMOUSLY = this.SERVER_BASE_URL + 'auth/signinAnonymously'
82
- // this.URL_TILEDESK_SIGNIN_WITH_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'auth/signinWithCustomToken';
83
- // this.checkIsAuth();
84
-
85
- // this.createOnline$().subscribe((isOnline) =>{
86
- // console.log('FIREBASEAuthSERVICE] isOnline ', isOnline);
87
- // if (isOnline === true ) {
88
- // this.onAuthStateChanged();
89
- // }
90
- // })
91
- this.checkInternetConnection()
92
82
 
93
- this.onAuthStateChanged();
83
+
84
+ let firebasePersistence;
85
+ // console.log('FB-AUTH firebasePersistence', this.getPersistence())
86
+ switch (this.getPersistence()) {
87
+ case 'SESSION': {
88
+ firebasePersistence = firebase.auth.Auth.Persistence.SESSION;
89
+ break;
90
+ }
91
+ case 'LOCAL': {
92
+ firebasePersistence = firebase.auth.Auth.Persistence.LOCAL;
93
+ break;
94
+ }
95
+ case 'NONE': {
96
+ firebasePersistence = firebase.auth.Auth.Persistence.NONE;
97
+ break;
98
+ }
99
+ default: {
100
+ firebasePersistence = firebase.auth.Auth.Persistence.NONE;
101
+ break;
102
+ }
103
+ }
104
+ firebase.auth().setPersistence(firebasePersistence).then(async () => {
105
+ console.log('[FIREBASEAuthSERVICE] firebasePersistence ', firebasePersistence)
106
+ this.onAuthStateChanged();
107
+ })
108
+ .catch((error) => {
109
+ this.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
110
+ });
111
+
112
+
94
113
  }
95
114
 
96
- checkInternetConnection () {
115
+ checkInternetConnection() {
97
116
  this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection');
98
117
  // let connectSubscription = this.network.onConnect().subscribe(() => {
99
118
  // this.logger.log('[FIREBASEAuthSERVICE] - network connected!');
@@ -107,28 +126,28 @@ export class FirebaseAuthService extends MessagingAuthService {
107
126
  // }, 3000);
108
127
  // });
109
128
 
110
-
111
- this.connectionService.monitor().subscribe(isConnected => {
112
- this.isConnected = isConnected;
113
- this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection isConnected', isConnected);
114
- if (this.isConnected) {
115
- this.status = "ONLINE";
116
-
117
- // this.onAuthStateChanged();
118
- firebase.auth().onAuthStateChanged(user => {
119
- this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
120
- })
121
- }
122
- else {
123
- this.status = "OFFLINE";
124
- // this.onAuthStateChanged();
125
- firebase.auth().onAuthStateChanged(user => {
126
- this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
127
- })
128
- }
129
- })
130
-
131
-
129
+
130
+ // this.connectionService.monitor().subscribe(isConnected => {
131
+ // this.isConnected = isConnected;
132
+ // this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection isConnected', isConnected);
133
+ // if (this.isConnected) {
134
+ // this.status = "ONLINE";
135
+
136
+ // // this.onAuthStateChanged();
137
+ // firebase.auth().onAuthStateChanged(user => {
138
+ // this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
139
+ // })
140
+ // }
141
+ // else {
142
+ // this.status = "OFFLINE";
143
+ // // this.onAuthStateChanged();
144
+ // firebase.auth().onAuthStateChanged(user => {
145
+ // this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
146
+ // })
147
+ // }
148
+ // })
149
+
150
+
132
151
  }
133
152
 
134
153
  // createOnline$() {
@@ -178,16 +197,37 @@ export class FirebaseAuthService extends MessagingAuthService {
178
197
  */
179
198
  onAuthStateChanged() {
180
199
  const that = this;
181
- firebase.auth().onAuthStateChanged(user => {
182
- this.logger.log('[FIREBASEAuthSERVICE] onAuthStateChanged', user)
200
+
201
+ // ---------------------------------------------------------------------------------------------------
202
+ // Protecting from multiple subsciptions due to multiple app initializations (call to initializeApp())
203
+ // Only one subscriber x application allowed
204
+ // ---------------------------------------------------------------------------------------------------
205
+ if (this.unsubscribe) {
206
+ console.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged ALREADY SUBSCRIBED')
207
+ return
208
+ }
209
+
210
+ this.unsubscribe = firebase.auth().onAuthStateChanged(user => {
211
+ console.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged', user)
183
212
  if (!user) {
184
213
  this.logger.log('[FIREBASEAuthSERVICE] 1 - PASSO OFFLINE AL CHAT MANAGER')
214
+ // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged user ', user)
215
+
185
216
  that.BSAuthStateChanged.next('offline');
217
+ // console.log('initialize FROM [APP-COMP] that.BSAuthStateChanged ', that.BSAuthStateChanged)
186
218
  } else {
187
219
  this.logger.log('[FIREBASEAuthSERVICE] 2 - PASSO ONLINE AL CHAT MANAGER')
220
+ // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged user ', user)
188
221
  that.BSAuthStateChanged.next('online');
189
222
  }
223
+ }, error => {
224
+ this.logger.error('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged * error * ', error)
225
+ }, () => {
226
+ this.logger.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged *** complete *** ');
227
+
190
228
  });
229
+
230
+
191
231
  }
192
232
 
193
233
  /**
@@ -195,36 +235,34 @@ export class FirebaseAuthService extends MessagingAuthService {
195
235
  * @param token
196
236
  */
197
237
  signInFirebaseWithCustomToken(token: string): Promise<any> {
198
- const that = this;
199
- let firebasePersistence;
200
- console.log('FB-AUTH firebasePersistence', this.getPersistence())
201
- switch (this.getPersistence()) {
202
- case 'SESSION': {
203
- firebasePersistence = firebase.auth.Auth.Persistence.SESSION;
204
- break;
205
- }
206
- case 'LOCAL': {
207
- firebasePersistence = firebase.auth.Auth.Persistence.LOCAL;
208
- break;
209
- }
210
- case 'NONE': {
211
- firebasePersistence = firebase.auth.Auth.Persistence.NONE;
212
- break;
213
- }
214
- default: {
215
- firebasePersistence = firebase.auth.Auth.Persistence.NONE;
216
- break;
217
- }
218
- }
219
- return firebase.auth().setPersistence(firebasePersistence).then(async () => {
220
- return firebase.auth().signInWithCustomToken(token).then(async () => {
221
- // that.firebaseSignInWithCustomToken.next(response);
222
- }).catch((error) => {
223
- that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
224
- // that.firebaseSignInWithCustomToken.next(null);
225
- });
238
+ // const that = this;
239
+ // let firebasePersistence;
240
+ // // console.log('FB-AUTH firebasePersistence', this.getPersistence())
241
+ // switch (this.getPersistence()) {
242
+ // case 'SESSION': {
243
+ // firebasePersistence = firebase.auth.Auth.Persistence.SESSION;
244
+ // break;
245
+ // }
246
+ // case 'LOCAL': {
247
+ // firebasePersistence = firebase.auth.Auth.Persistence.LOCAL;
248
+ // break;
249
+ // }
250
+ // case 'NONE': {
251
+ // firebasePersistence = firebase.auth.Auth.Persistence.NONE;
252
+ // break;
253
+ // }
254
+ // default: {
255
+ // firebasePersistence = firebase.auth.Auth.Persistence.NONE;
256
+ // break;
257
+ // }
258
+ // }
259
+ // return firebase.auth().setPersistence(firebasePersistence).then(async () => {
260
+ return firebase.auth().signInWithCustomToken(token).then(async (user) => {
261
+
262
+ // that.firebaseSignInWithCustomToken.next(response);
226
263
  }).catch((error) => {
227
- that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
264
+ this.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
265
+ // that.firebaseSignInWithCustomToken.next(null);
228
266
  });
229
267
  }
230
268
 
@@ -271,6 +309,8 @@ export class FirebaseAuthService extends MessagingAuthService {
271
309
  // cancello token
272
310
  // this.appStorage.removeItem('tiledeskToken');
273
311
  //localStorage.removeItem('firebaseToken');
312
+
313
+
274
314
  that.BSSignOut.next(true);
275
315
  }).catch((error) => {
276
316
  that.logger.error('[FIREBASEAuthSERVICE] signOut error: ', error);
@@ -317,9 +357,12 @@ export class FirebaseAuthService extends MessagingAuthService {
317
357
 
318
358
  logout() {
319
359
  this.logger.log('[FIREBASEAuthSERVICE] logout');
360
+ this.BSAuthStateChanged.next(null);
361
+
320
362
  // cancello token firebase dal local storage e da firebase
321
363
  // dovrebbe scattare l'evento authchangeStat
322
364
  this.signOut();
365
+ // this.unsubscribe();
323
366
  }
324
367
 
325
368
  }
@@ -217,7 +217,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
217
217
 
218
218
  this.getFirebaseToken((error, idToken) => {
219
219
  this.logger.debug('[FIREBASEConversationsHandlerSERVICE] DELETE CONV idToken', idToken)
220
- this.logger.error('F[FIREBASEConversationsHandlerSERVICE] DELETE CONV error', error)
220
+ this.logger.debug('F[FIREBASEConversationsHandlerSERVICE] DELETE CONV error', error)
221
221
  if (idToken) {
222
222
  const httpOptions = {
223
223
  headers: new HttpHeaders({
@@ -282,8 +282,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
282
282
  this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot.val() *****', childSnapshot.val());
283
283
  this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot *****', childSnapshot)
284
284
  // && childData.uid
285
- if (childSnapshot && childSnapshot.key) {
286
- // if (childData) {
285
+ if (childSnapshot && childSnapshot.key && childData) {
287
286
  childData.uid = childSnapshot.key;
288
287
  const conversation = this.completeConversation(childData);
289
288
  if (conversation) {
@@ -291,6 +290,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
291
290
  } else {
292
291
  callback(null)
293
292
  }
293
+
294
294
  }
295
295
  // this.BSConversationDetail.next(conversation);
296
296
  });
@@ -400,7 +400,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
400
400
  this.conversationAdded.next(conversationAdded);
401
401
  }
402
402
  } else {
403
- this.logger.error('[FIREBASEConversationsHandlerSERVICE]ADDED::conversations with conversationId: ', childSnapshot.key, 'is not valid')
403
+ this.logger.log('[FIREBASEConversationsHandlerSERVICE]ADDED::conversations with conversationId: ', childSnapshot.key, 'is not valid')
404
404
  }
405
405
  }
406
406
 
@@ -27,7 +27,7 @@ export class FirebaseImageRepoService extends ImageRepoService {
27
27
  getImagePhotoUrl(uid: string): string {
28
28
  this.baseImageURL = this.getImageBaseUrl()
29
29
  let sender_id = '';
30
- if (uid.includes('bot_')) {
30
+ if (uid && uid.includes('bot_')) {
31
31
  sender_id = uid.slice(4)
32
32
  } else {
33
33
  sender_id = uid
@@ -39,10 +39,10 @@ export class FirebaseNotifications extends NotificationsService {
39
39
  navigator.serviceWorker.getRegistrations().then((serviceWorkerRegistrations) => {
40
40
  this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser serviceWorkerRegistrations", serviceWorkerRegistrations)
41
41
  if (serviceWorkerRegistrations.length > 0) {
42
- serviceWorkerRegistrations.forEach(registrations => {
43
-
44
- this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations scriptURL", registrations.active.scriptURL)
45
- this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations state", registrations.active.state)
42
+ serviceWorkerRegistrations.forEach(registration => {
43
+ this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registration ", registration)
44
+ // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations scriptURL", registrations.active.scriptURL)
45
+ // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations state", registrations.active.state)
46
46
 
47
47
  });
48
48
  } else {
@@ -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,8 +76,9 @@ export class FirebaseNotifications extends NotificationsService {
76
76
  // }
77
77
 
78
78
 
79
- const messaging = firebase.messaging();
79
+
80
80
  if (firebase.messaging.isSupported()) {
81
+ const messaging = firebase.messaging();
81
82
  // messaging.requestPermission()
82
83
  Notification.requestPermission().then((permission) => {
83
84
  if (permission === 'granted') {
@@ -156,39 +157,38 @@ export class FirebaseNotifications extends NotificationsService {
156
157
 
157
158
  removeNotificationsInstance(callback: (string) => void) {
158
159
  var self = this;
159
- firebase.auth().onAuthStateChanged(function (user) {
160
- if (user) {
161
- self.logger.debug('[FIREBASE-NOTIFICATIONS] - User is signed in. ', user)
162
-
163
- } else {
164
- self.logger.debug('[FIREBASE-NOTIFICATIONS] - No user is signed in. ', user)
165
- }
166
- });
167
-
168
- this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.userId', this.userId);
169
- this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > FCMcurrentToken', this.FCMcurrentToken);
170
- // this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.tenant', this.tenant);
171
- const urlNodeFirebase = '/apps/' + this.tenant
172
- const connectionsRefinstancesId = urlNodeFirebase + '/users/' + this.userId + '/instances/'
173
- this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
160
+ // firebase.auth().onAuthStateChanged(function (user) {
161
+ // if (user) {
162
+ // self.logger.debug('[FIREBASE-NOTIFICATIONS] - FB User is signed in. ', user)
163
+ // self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.userId', self.userId);
164
+ // self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > FCMcurrentToken', self.FCMcurrentToken);
165
+ // // this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.tenant', this.tenant);
166
+ // } else {
167
+ // self.logger.debug('[FIREBASE-NOTIFICATIONS] - No FB user is signed in. ', user)
168
+ // }
169
+ // });
170
+ const urlNodeFirebase = '/apps/' + self.tenant
171
+ const connectionsRefinstancesId = urlNodeFirebase + '/users/' + self.userId + '/instances/'
172
+ self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
174
173
  let connectionsRefURL = '';
175
174
  if (connectionsRefinstancesId) {
176
- connectionsRefURL = connectionsRefinstancesId + this.FCMcurrentToken;
175
+ connectionsRefURL = connectionsRefinstancesId + self.FCMcurrentToken;
177
176
  const connectionsRef = firebase.database().ref().child(connectionsRefURL);
178
- this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef ', connectionsRef);
179
- this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef url ', connectionsRefURL);
177
+ self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef ', connectionsRef);
178
+ self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef url ', connectionsRefURL);
180
179
  connectionsRef.off()
181
180
  connectionsRef.remove()
182
181
  .then(() => {
183
- this.logger.log("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > Remove succeeded.")
182
+ self.logger.log("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > Remove succeeded.")
184
183
  callback('success')
185
184
  }).catch((error) => {
186
- this.logger.error("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance Remove failed: " + error.message)
185
+ self.logger.error("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance Remove failed: " + error.message)
187
186
  callback('error')
188
187
  }).finally(() => {
189
- this.logger.log('[FIREBASE-NOTIFICATIONS] COMPLETED');
188
+ self.logger.log('[FIREBASE-NOTIFICATIONS] COMPLETED');
190
189
  })
191
190
  }
191
+
192
192
  }
193
193
 
194
194
  // 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';