@chat21/chat21-ionic 3.0.52-beta → 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 +55 -0
- package/LICENSE +21 -0
- package/config.xml +1 -0
- package/env.sample +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 +509 -434
- package/src/app/app.module.ts +10 -5
- 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/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +18 -5
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +15 -3
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +24 -6
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +4 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +17 -4
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +20 -16
- package/src/app/components/conversation-info/info-content/info-content.component.ts +8 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.html +37 -16
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +143 -53
- package/src/app/pages/conversations-list/conversations-list.page.html +5 -2
- package/src/app/pages/conversations-list/conversations-list.page.ts +19 -14
- package/src/chat-config-pre-test.json +4 -2
- package/src/chat-config-template.json +2 -1
- package/src/chat-config.json +2 -1
- package/src/chat21-core/providers/abstract/messagingAuth.service.ts +1 -1
- package/src/chat21-core/providers/abstract/notifications.service.ts +2 -2
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +6 -4
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +84 -17
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +15 -10
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +119 -18
- package/src/chat21-core/providers/localSessionStorage.ts +2 -1
- package/src/chat21-core/utils/utils-user.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
|
|
|
@@ -172,9 +186,12 @@ export class AppComponent implements OnInit {
|
|
|
172
186
|
this.chatManager.initialize();
|
|
173
187
|
this.presenceService.initialize(this.tenant);
|
|
174
188
|
this.typingService.initialize(this.tenant);
|
|
189
|
+
|
|
175
190
|
const pushEngine = this.appConfigProvider.getConfig().pushEngine
|
|
191
|
+
const vap_id_Key = this.appConfigProvider.getConfig().firebaseConfig.vapidKey
|
|
192
|
+
|
|
176
193
|
if (pushEngine && pushEngine !== 'none') {
|
|
177
|
-
this.notificationsService.initialize(this.tenant)
|
|
194
|
+
this.notificationsService.initialize(this.tenant, vap_id_Key)
|
|
178
195
|
}
|
|
179
196
|
this.uploadService.initialize();
|
|
180
197
|
|
|
@@ -185,417 +202,474 @@ export class AppComponent implements OnInit {
|
|
|
185
202
|
this.logger.debug('[APP-COMP] initializeApp:: ', this.sidebarNav, this.detailNav);
|
|
186
203
|
// this.listenToLogoutEvent()
|
|
187
204
|
this.translateToastMessage();
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
205
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
this.toastMsg = text;
|
|
197
|
-
// this.logger.debug('FIREBASE-NOTIFICATION >>>> (APP-COMPONENT): this.toastMsg', this.toastMsg)
|
|
198
|
-
});
|
|
206
|
+
// ---------------------------------------
|
|
207
|
+
// Watch to network status
|
|
208
|
+
// ---------------------------------------
|
|
209
|
+
this.watchToConnectionStatus()
|
|
210
|
+
});
|
|
199
211
|
}
|
|
200
212
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
206
|
-
if (tiledeskToken) {
|
|
207
|
-
this.logger.debug('[APP-COMP] >>> I LOG IN WITH A TOKEN EXISTING IN THE LOCAL STORAGE OR WITH A TOKEN PASSED IN THE URL PARAMETERS <<<')
|
|
208
|
-
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
|
|
209
|
-
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
210
|
-
}).catch(error => { this.logger.error('[APP-COMP] SIGNINWITHCUSTOMTOKEN error::' + error) })
|
|
211
|
-
} else {
|
|
212
|
-
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
|
|
213
|
-
const that = this;
|
|
214
|
-
clearTimeout(this.timeModalLogin);
|
|
215
|
-
this.timeModalLogin = setTimeout(() => {
|
|
216
|
-
if (!this.hadBeenCalledOpenModal) {
|
|
217
|
-
this.authModal = this.presentModal('initAuthentication');
|
|
218
|
-
this.hadBeenCalledOpenModal = true;
|
|
219
|
-
}
|
|
220
|
-
}, 1000);
|
|
221
|
-
}
|
|
213
|
+
watchToConnectionStatus() {
|
|
214
|
+
this.checkInternetFunc().subscribe(isOnline => {
|
|
215
|
+
this.checkInternet = isOnline
|
|
216
|
+
console.log('[APP-COMP] - watchToConnectionStatus - this.checkInterent', this.checkInternet)
|
|
222
217
|
|
|
223
|
-
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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.')
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.logger.debug('[APP-COMP] ***** authenticate - stored token *****', token);
|
|
235
|
-
if (!token) {
|
|
236
|
-
this.goOffLine()
|
|
237
|
-
}
|
|
238
|
-
}
|
|
232
|
+
checkInternetFunc() {
|
|
233
|
+
if (!window || !navigator || !('onLine' in navigator)) return;
|
|
239
234
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
* 2 - recupero il tiledeskToken e lo salvo in chat manager
|
|
244
|
-
* 3 - carico in d
|
|
245
|
-
* @param user
|
|
246
|
-
*/
|
|
247
|
-
goOnLine = () => {
|
|
248
|
-
clearTimeout(this.timeModalLogin);
|
|
249
|
-
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
|
|
250
|
-
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
251
|
-
// this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
|
|
252
|
-
this.logger.debug('[APP-COMP] - goOnLine****', currentUser);
|
|
253
|
-
this.chatManager.setTiledeskToken(tiledeskToken);
|
|
235
|
+
this.appIsOnline$ = Observable.create(observer => {
|
|
236
|
+
observer.next(true);
|
|
237
|
+
}).pipe(mapTo(true));
|
|
254
238
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
+
);
|
|
261
252
|
}
|
|
262
253
|
|
|
263
|
-
|
|
264
|
-
this.chatManager.setCurrentUser(currentUser);
|
|
265
|
-
this.presenceService.setPresence(currentUser.uid);
|
|
266
|
-
this.initConversationsHandler(currentUser.uid);
|
|
267
|
-
this.initArchivedConversationsHandler(currentUser.uid);
|
|
268
|
-
}
|
|
269
|
-
this.checkPlatform();
|
|
270
|
-
try {
|
|
271
|
-
this.logger.debug('[APP-COMP] ************** closeModal', this.authModal);
|
|
272
|
-
if (this.authModal) {
|
|
273
|
-
this.closeModal();
|
|
274
|
-
}
|
|
275
|
-
} catch (err) {
|
|
276
|
-
this.logger.error('[APP-COMP] -> error:', err);
|
|
277
|
-
}
|
|
278
|
-
this.chatManager.startApp();
|
|
254
|
+
return this.appIsOnline$
|
|
279
255
|
}
|
|
280
256
|
|
|
281
|
-
goOffLine = () => {
|
|
282
|
-
this.logger.log('[APP-COMP] ************** goOffLine:', this.authModal);
|
|
283
|
-
// this.conversationsHandlerService.conversations = [];
|
|
284
257
|
|
|
285
|
-
this.chatManager.setTiledeskToken(null);
|
|
286
|
-
this.chatManager.setCurrentUser(null);
|
|
287
|
-
this.chatManager.goOffLine();
|
|
288
258
|
|
|
289
|
-
|
|
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
|
+
}
|
|
268
|
+
|
|
269
|
+
/***************************************************+*/
|
|
270
|
+
/**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
|
|
271
|
+
private initAuthentication() {
|
|
272
|
+
const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
273
|
+
this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
|
|
274
|
+
|
|
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 <<<')
|
|
279
|
+
|
|
280
|
+
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
|
|
281
|
+
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
282
|
+
}).catch(error => { this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::' + error) })
|
|
283
|
+
|
|
284
|
+
} else {
|
|
285
|
+
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
|
|
290
286
|
const that = this;
|
|
291
287
|
clearTimeout(this.timeModalLogin);
|
|
292
288
|
this.timeModalLogin = setTimeout(() => {
|
|
293
289
|
if (!this.hadBeenCalledOpenModal) {
|
|
294
|
-
this.authModal = this.presentModal('
|
|
295
|
-
this.hadBeenCalledOpenModal = true
|
|
290
|
+
this.authModal = this.presentModal('initAuthentication');
|
|
291
|
+
this.hadBeenCalledOpenModal = true;
|
|
296
292
|
}
|
|
297
293
|
}, 1000);
|
|
298
294
|
}
|
|
299
|
-
/**------- AUTHENTICATION FUNCTIONS --> END <--- +*/
|
|
300
|
-
/***************************************************+*/
|
|
301
295
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
// initConversationsHandler(userId: string) {
|
|
311
|
-
// const keys = [
|
|
312
|
-
// 'LABEL_TU'
|
|
313
|
-
// ];
|
|
314
|
-
// const translationMap = this.translateService.translateLanguage(keys);
|
|
315
|
-
|
|
316
|
-
// this.logger.debug('initConversationsHandler ------------->', userId);
|
|
317
|
-
// // 1 - init chatConversationsHandler and archviedConversationsHandler
|
|
318
|
-
// this.conversationsHandlerService.initialize(userId, translationMap);
|
|
319
|
-
// // 2 - get conversations from storage
|
|
320
|
-
// // this.chatConversationsHandler.getConversationsFromStorage();
|
|
321
|
-
// // 5 - connect conversationHandler and archviedConversationsHandler to firebase event (add, change, remove)
|
|
322
|
-
// this.conversationsHandlerService.connect();
|
|
323
|
-
// // 6 - save conversationHandler in chatManager
|
|
324
|
-
// this.chatManager.setConversationsHandler(this.conversationsHandlerService);
|
|
325
|
-
// }
|
|
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
|
+
}
|
|
326
304
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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);
|
|
339
336
|
}
|
|
340
|
-
|
|
337
|
+
|
|
338
|
+
this.chatManager.setCurrentUser(currentUser);
|
|
339
|
+
this.presenceService.setPresence(currentUser.uid);
|
|
340
|
+
this.initConversationsHandler(currentUser.uid);
|
|
341
|
+
this.initArchivedConversationsHandler(currentUser.uid);
|
|
341
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
|
+
}
|
|
342
354
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
+
}
|
|
358
416
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
+
// }
|
|
372
432
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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, {});
|
|
376
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');
|
|
377
450
|
|
|
378
|
-
let pageUrl = 'conversation-detail/'
|
|
379
|
-
if (IDConv && FullNameConv) {
|
|
380
|
-
pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
|
|
381
|
-
}
|
|
382
451
|
|
|
383
|
-
|
|
452
|
+
let pageUrl = 'conversation-detail/'
|
|
453
|
+
if (IDConv && FullNameConv) {
|
|
454
|
+
pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
|
|
455
|
+
}
|
|
384
456
|
|
|
457
|
+
this.router.navigateByUrl(pageUrl);
|
|
385
458
|
|
|
386
|
-
// const DASHBOARD_URL = this.appConfigProvider.getConfig().DASHBOARD_URL;
|
|
387
|
-
// createExternalSidebar(this.renderer, DASHBOARD_URL);
|
|
388
459
|
|
|
389
|
-
|
|
390
|
-
|
|
460
|
+
// const DASHBOARD_URL = this.appConfigProvider.getConfig().DASHBOARD_URL;
|
|
461
|
+
// createExternalSidebar(this.renderer, DASHBOARD_URL);
|
|
462
|
+
|
|
463
|
+
// // FOR REALTIME TESTING
|
|
464
|
+
// createExternalSidebar(this.renderer, 'http://localhost:4203');
|
|
391
465
|
|
|
392
|
-
}
|
|
393
466
|
}
|
|
467
|
+
}
|
|
394
468
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
469
|
+
/** */
|
|
470
|
+
// showNavbar() {
|
|
471
|
+
// let TEMP = location.search.split('navBar=')[1];
|
|
472
|
+
// if (TEMP) { this.isNavBar = TEMP.split('&')[0]; }
|
|
473
|
+
// }
|
|
400
474
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
475
|
+
/** */
|
|
476
|
+
hideAlert() {
|
|
477
|
+
this.logger.debug('[APP-COMP] hideAlert');
|
|
478
|
+
this.notificationsEnabled = true;
|
|
479
|
+
}
|
|
406
480
|
|
|
407
481
|
private initAudio() {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
482
|
+
// SET AUDIO
|
|
483
|
+
this.audio = new Audio();
|
|
484
|
+
this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
485
|
+
this.audio.load();
|
|
486
|
+
}
|
|
413
487
|
|
|
414
488
|
private manageTabNotification() {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}, 1000);
|
|
431
|
-
this.soundMessage()
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
soundMessage() {
|
|
436
|
-
const that = this;
|
|
437
|
-
// this.audio = new Audio();
|
|
438
|
-
// // this.audio.src = '/assets/sounds/pling.mp3';
|
|
439
|
-
// this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
440
|
-
// this.audio.load();
|
|
441
|
-
this.logger.debug('[APP-COMP] conversation play', this.audio);
|
|
442
|
-
clearTimeout(this.setTimeoutSound);
|
|
443
|
-
this.setTimeoutSound = setTimeout(function () {
|
|
444
|
-
that.audio.play().then(() => {
|
|
445
|
-
that.logger.debug('[APP-COMP] ****** soundMessage played *****');
|
|
446
|
-
}).catch((error: any) => {
|
|
447
|
-
that.logger.debug('[APP-COMP] ***soundMessage error*', error);
|
|
448
|
-
});
|
|
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
|
+
}
|
|
449
504
|
}, 1000);
|
|
505
|
+
this.soundMessage()
|
|
450
506
|
}
|
|
451
|
-
|
|
452
|
-
/***************************************************+*/
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
// BEGIN SUBSCRIPTIONS //
|
|
456
|
-
/** */
|
|
457
|
-
initSubscriptions() {
|
|
458
|
-
const that = this;
|
|
507
|
+
}
|
|
459
508
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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);
|
|
469
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
|
+
//
|
|
470
585
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
// this.currentUserService.BScurrentUser.subscribe((currentUser: any) => {
|
|
480
|
-
// this.logger.debug('***** app comp BScurrentUser *****', currentUser);
|
|
481
|
-
// if (currentUser) {
|
|
482
|
-
// that.chatManager.setCurrentUser(currentUser);
|
|
483
|
-
// }
|
|
484
|
-
// });
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
// this.events.subscribe('go-off-line', this.goOffLine);
|
|
488
|
-
// this.events.subscribe('go-on-line', this.goOnLine);
|
|
489
|
-
// this.events.subscribe('sign-in', this.signIn);
|
|
490
|
-
// dopo il login quando ho completato il profilo utente corrente
|
|
491
|
-
// this.events.subscribe('loaded-current-user', null);
|
|
492
|
-
// this.events.subscribe('firebase-sign-in-with-custom-token', this.firebaseSignInWithCustomToken);
|
|
493
|
-
// this.events.subscribe('firebase-create-user-with-email-and-password', this.firebaseCreateUserWithEmailAndPassword);
|
|
494
|
-
// this.events.subscribe('firebase-current-user-delete', this.firebaseCurrentUserDelete);
|
|
495
|
-
// this.events.subscribe('firebase-send-password-reset-email', this.firebaseSendPasswordResetEmail);
|
|
496
|
-
// this.events.subscribe('firebase-sign-out', this.firebaseSignOut);
|
|
497
|
-
this.events.subscribe('uidConvSelected:changed', this.subscribeChangedConversationSelected);
|
|
498
|
-
this.events.subscribe('profileInfoButtonClick:logout', this.subscribeProfileInfoButtonLogOut);
|
|
499
|
-
|
|
500
|
-
this.conversationsHandlerService.conversationAdded.subscribe((conversation: ConversationModel) => {
|
|
501
|
-
this.logger.log('[APP-COMP] ***** conversationsAdded *****', conversation);
|
|
502
|
-
// that.conversationsChanged(conversations);
|
|
503
|
-
if (conversation && conversation.is_new === true) {
|
|
504
|
-
this.manageTabNotification()
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
|
|
508
|
-
this.logger.log('[APP-COMP] ***** subscribeConversationChanged *****', conversation);
|
|
509
|
-
// that.conversationsChanged(conversations);
|
|
510
|
-
//
|
|
511
|
-
|
|
512
|
-
this.logger.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
|
|
513
|
-
const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
514
|
-
this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
|
|
515
|
-
if (currentUser) {
|
|
516
|
-
this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user uid: ', currentUser.uid);
|
|
517
|
-
|
|
518
|
-
if (conversation && conversation.sender !== currentUser.uid) {
|
|
519
|
-
this.manageTabNotification();
|
|
520
|
-
}
|
|
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();
|
|
521
594
|
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
524
598
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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
|
+
}
|
|
535
609
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
610
|
+
subscribeProfileInfoButtonLogOut = (hasClickedLogout) => {
|
|
611
|
+
this.logger.log('[APP-COMP] FIREBASE-NOTIFICATION >>>> subscribeProfileInfoButtonLogOut ');
|
|
612
|
+
// if (hasClickedLogout === true) {
|
|
613
|
+
// this.removePresenceAndLogout()
|
|
614
|
+
// }
|
|
541
615
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
if (res === 'success') {
|
|
553
|
-
that.removePresenceAndLogout();
|
|
554
|
-
} else {
|
|
555
|
-
that.removePresenceAndLogout();
|
|
556
|
-
that.presentToast();
|
|
557
|
-
}
|
|
558
|
-
})
|
|
559
|
-
}
|
|
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);
|
|
560
625
|
|
|
626
|
+
if (res === 'success') {
|
|
627
|
+
that.removePresenceAndLogout();
|
|
628
|
+
} else {
|
|
629
|
+
that.removePresenceAndLogout();
|
|
630
|
+
that.presentToast();
|
|
631
|
+
}
|
|
632
|
+
})
|
|
561
633
|
}
|
|
562
|
-
}
|
|
563
634
|
|
|
564
|
-
private async presentModal(calledby): Promise<any> {
|
|
565
|
-
this.logger.log('[APP-COMP] presentModal calledby', calledby, '- hadBeenCalledOpenModal: ', this.hadBeenCalledOpenModal);
|
|
566
|
-
const attributes = { tenant: this.tenant, enableBackdropDismiss: false };
|
|
567
|
-
const modal: HTMLIonModalElement =
|
|
568
|
-
await this.modalController.create({
|
|
569
|
-
component: LoginPage,
|
|
570
|
-
componentProps: attributes,
|
|
571
|
-
swipeToClose: false,
|
|
572
|
-
backdropDismiss: false
|
|
573
|
-
});
|
|
574
|
-
modal.onDidDismiss().then((detail: any) => {
|
|
575
|
-
this.hadBeenCalledOpenModal = false
|
|
576
|
-
this.logger.log('[APP-COMP] presentModal onDidDismiss detail.data ', detail.data);
|
|
577
|
-
// this.checkPlatform();
|
|
578
|
-
if (detail !== null) {
|
|
579
|
-
// this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
// await modal.present();
|
|
583
|
-
// modal.onDidDismiss().then((detail: any) => {
|
|
584
|
-
// this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
585
|
-
// // this.checkPlatform();
|
|
586
|
-
// if (detail !== null) {
|
|
587
|
-
// // this.logger.debug('The result: CHIUDI!!!!!', detail.data);
|
|
588
|
-
// }
|
|
589
|
-
// });
|
|
590
|
-
return await modal.present();
|
|
591
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
|
+
}
|
|
592
666
|
|
|
593
667
|
private async closeModal() {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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
|
+
}
|
|
599
673
|
|
|
600
674
|
|
|
601
675
|
// listenToLogoutEvent() {
|
|
@@ -626,97 +700,98 @@ export class AppComponent implements OnInit {
|
|
|
626
700
|
|
|
627
701
|
|
|
628
702
|
async presentToast() {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
703
|
+
const toast = await this.toastController.create({
|
|
704
|
+
message: this.toastMsg,
|
|
705
|
+
duration: 2000
|
|
706
|
+
});
|
|
707
|
+
toast.present();
|
|
708
|
+
}
|
|
635
709
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
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
|
+
}
|
|
642
716
|
|
|
643
717
|
private initConversationsHandler(userId: string) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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
|
+
});
|
|
664
738
|
|
|
665
|
-
|
|
739
|
+
}
|
|
666
740
|
|
|
667
741
|
private initArchivedConversationsHandler(userId: string) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
const translationMap = this.translateService.translateLanguage(keys);
|
|
742
|
+
const keys = ['YOU'];
|
|
671
743
|
|
|
672
|
-
|
|
673
|
-
// 1 - init archviedConversationsHandler
|
|
674
|
-
this.archivedConversationsHandlerService.initialize(this.tenant, userId, translationMap);
|
|
675
|
-
}
|
|
744
|
+
const translationMap = this.translateService.translateLanguage(keys);
|
|
676
745
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
// this.logger.debug('this.doitResize)', this.doitResize)
|
|
682
|
-
clearTimeout(this.doitResize);
|
|
683
|
-
this.doitResize = setTimeout(() => {
|
|
684
|
-
let platformIsNow = PLATFORM_DESKTOP;
|
|
685
|
-
if (checkPlatformIsMobile()) {
|
|
686
|
-
platformIsNow = PLATFORM_MOBILE;
|
|
687
|
-
}
|
|
688
|
-
if (!this.platformIs || this.platformIs === '') {
|
|
689
|
-
this.platformIs = platformIsNow;
|
|
690
|
-
}
|
|
691
|
-
this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
|
|
692
|
-
this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
|
|
693
|
-
this.logger.debug('[APP-COMP] onResize width:::: platformIsNow this.platformIs', this.platformIs);
|
|
694
|
-
if (platformIsNow !== this.platformIs) {
|
|
695
|
-
window.location.reload();
|
|
696
|
-
}
|
|
697
|
-
}, 500);
|
|
698
|
-
}
|
|
699
|
-
// 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
|
+
}
|
|
700
750
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
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();
|
|
711
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;
|
|
712
785
|
}
|
|
786
|
+
}
|
|
713
787
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
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();
|
|
720
794
|
}
|
|
795
|
+
}
|
|
721
796
|
|
|
722
797
|
}
|