@chat21/chat21-ionic 3.0.54-RC2 → 3.0.55-RC6
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 +20 -0
- package/LICENSE +21 -0
- package/config.xml +1 -0
- package/package.json +6 -2
- package/resources/Android/icon/drawable-hdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-ldpi-icon.png +0 -0
- package/resources/Android/icon/drawable-mdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xhdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xxhdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xxxhdpi-icon.png +0 -0
- package/resources/Android/icon.png +0 -0
- package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash.png +0 -0
- package/src/app/app.component.ts +504 -433
- package/src/app/app.module.ts +9 -4
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +4 -0
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +27 -30
- package/src/app/chatlib/conversation-detail/message/text/text.component.html +1 -1
- package/src/app/chatlib/conversation-detail/message/text/text.component.ts +27 -3
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +4 -4
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +5 -5
- package/src/app/components/conversation-info/info-content/info-content.component.ts +8 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +33 -25
- package/src/chat-config-pre-test.json +2 -1
- package/src/chat21-core/providers/abstract/messagingAuth.service.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +3 -2
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +84 -17
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +6 -4
- package/src/chat21-core/providers/localSessionStorage.ts +2 -1
- package/src/index.html +87 -6
package/src/app/app.component.ts
CHANGED
|
@@ -8,7 +8,10 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|
|
8
8
|
import { Subscription } from 'rxjs';
|
|
9
9
|
import { ModalController } from '@ionic/angular';
|
|
10
10
|
|
|
11
|
-
import * as firebase from 'firebase/app';
|
|
11
|
+
// import * as firebase from 'firebase/app';
|
|
12
|
+
import firebase from "firebase/app";
|
|
13
|
+
import 'firebase/auth'; // nk in watch connection status
|
|
14
|
+
|
|
12
15
|
import { StatusBar } from '@ionic-native/status-bar/ngx';
|
|
13
16
|
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
|
|
14
17
|
import { TranslateService } from '@ngx-translate/core';
|
|
@@ -45,6 +48,11 @@ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk
|
|
|
45
48
|
// FCM
|
|
46
49
|
import { NotificationsService } from 'src/chat21-core/providers/abstract/notifications.service';
|
|
47
50
|
import { getImageUrlThumbFromFirebasestorage } from 'src/chat21-core/utils/utils-user';
|
|
51
|
+
|
|
52
|
+
import { Network } from '@ionic-native/network/ngx';
|
|
53
|
+
import { Observable, Observer, fromEvent, merge, of } from 'rxjs';
|
|
54
|
+
import { mapTo } from 'rxjs/operators';
|
|
55
|
+
|
|
48
56
|
@Component({
|
|
49
57
|
selector: 'app-root',
|
|
50
58
|
templateUrl: 'app.component.html',
|
|
@@ -55,6 +63,9 @@ export class AppComponent implements OnInit {
|
|
|
55
63
|
@ViewChild('sidebarNav', { static: false }) sidebarNav: IonNav;
|
|
56
64
|
@ViewChild('detailNav', { static: false }) detailNav: IonRouterOutlet;
|
|
57
65
|
|
|
66
|
+
public appIsOnline$: Observable<boolean> = undefined;
|
|
67
|
+
checkInternet: boolean;
|
|
68
|
+
|
|
58
69
|
private subscription: Subscription;
|
|
59
70
|
public sidebarPage: any;
|
|
60
71
|
public notificationsEnabled: boolean;
|
|
@@ -105,7 +116,8 @@ export class AppComponent implements OnInit {
|
|
|
105
116
|
public archivedConversationsHandlerService: ArchivedConversationsHandlerService,
|
|
106
117
|
private translateService: CustomTranslateService,
|
|
107
118
|
public notificationsService: NotificationsService,
|
|
108
|
-
public toastController: ToastController
|
|
119
|
+
public toastController: ToastController,
|
|
120
|
+
private network: Network
|
|
109
121
|
) {
|
|
110
122
|
|
|
111
123
|
const appconfig = appConfigProvider.getConfig();
|
|
@@ -114,6 +126,8 @@ export class AppComponent implements OnInit {
|
|
|
114
126
|
this.tenant = appconfig.firebaseConfig.tenant;
|
|
115
127
|
this.logger.info('[APP-COMP] appconfig firebaseConfig tenant: ', this.tenant)
|
|
116
128
|
this.logger.info('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
|
|
129
|
+
this.logger.info('[APP-COMP] appconfig version: 3.0.55-RC4-test1',)
|
|
130
|
+
|
|
117
131
|
|
|
118
132
|
|
|
119
133
|
|
|
@@ -188,418 +202,474 @@ export class AppComponent implements OnInit {
|
|
|
188
202
|
this.logger.debug('[APP-COMP] initializeApp:: ', this.sidebarNav, this.detailNav);
|
|
189
203
|
// this.listenToLogoutEvent()
|
|
190
204
|
this.translateToastMessage();
|
|
205
|
+
|
|
206
|
+
// ---------------------------------------
|
|
207
|
+
// Watch to network status
|
|
208
|
+
// ---------------------------------------
|
|
209
|
+
this.watchToConnectionStatus()
|
|
191
210
|
});
|
|
192
211
|
}
|
|
193
212
|
|
|
194
|
-
|
|
195
|
-
this.
|
|
196
|
-
.
|
|
197
|
-
|
|
198
|
-
// this.logger.debug('FIREBASE-NOTIFICATION >>>> (APP-COMPONENT) text: ', text)
|
|
199
|
-
this.toastMsg = text;
|
|
200
|
-
// this.logger.debug('FIREBASE-NOTIFICATION >>>> (APP-COMPONENT): this.toastMsg', this.toastMsg)
|
|
201
|
-
});
|
|
202
|
-
}
|
|
213
|
+
watchToConnectionStatus() {
|
|
214
|
+
this.checkInternetFunc().subscribe(isOnline => {
|
|
215
|
+
this.checkInternet = isOnline
|
|
216
|
+
console.log('[APP-COMP] - watchToConnectionStatus - this.checkInterent', this.checkInternet)
|
|
203
217
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
} else {
|
|
215
|
-
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
|
|
216
|
-
const that = this;
|
|
217
|
-
clearTimeout(this.timeModalLogin);
|
|
218
|
-
this.timeModalLogin = setTimeout(() => {
|
|
219
|
-
if (!this.hadBeenCalledOpenModal) {
|
|
220
|
-
this.authModal = this.presentModal('initAuthentication');
|
|
221
|
-
this.hadBeenCalledOpenModal = true;
|
|
222
|
-
}
|
|
223
|
-
}, 1000);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
this.route.queryParams.subscribe(params => {
|
|
227
|
-
if (params.jwt) {
|
|
228
|
-
this.tiledeskAuthService.signInWithCustomToken(params.jwt).then(user => {
|
|
229
|
-
this.messagingAuthService.createCustomToken(params.jwt)
|
|
230
|
-
}).catch(error => { this.logger.error('[APP-COMP] SIGNINWITHCUSTOMTOKEN error::' + error) })
|
|
218
|
+
// checking internet connection
|
|
219
|
+
if (this.checkInternet == true) {
|
|
220
|
+
// show success alert if internet is working
|
|
221
|
+
// alert('Internet is working.')
|
|
222
|
+
console.log('[APP-COMP] - watchToConnectionStatus - Internet is working.')
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
// show danger alert if net internet not working
|
|
226
|
+
// alert('Internet is slow or not working.')
|
|
227
|
+
console.log('[APP-COMP] - watchToConnectionStatus - Internet is slow or not working.')
|
|
231
228
|
}
|
|
232
229
|
});
|
|
233
230
|
}
|
|
234
231
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
232
|
+
checkInternetFunc() {
|
|
233
|
+
if (!window || !navigator || !('onLine' in navigator)) return;
|
|
234
|
+
|
|
235
|
+
this.appIsOnline$ = Observable.create(observer => {
|
|
236
|
+
observer.next(true);
|
|
237
|
+
}).pipe(mapTo(true));
|
|
238
|
+
|
|
239
|
+
if (this.platform.is('cordova')) {
|
|
240
|
+
// on Device - when platform is cordova
|
|
241
|
+
this.appIsOnline$ = merge(
|
|
242
|
+
this.network.onConnect().pipe(mapTo(true)),
|
|
243
|
+
this.network.onDisconnect().pipe(mapTo(false))
|
|
244
|
+
);
|
|
245
|
+
} else {
|
|
246
|
+
// on Browser - when platform is Browser
|
|
247
|
+
this.appIsOnline$ = merge(
|
|
248
|
+
of(navigator.onLine),
|
|
249
|
+
fromEvent(window, 'online').pipe(mapTo(true)),
|
|
250
|
+
fromEvent(window, 'offline').pipe(mapTo(false))
|
|
251
|
+
);
|
|
240
252
|
}
|
|
253
|
+
|
|
254
|
+
return this.appIsOnline$
|
|
241
255
|
}
|
|
242
256
|
|
|
243
|
-
/**
|
|
244
|
-
* goOnLine:
|
|
245
|
-
* 1 - nascondo splashscreen
|
|
246
|
-
* 2 - recupero il tiledeskToken e lo salvo in chat manager
|
|
247
|
-
* 3 - carico in d
|
|
248
|
-
* @param user
|
|
249
|
-
*/
|
|
250
|
-
goOnLine = () => {
|
|
251
|
-
clearTimeout(this.timeModalLogin);
|
|
252
|
-
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
|
|
253
|
-
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
254
|
-
// this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
|
|
255
|
-
this.logger.debug('[APP-COMP] - goOnLine****', currentUser);
|
|
256
|
-
this.chatManager.setTiledeskToken(tiledeskToken);
|
|
257
257
|
|
|
258
|
-
// ----------------------------------------------
|
|
259
|
-
// PUSH NOTIFICATIONS
|
|
260
|
-
// ----------------------------------------------
|
|
261
|
-
const pushEngine = this.appConfigProvider.getConfig().pushEngine
|
|
262
258
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
259
|
+
translateToastMessage() {
|
|
260
|
+
this.translate.get('AnErrorOccurredWhileUnsubscribingFromNotifications')
|
|
261
|
+
.subscribe((text: string) => {
|
|
262
|
+
// this.deleteContact_msg = text;
|
|
263
|
+
// this.logger.debug('FIREBASE-NOTIFICATION >>>> (APP-COMPONENT) text: ', text)
|
|
264
|
+
this.toastMsg = text;
|
|
265
|
+
// this.logger.debug('FIREBASE-NOTIFICATION >>>> (APP-COMPONENT): this.toastMsg', this.toastMsg)
|
|
266
|
+
});
|
|
267
|
+
}
|
|
267
268
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
this.checkPlatform();
|
|
274
|
-
try {
|
|
275
|
-
this.logger.debug('[APP-COMP] ************** closeModal', this.authModal);
|
|
276
|
-
if (this.authModal) {
|
|
277
|
-
this.closeModal();
|
|
278
|
-
}
|
|
279
|
-
} catch (err) {
|
|
280
|
-
this.logger.error('[APP-COMP] -> error:', err);
|
|
281
|
-
}
|
|
282
|
-
this.chatManager.startApp();
|
|
283
|
-
}
|
|
269
|
+
/***************************************************+*/
|
|
270
|
+
/**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
|
|
271
|
+
private initAuthentication() {
|
|
272
|
+
const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
273
|
+
this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
|
|
284
274
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
275
|
+
const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
276
|
+
this.logger.log('[APP-COMP] >>> initAuthentication currentUser ', currentUser)
|
|
277
|
+
if (tiledeskToken) {
|
|
278
|
+
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 <<<')
|
|
288
279
|
|
|
289
|
-
this.
|
|
290
|
-
|
|
291
|
-
this.
|
|
280
|
+
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
|
|
281
|
+
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
282
|
+
}).catch(error => { this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::' + error) })
|
|
292
283
|
|
|
293
|
-
|
|
284
|
+
} else {
|
|
285
|
+
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
|
|
294
286
|
const that = this;
|
|
295
287
|
clearTimeout(this.timeModalLogin);
|
|
296
288
|
this.timeModalLogin = setTimeout(() => {
|
|
297
289
|
if (!this.hadBeenCalledOpenModal) {
|
|
298
|
-
this.authModal = this.presentModal('
|
|
299
|
-
this.hadBeenCalledOpenModal = true
|
|
290
|
+
this.authModal = this.presentModal('initAuthentication');
|
|
291
|
+
this.hadBeenCalledOpenModal = true;
|
|
300
292
|
}
|
|
301
293
|
}, 1000);
|
|
302
294
|
}
|
|
303
|
-
/**------- AUTHENTICATION FUNCTIONS --> END <--- +*/
|
|
304
|
-
/***************************************************+*/
|
|
305
295
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
// initConversationsHandler(userId: string) {
|
|
315
|
-
// const keys = [
|
|
316
|
-
// 'LABEL_TU'
|
|
317
|
-
// ];
|
|
318
|
-
// const translationMap = this.translateService.translateLanguage(keys);
|
|
319
|
-
|
|
320
|
-
// this.logger.debug('initConversationsHandler ------------->', userId);
|
|
321
|
-
// // 1 - init chatConversationsHandler and archviedConversationsHandler
|
|
322
|
-
// this.conversationsHandlerService.initialize(userId, translationMap);
|
|
323
|
-
// // 2 - get conversations from storage
|
|
324
|
-
// // this.chatConversationsHandler.getConversationsFromStorage();
|
|
325
|
-
// // 5 - connect conversationHandler and archviedConversationsHandler to firebase event (add, change, remove)
|
|
326
|
-
// this.conversationsHandlerService.connect();
|
|
327
|
-
// // 6 - save conversationHandler in chatManager
|
|
328
|
-
// this.chatManager.setConversationsHandler(this.conversationsHandlerService);
|
|
329
|
-
// }
|
|
296
|
+
this.route.queryParams.subscribe(params => {
|
|
297
|
+
if (params.jwt) {
|
|
298
|
+
this.tiledeskAuthService.signInWithCustomToken(params.jwt).then(user => {
|
|
299
|
+
this.messagingAuthService.createCustomToken(params.jwt)
|
|
300
|
+
}).catch(error => { this.logger.error('[APP-COMP] SIGNINWITHCUSTOMTOKEN error::' + error) })
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
330
304
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
this.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
305
|
+
authenticate() {
|
|
306
|
+
let token = this.appStorageService.getItem('tiledeskToken');
|
|
307
|
+
this.logger.debug('[APP-COMP] ***** authenticate - stored token *****', token);
|
|
308
|
+
if (!token) {
|
|
309
|
+
this.goOffLine()
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* goOnLine:
|
|
315
|
+
* 1 - nascondo splashscreen
|
|
316
|
+
* 2 - recupero il tiledeskToken e lo salvo in chat manager
|
|
317
|
+
* 3 - carico in d
|
|
318
|
+
* @param user
|
|
319
|
+
*/
|
|
320
|
+
goOnLine = () => {
|
|
321
|
+
clearTimeout(this.timeModalLogin);
|
|
322
|
+
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
|
|
323
|
+
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
324
|
+
// this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
|
|
325
|
+
this.logger.debug('[APP-COMP] - goOnLine****', currentUser);
|
|
326
|
+
this.chatManager.setTiledeskToken(tiledeskToken);
|
|
327
|
+
|
|
328
|
+
// ----------------------------------------------
|
|
329
|
+
// PUSH NOTIFICATIONS
|
|
330
|
+
// ----------------------------------------------
|
|
331
|
+
const pushEngine = this.appConfigProvider.getConfig().pushEngine
|
|
332
|
+
|
|
333
|
+
if (currentUser) {
|
|
334
|
+
if (pushEngine && pushEngine !== 'none') {
|
|
335
|
+
this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
|
|
343
336
|
}
|
|
344
|
-
|
|
337
|
+
|
|
338
|
+
this.chatManager.setCurrentUser(currentUser);
|
|
339
|
+
this.presenceService.setPresence(currentUser.uid);
|
|
340
|
+
this.initConversationsHandler(currentUser.uid);
|
|
341
|
+
this.initArchivedConversationsHandler(currentUser.uid);
|
|
345
342
|
}
|
|
343
|
+
this.checkPlatform();
|
|
344
|
+
try {
|
|
345
|
+
this.logger.debug('[APP-COMP] ************** closeModal', this.authModal);
|
|
346
|
+
if (this.authModal) {
|
|
347
|
+
this.closeModal();
|
|
348
|
+
}
|
|
349
|
+
} catch (err) {
|
|
350
|
+
this.logger.error('[APP-COMP] -> error:', err);
|
|
351
|
+
}
|
|
352
|
+
this.chatManager.startApp();
|
|
353
|
+
}
|
|
346
354
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
355
|
+
goOffLine = () => {
|
|
356
|
+
this.logger.log('[APP-COMP] ************** goOffLine:', this.authModal);
|
|
357
|
+
// this.conversationsHandlerService.conversations = [];
|
|
358
|
+
|
|
359
|
+
this.chatManager.setTiledeskToken(null);
|
|
360
|
+
this.chatManager.setCurrentUser(null);
|
|
361
|
+
this.chatManager.goOffLine();
|
|
362
|
+
|
|
363
|
+
this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
|
|
364
|
+
const that = this;
|
|
365
|
+
clearTimeout(this.timeModalLogin);
|
|
366
|
+
this.timeModalLogin = setTimeout(() => {
|
|
367
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
368
|
+
this.authModal = this.presentModal('goOffLine');
|
|
369
|
+
this.hadBeenCalledOpenModal = true
|
|
370
|
+
}
|
|
371
|
+
}, 1000);
|
|
372
|
+
}
|
|
373
|
+
/**------- AUTHENTICATION FUNCTIONS --> END <--- +*/
|
|
374
|
+
/***************************************************+*/
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* ::: initConversationsHandler :::
|
|
378
|
+
* inizializzo chatConversationsHandler e archviedConversationsHandler
|
|
379
|
+
* recupero le conversazioni salvate nello storage e pubblico l'evento loadedConversationsStorage
|
|
380
|
+
* imposto uidConvSelected in conversationHandler e chatArchivedConversationsHandler
|
|
381
|
+
* e mi sottoscrivo al nodo conversazioni in conversationHandler e chatArchivedConversationsHandler (connect)
|
|
382
|
+
* salvo conversationHandler in chatManager
|
|
383
|
+
*/
|
|
384
|
+
// initConversationsHandler(userId: string) {
|
|
385
|
+
// const keys = [
|
|
386
|
+
// 'LABEL_TU'
|
|
387
|
+
// ];
|
|
388
|
+
// const translationMap = this.translateService.translateLanguage(keys);
|
|
389
|
+
|
|
390
|
+
// this.logger.debug('initConversationsHandler ------------->', userId);
|
|
391
|
+
// // 1 - init chatConversationsHandler and archviedConversationsHandler
|
|
392
|
+
// this.conversationsHandlerService.initialize(userId, translationMap);
|
|
393
|
+
// // 2 - get conversations from storage
|
|
394
|
+
// // this.chatConversationsHandler.getConversationsFromStorage();
|
|
395
|
+
// // 5 - connect conversationHandler and archviedConversationsHandler to firebase event (add, change, remove)
|
|
396
|
+
// this.conversationsHandlerService.connect();
|
|
397
|
+
// // 6 - save conversationHandler in chatManager
|
|
398
|
+
// this.chatManager.setConversationsHandler(this.conversationsHandlerService);
|
|
399
|
+
// }
|
|
400
|
+
|
|
401
|
+
/** */
|
|
402
|
+
setLanguage() {
|
|
403
|
+
this.translate.setDefaultLang('en');
|
|
404
|
+
this.translate.use('en');
|
|
405
|
+
this.logger.debug('[APP-COMP] navigator.language: ', navigator.language);
|
|
406
|
+
let language;
|
|
407
|
+
if (navigator.language.indexOf('-') !== -1) {
|
|
408
|
+
language = navigator.language.substring(0, navigator.language.indexOf('-'));
|
|
409
|
+
} else if (navigator.language.indexOf('_') !== -1) {
|
|
410
|
+
language = navigator.language.substring(0, navigator.language.indexOf('_'));
|
|
411
|
+
} else {
|
|
412
|
+
language = navigator.language;
|
|
413
|
+
}
|
|
414
|
+
this.translate.use(language);
|
|
415
|
+
}
|
|
362
416
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
417
|
+
checkPlatform() {
|
|
418
|
+
this.logger.debug('[APP-COMP] checkPlatform');
|
|
419
|
+
// let pageUrl = '';
|
|
420
|
+
// try {
|
|
421
|
+
// const pathPage = this.route.snapshot.firstChild.routeConfig.path;
|
|
422
|
+
// this.route.snapshot.firstChild.url.forEach(element => {
|
|
423
|
+
// pageUrl += '/' + element.path;
|
|
424
|
+
// });
|
|
425
|
+
// } catch (error) {
|
|
426
|
+
// this.logger.debug('error', error);
|
|
427
|
+
// }
|
|
428
|
+
// this.logger.debug('checkPlatform pathPage: ', pageUrl);
|
|
429
|
+
// if (!pageUrl || pageUrl === '') {
|
|
430
|
+
// pageUrl = '/conversations-list';
|
|
431
|
+
// }
|
|
376
432
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
433
|
+
if (checkPlatformIsMobile()) {
|
|
434
|
+
this.platformIs = PLATFORM_MOBILE;
|
|
435
|
+
const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
|
|
436
|
+
this.logger.debug('[APP-COMP] PLATFORM_MOBILE2 navigateByUrl', PLATFORM_MOBILE, this.route.snapshot);
|
|
437
|
+
if (!IDConv) {
|
|
438
|
+
this.router.navigateByUrl('conversations-list')
|
|
439
|
+
}
|
|
440
|
+
// this.router.navigateByUrl(pageUrl);
|
|
441
|
+
// this.navService.setRoot(ConversationListPage, {});
|
|
442
|
+
} else {
|
|
443
|
+
this.platformIs = PLATFORM_DESKTOP;
|
|
444
|
+
this.logger.debug('[APP-COMP] PLATFORM_DESKTOP ', this.navService);
|
|
445
|
+
this.navService.setRoot(ConversationListPage, {});
|
|
380
446
|
|
|
447
|
+
const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
|
|
448
|
+
const FullNameConv = this.route.snapshot.firstChild.paramMap.get('FullNameConv');
|
|
449
|
+
const Convtype = this.route.snapshot.firstChild.paramMap.get('Convtype');
|
|
381
450
|
|
|
382
|
-
let pageUrl = 'conversation-detail/'
|
|
383
|
-
if (IDConv && FullNameConv) {
|
|
384
|
-
pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
|
|
385
|
-
}
|
|
386
451
|
|
|
387
|
-
|
|
452
|
+
let pageUrl = 'conversation-detail/'
|
|
453
|
+
if (IDConv && FullNameConv) {
|
|
454
|
+
pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
this.router.navigateByUrl(pageUrl);
|
|
388
458
|
|
|
389
459
|
|
|
390
|
-
|
|
391
|
-
|
|
460
|
+
// const DASHBOARD_URL = this.appConfigProvider.getConfig().DASHBOARD_URL;
|
|
461
|
+
// createExternalSidebar(this.renderer, DASHBOARD_URL);
|
|
392
462
|
|
|
393
|
-
|
|
394
|
-
|
|
463
|
+
// // FOR REALTIME TESTING
|
|
464
|
+
// createExternalSidebar(this.renderer, 'http://localhost:4203');
|
|
395
465
|
|
|
396
|
-
}
|
|
397
466
|
}
|
|
467
|
+
}
|
|
398
468
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
469
|
+
/** */
|
|
470
|
+
// showNavbar() {
|
|
471
|
+
// let TEMP = location.search.split('navBar=')[1];
|
|
472
|
+
// if (TEMP) { this.isNavBar = TEMP.split('&')[0]; }
|
|
473
|
+
// }
|
|
404
474
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
475
|
+
/** */
|
|
476
|
+
hideAlert() {
|
|
477
|
+
this.logger.debug('[APP-COMP] hideAlert');
|
|
478
|
+
this.notificationsEnabled = true;
|
|
479
|
+
}
|
|
410
480
|
|
|
411
481
|
private initAudio() {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
482
|
+
// SET AUDIO
|
|
483
|
+
this.audio = new Audio();
|
|
484
|
+
this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
485
|
+
this.audio.load();
|
|
486
|
+
}
|
|
417
487
|
|
|
418
488
|
private manageTabNotification() {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}, 1000);
|
|
435
|
-
this.soundMessage()
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
soundMessage() {
|
|
440
|
-
const that = this;
|
|
441
|
-
// this.audio = new Audio();
|
|
442
|
-
// // this.audio.src = '/assets/sounds/pling.mp3';
|
|
443
|
-
// this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
444
|
-
// this.audio.load();
|
|
445
|
-
this.logger.debug('[APP-COMP] conversation play', this.audio);
|
|
446
|
-
clearTimeout(this.setTimeoutSound);
|
|
447
|
-
this.setTimeoutSound = setTimeout(function () {
|
|
448
|
-
that.audio.play().then(() => {
|
|
449
|
-
that.logger.debug('[APP-COMP] ****** soundMessage played *****');
|
|
450
|
-
}).catch((error: any) => {
|
|
451
|
-
that.logger.debug('[APP-COMP] ***soundMessage error*', error);
|
|
452
|
-
});
|
|
489
|
+
if (!this.isTabVisible) {
|
|
490
|
+
// TAB IS HIDDEN --> manage title and SOUND
|
|
491
|
+
|
|
492
|
+
let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
|
|
493
|
+
badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
|
|
494
|
+
document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
|
|
495
|
+
|
|
496
|
+
clearInterval(this.setIntervalTime)
|
|
497
|
+
const that = this
|
|
498
|
+
this.setIntervalTime = setInterval(function () {
|
|
499
|
+
if (document.title.charAt(0) === '(') {
|
|
500
|
+
document.title = that.tabTitle
|
|
501
|
+
} else {
|
|
502
|
+
document.title = "(" + badgeNewConverstionNumber + ") " + that.tabTitle;
|
|
503
|
+
}
|
|
453
504
|
}, 1000);
|
|
505
|
+
this.soundMessage()
|
|
454
506
|
}
|
|
455
|
-
|
|
456
|
-
/***************************************************+*/
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
// BEGIN SUBSCRIPTIONS //
|
|
460
|
-
/** */
|
|
461
|
-
initSubscriptions() {
|
|
462
|
-
const that = this;
|
|
507
|
+
}
|
|
463
508
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
509
|
+
soundMessage() {
|
|
510
|
+
const that = this;
|
|
511
|
+
// this.audio = new Audio();
|
|
512
|
+
// // this.audio.src = '/assets/sounds/pling.mp3';
|
|
513
|
+
// this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
514
|
+
// this.audio.load();
|
|
515
|
+
this.logger.debug('[APP-COMP] conversation play', this.audio);
|
|
516
|
+
clearTimeout(this.setTimeoutSound);
|
|
517
|
+
this.setTimeoutSound = setTimeout(function () {
|
|
518
|
+
that.audio.play().then(() => {
|
|
519
|
+
that.logger.debug('[APP-COMP] ****** soundMessage played *****');
|
|
520
|
+
}).catch((error: any) => {
|
|
521
|
+
that.logger.debug('[APP-COMP] ***soundMessage error*', error);
|
|
473
522
|
});
|
|
523
|
+
}, 1000);
|
|
524
|
+
}
|
|
525
|
+
/**---------------- SOUND FUNCTIONS --> END <--- +*/
|
|
526
|
+
/***************************************************+*/
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
// BEGIN SUBSCRIPTIONS //
|
|
530
|
+
/** */
|
|
531
|
+
initSubscriptions() {
|
|
532
|
+
const that = this;
|
|
533
|
+
|
|
534
|
+
this.messagingAuthService.BSAuthStateChanged.subscribe((state: any) => {
|
|
535
|
+
this.logger.debug('[APP-COMP] ***** BSAuthStateChanged ***** state', state);
|
|
536
|
+
if (state && state === AUTH_STATE_ONLINE) {
|
|
537
|
+
const user = that.tiledeskAuthService.getCurrentUser();
|
|
538
|
+
that.goOnLine();
|
|
539
|
+
} else if (state === AUTH_STATE_OFFLINE) {
|
|
540
|
+
// that.goOffLine();
|
|
541
|
+
that.authenticate() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
// this.authService.BSSignOut.subscribe((data: any) => {
|
|
546
|
+
// this.logger.debug('***** BSSignOut *****', data);
|
|
547
|
+
// if (data) {
|
|
548
|
+
// that.presenceService.removePresence();
|
|
549
|
+
// }
|
|
550
|
+
// });
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
// this.currentUserService.BScurrentUser.subscribe((currentUser: any) => {
|
|
554
|
+
// this.logger.debug('***** app comp BScurrentUser *****', currentUser);
|
|
555
|
+
// if (currentUser) {
|
|
556
|
+
// that.chatManager.setCurrentUser(currentUser);
|
|
557
|
+
// }
|
|
558
|
+
// });
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
// this.events.subscribe('go-off-line', this.goOffLine);
|
|
562
|
+
// this.events.subscribe('go-on-line', this.goOnLine);
|
|
563
|
+
// this.events.subscribe('sign-in', this.signIn);
|
|
564
|
+
// dopo il login quando ho completato il profilo utente corrente
|
|
565
|
+
// this.events.subscribe('loaded-current-user', null);
|
|
566
|
+
// this.events.subscribe('firebase-sign-in-with-custom-token', this.firebaseSignInWithCustomToken);
|
|
567
|
+
// this.events.subscribe('firebase-create-user-with-email-and-password', this.firebaseCreateUserWithEmailAndPassword);
|
|
568
|
+
// this.events.subscribe('firebase-current-user-delete', this.firebaseCurrentUserDelete);
|
|
569
|
+
// this.events.subscribe('firebase-send-password-reset-email', this.firebaseSendPasswordResetEmail);
|
|
570
|
+
// this.events.subscribe('firebase-sign-out', this.firebaseSignOut);
|
|
571
|
+
this.events.subscribe('uidConvSelected:changed', this.subscribeChangedConversationSelected);
|
|
572
|
+
this.events.subscribe('profileInfoButtonClick:logout', this.subscribeProfileInfoButtonLogOut);
|
|
573
|
+
|
|
574
|
+
this.conversationsHandlerService.conversationAdded.subscribe((conversation: ConversationModel) => {
|
|
575
|
+
this.logger.log('[APP-COMP] ***** conversationsAdded *****', conversation);
|
|
576
|
+
// that.conversationsChanged(conversations);
|
|
577
|
+
if (conversation && conversation.is_new === true) {
|
|
578
|
+
this.manageTabNotification()
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
|
|
582
|
+
this.logger.log('[APP-COMP] ***** subscribeConversationChanged *****', conversation);
|
|
583
|
+
// that.conversationsChanged(conversations);
|
|
584
|
+
//
|
|
474
585
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
// this.currentUserService.BScurrentUser.subscribe((currentUser: any) => {
|
|
484
|
-
// this.logger.debug('***** app comp BScurrentUser *****', currentUser);
|
|
485
|
-
// if (currentUser) {
|
|
486
|
-
// that.chatManager.setCurrentUser(currentUser);
|
|
487
|
-
// }
|
|
488
|
-
// });
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
// this.events.subscribe('go-off-line', this.goOffLine);
|
|
492
|
-
// this.events.subscribe('go-on-line', this.goOnLine);
|
|
493
|
-
// this.events.subscribe('sign-in', this.signIn);
|
|
494
|
-
// dopo il login quando ho completato il profilo utente corrente
|
|
495
|
-
// this.events.subscribe('loaded-current-user', null);
|
|
496
|
-
// this.events.subscribe('firebase-sign-in-with-custom-token', this.firebaseSignInWithCustomToken);
|
|
497
|
-
// this.events.subscribe('firebase-create-user-with-email-and-password', this.firebaseCreateUserWithEmailAndPassword);
|
|
498
|
-
// this.events.subscribe('firebase-current-user-delete', this.firebaseCurrentUserDelete);
|
|
499
|
-
// this.events.subscribe('firebase-send-password-reset-email', this.firebaseSendPasswordResetEmail);
|
|
500
|
-
// this.events.subscribe('firebase-sign-out', this.firebaseSignOut);
|
|
501
|
-
this.events.subscribe('uidConvSelected:changed', this.subscribeChangedConversationSelected);
|
|
502
|
-
this.events.subscribe('profileInfoButtonClick:logout', this.subscribeProfileInfoButtonLogOut);
|
|
503
|
-
|
|
504
|
-
this.conversationsHandlerService.conversationAdded.subscribe((conversation: ConversationModel) => {
|
|
505
|
-
this.logger.log('[APP-COMP] ***** conversationsAdded *****', conversation);
|
|
506
|
-
// that.conversationsChanged(conversations);
|
|
507
|
-
if (conversation && conversation.is_new === true) {
|
|
508
|
-
this.manageTabNotification()
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
|
|
512
|
-
this.logger.log('[APP-COMP] ***** subscribeConversationChanged *****', conversation);
|
|
513
|
-
// that.conversationsChanged(conversations);
|
|
514
|
-
//
|
|
515
|
-
|
|
516
|
-
this.logger.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
|
|
517
|
-
const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
518
|
-
this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
|
|
519
|
-
|
|
520
|
-
if (currentUser) {
|
|
521
|
-
this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user uid: ', currentUser.uid);
|
|
522
|
-
if (conversation && conversation.sender !== currentUser.uid) {
|
|
523
|
-
this.manageTabNotification();
|
|
524
|
-
}
|
|
586
|
+
this.logger.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
|
|
587
|
+
const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
588
|
+
this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
|
|
589
|
+
|
|
590
|
+
if (currentUser) {
|
|
591
|
+
this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user uid: ', currentUser.uid);
|
|
592
|
+
if (conversation && conversation.sender !== currentUser.uid) {
|
|
593
|
+
this.manageTabNotification();
|
|
525
594
|
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
528
598
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
599
|
+
/**
|
|
600
|
+
* ::: subscribeChangedConversationSelected :::
|
|
601
|
+
* evento richiamato quando si seleziona un utente nell'elenco degli user
|
|
602
|
+
* apro dettaglio conversazione
|
|
603
|
+
*/
|
|
604
|
+
subscribeChangedConversationSelected = (user: UserModel, type: string) => {
|
|
605
|
+
this.logger.info('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
|
|
606
|
+
// this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
|
|
607
|
+
this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
|
|
608
|
+
}
|
|
539
609
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
610
|
+
subscribeProfileInfoButtonLogOut = (hasClickedLogout) => {
|
|
611
|
+
this.logger.log('[APP-COMP] FIREBASE-NOTIFICATION >>>> subscribeProfileInfoButtonLogOut ');
|
|
612
|
+
// if (hasClickedLogout === true) {
|
|
613
|
+
// this.removePresenceAndLogout()
|
|
614
|
+
// }
|
|
545
615
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
if (res === 'success') {
|
|
557
|
-
that.removePresenceAndLogout();
|
|
558
|
-
} else {
|
|
559
|
-
that.removePresenceAndLogout();
|
|
560
|
-
that.presentToast();
|
|
561
|
-
}
|
|
562
|
-
})
|
|
563
|
-
}
|
|
616
|
+
if (hasClickedLogout === true) {
|
|
617
|
+
// ----------------------------------------------
|
|
618
|
+
// PUSH NOTIFICATIONS
|
|
619
|
+
// ----------------------------------------------
|
|
620
|
+
const that = this;
|
|
621
|
+
const pushEngine = this.appConfigProvider.getConfig().pushEngine
|
|
622
|
+
if (pushEngine && pushEngine !== 'none') {
|
|
623
|
+
this.notificationsService.removeNotificationsInstance(function (res) {
|
|
624
|
+
that.logger.log('[APP-COMP] FIREBASE-NOTIFICATION >>>> removeNotificationsInstance > CALLBACK RES', res);
|
|
564
625
|
|
|
626
|
+
if (res === 'success') {
|
|
627
|
+
that.removePresenceAndLogout();
|
|
628
|
+
} else {
|
|
629
|
+
that.removePresenceAndLogout();
|
|
630
|
+
that.presentToast();
|
|
631
|
+
}
|
|
632
|
+
})
|
|
565
633
|
}
|
|
566
|
-
}
|
|
567
634
|
|
|
568
|
-
private async presentModal(calledby): Promise<any> {
|
|
569
|
-
this.logger.log('[APP-COMP] presentModal calledby', calledby, '- hadBeenCalledOpenModal: ', this.hadBeenCalledOpenModal);
|
|
570
|
-
const attributes = { tenant: this.tenant, enableBackdropDismiss: false };
|
|
571
|
-
const modal: HTMLIonModalElement =
|
|
572
|
-
await this.modalController.create({
|
|
573
|
-
component: LoginPage,
|
|
574
|
-
componentProps: attributes,
|
|
575
|
-
swipeToClose: false,
|
|
576
|
-
backdropDismiss: false
|
|
577
|
-
});
|
|
578
|
-
modal.onDidDismiss().then((detail: any) => {
|
|
579
|
-
this.hadBeenCalledOpenModal = false
|
|
580
|
-
this.logger.log('[APP-COMP] presentModal onDidDismiss detail.data ', detail.data);
|
|
581
|
-
// this.checkPlatform();
|
|
582
|
-
if (detail !== null) {
|
|
583
|
-
// this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
// await modal.present();
|
|
587
|
-
// modal.onDidDismiss().then((detail: any) => {
|
|
588
|
-
// this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
589
|
-
// // this.checkPlatform();
|
|
590
|
-
// if (detail !== null) {
|
|
591
|
-
// // this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
592
|
-
// }
|
|
593
|
-
// });
|
|
594
|
-
return await modal.present();
|
|
595
635
|
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
private async presentModal(calledby): Promise < any > {
|
|
639
|
+
this.logger.log('[APP-COMP] presentModal calledby', calledby, '- hadBeenCalledOpenModal: ', this.hadBeenCalledOpenModal);
|
|
640
|
+
const attributes = { tenant: this.tenant, enableBackdropDismiss: false };
|
|
641
|
+
const modal: HTMLIonModalElement =
|
|
642
|
+
await this.modalController.create({
|
|
643
|
+
component: LoginPage,
|
|
644
|
+
componentProps: attributes,
|
|
645
|
+
swipeToClose: false,
|
|
646
|
+
backdropDismiss: false
|
|
647
|
+
});
|
|
648
|
+
modal.onDidDismiss().then((detail: any) => {
|
|
649
|
+
this.hadBeenCalledOpenModal = false
|
|
650
|
+
this.logger.log('[APP-COMP] presentModal onDidDismiss detail.data ', detail.data);
|
|
651
|
+
// this.checkPlatform();
|
|
652
|
+
if (detail !== null) {
|
|
653
|
+
// this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
// await modal.present();
|
|
657
|
+
// modal.onDidDismiss().then((detail: any) => {
|
|
658
|
+
// this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
659
|
+
// // this.checkPlatform();
|
|
660
|
+
// if (detail !== null) {
|
|
661
|
+
// // this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
662
|
+
// }
|
|
663
|
+
// });
|
|
664
|
+
return await modal.present();
|
|
665
|
+
}
|
|
596
666
|
|
|
597
667
|
private async closeModal() {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
668
|
+
this.logger.debug('[APP-COMP] closeModal', this.modalController);
|
|
669
|
+
this.logger.debug('[APP-COMP] closeModal .getTop()', this.modalController.getTop());
|
|
670
|
+
await this.modalController.getTop();
|
|
671
|
+
this.modalController.dismiss({ confirmed: true });
|
|
672
|
+
}
|
|
603
673
|
|
|
604
674
|
|
|
605
675
|
// listenToLogoutEvent() {
|
|
@@ -630,97 +700,98 @@ export class AppComponent implements OnInit {
|
|
|
630
700
|
|
|
631
701
|
|
|
632
702
|
async presentToast() {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
703
|
+
const toast = await this.toastController.create({
|
|
704
|
+
message: this.toastMsg,
|
|
705
|
+
duration: 2000
|
|
706
|
+
});
|
|
707
|
+
toast.present();
|
|
708
|
+
}
|
|
639
709
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
710
|
+
removePresenceAndLogout() {
|
|
711
|
+
this.logger.debug('[APP-COMP] FIREBASE-NOTIFICATION >>>> calling removePresenceAndLogout');
|
|
712
|
+
this.presenceService.removePresence();
|
|
713
|
+
this.tiledeskAuthService.logOut()
|
|
714
|
+
this.messagingAuthService.logout()
|
|
715
|
+
}
|
|
646
716
|
|
|
647
717
|
private initConversationsHandler(userId: string) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
718
|
+
const keys = ['YOU'];
|
|
719
|
+
const translationMap = this.translateService.translateLanguage(keys);
|
|
720
|
+
|
|
721
|
+
this.logger.debug('[APP-COMP] initConversationsHandler ------------->', userId, this.tenant);
|
|
722
|
+
// 1 - init chatConversationsHandler and archviedConversationsHandler
|
|
723
|
+
this.conversationsHandlerService.initialize(this.tenant, userId, translationMap);
|
|
724
|
+
|
|
725
|
+
// this.subscribeToConvs()
|
|
726
|
+
this.conversationsHandlerService.subscribeToConversations(() => {
|
|
727
|
+
this.logger.debug('[APP-COMP]-CONVS- INIT CONV')
|
|
728
|
+
const conversations = this.conversationsHandlerService.conversations;
|
|
729
|
+
this.logger.debug('[APP-COMP]-CONVS - INIT CONV CONVS', conversations)
|
|
730
|
+
|
|
731
|
+
// this.logger.printDebug('SubscribeToConversations (convs-list-page) - conversations')
|
|
732
|
+
if (!conversations || conversations.length === 0) {
|
|
733
|
+
// that.showPlaceholder = true;
|
|
734
|
+
this.logger.debug('[APP-COMP]-CONVS - INIT CONV CONVS 2', conversations)
|
|
735
|
+
this.events.publish('appcompSubscribeToConvs:loadingIsActive', false);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
668
738
|
|
|
669
|
-
|
|
739
|
+
}
|
|
670
740
|
|
|
671
741
|
private initArchivedConversationsHandler(userId: string) {
|
|
672
|
-
|
|
742
|
+
const keys = ['YOU'];
|
|
673
743
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
this.logger.debug('[APP-COMP] initArchivedConversationsHandler ------------->', userId, this.tenant);
|
|
677
|
-
// 1 - init archviedConversationsHandler
|
|
678
|
-
this.archivedConversationsHandlerService.initialize(this.tenant, userId, translationMap);
|
|
679
|
-
}
|
|
744
|
+
const translationMap = this.translateService.translateLanguage(keys);
|
|
680
745
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
// this.logger.debug('this.doitResize)', this.doitResize)
|
|
686
|
-
clearTimeout(this.doitResize);
|
|
687
|
-
this.doitResize = setTimeout(() => {
|
|
688
|
-
let platformIsNow = PLATFORM_DESKTOP;
|
|
689
|
-
if (checkPlatformIsMobile()) {
|
|
690
|
-
platformIsNow = PLATFORM_MOBILE;
|
|
691
|
-
}
|
|
692
|
-
if (!this.platformIs || this.platformIs === '') {
|
|
693
|
-
this.platformIs = platformIsNow;
|
|
694
|
-
}
|
|
695
|
-
this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
|
|
696
|
-
this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
|
|
697
|
-
this.logger.debug('[APP-COMP] onResize width:::: platformIsNow this.platformIs', this.platformIs);
|
|
698
|
-
if (platformIsNow !== this.platformIs) {
|
|
699
|
-
window.location.reload();
|
|
700
|
-
}
|
|
701
|
-
}, 500);
|
|
702
|
-
}
|
|
703
|
-
// END RESIZE FUNCTIONS //
|
|
746
|
+
this.logger.debug('[APP-COMP] initArchivedConversationsHandler ------------->', userId, this.tenant);
|
|
747
|
+
// 1 - init archviedConversationsHandler
|
|
748
|
+
this.archivedConversationsHandlerService.initialize(this.tenant, userId, translationMap);
|
|
749
|
+
}
|
|
704
750
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
751
|
+
// BEGIN RESIZE FUNCTIONS //
|
|
752
|
+
@HostListener('window:resize', ['$event'])
|
|
753
|
+
onResize(event: any) {
|
|
754
|
+
const that = this;
|
|
755
|
+
// this.logger.debug('this.doitResize)', this.doitResize)
|
|
756
|
+
clearTimeout(this.doitResize);
|
|
757
|
+
this.doitResize = setTimeout(() => {
|
|
758
|
+
let platformIsNow = PLATFORM_DESKTOP;
|
|
759
|
+
if (checkPlatformIsMobile()) {
|
|
760
|
+
platformIsNow = PLATFORM_MOBILE;
|
|
761
|
+
}
|
|
762
|
+
if (!this.platformIs || this.platformIs === '') {
|
|
763
|
+
this.platformIs = platformIsNow;
|
|
764
|
+
}
|
|
765
|
+
this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
|
|
766
|
+
this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
|
|
767
|
+
this.logger.debug('[APP-COMP] onResize width:::: platformIsNow this.platformIs', this.platformIs);
|
|
768
|
+
if (platformIsNow !== this.platformIs) {
|
|
769
|
+
window.location.reload();
|
|
715
770
|
}
|
|
771
|
+
}, 500);
|
|
772
|
+
}
|
|
773
|
+
// END RESIZE FUNCTIONS //
|
|
774
|
+
|
|
775
|
+
@HostListener('document:visibilitychange', [])
|
|
776
|
+
visibilitychange() {
|
|
777
|
+
// this.logger.debug("document TITLE", document.hidden, document.title);
|
|
778
|
+
if (document.hidden) {
|
|
779
|
+
this.isTabVisible = false
|
|
780
|
+
} else {
|
|
781
|
+
// TAB IS ACTIVE --> restore title and DO NOT SOUND
|
|
782
|
+
clearInterval(this.setIntervalTime)
|
|
783
|
+
this.isTabVisible = true;
|
|
784
|
+
document.title = this.tabTitle;
|
|
716
785
|
}
|
|
786
|
+
}
|
|
717
787
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
788
|
+
@HostListener('window:storage', ['$event'])
|
|
789
|
+
onStorageChanged(event: any) {
|
|
790
|
+
this.logger.log('[APP-COMP] - onStorageChanged')
|
|
791
|
+
if (this.appStorageService.getItem('tiledeskToken') === null) {
|
|
792
|
+
this.tiledeskAuthService.logOut()
|
|
793
|
+
this.messagingAuthService.logout();
|
|
724
794
|
}
|
|
795
|
+
}
|
|
725
796
|
|
|
726
797
|
}
|