@chat21/chat21-ionic 3.0.55 → 3.0.59-rc10
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 +65 -0
- package/README.md +4 -0
- package/config.xml +11 -2
- package/env.sample +2 -0
- package/package.json +1 -1
- 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-routing.module.ts +21 -17
- package/src/app/app.component.html +6 -3
- package/src/app/app.component.ts +323 -185
- package/src/app/app.module.ts +16 -8
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +4 -4
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +8 -2
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +6 -1
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +7 -2
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +48 -3
- package/src/app/chatlib/conversation-detail/message/image/image.component.html +7 -6
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +20 -1
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +39 -9
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +8 -144
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +14 -17
- package/src/app/components/authentication/login/login.component.html +2 -2
- package/src/app/components/authentication/login/login.component.ts +2 -1
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.ts +1 -1
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.ts +1 -1
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +17 -12
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +12 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +21 -5
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +22 -17
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +46 -5
- package/src/app/components/ddp-header/ddp-header.component.html +1 -1
- package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
- package/src/app/components/image-viewer/image-viewer.component.html +23 -0
- package/src/app/components/image-viewer/image-viewer.component.scss +107 -0
- package/src/app/components/image-viewer/image-viewer.component.spec.ts +24 -0
- package/src/app/components/image-viewer/image-viewer.component.ts +38 -0
- package/src/app/components/project-item/project-item.component.html +147 -0
- package/src/app/components/project-item/project-item.component.scss +669 -0
- package/src/app/components/project-item/project-item.component.spec.ts +24 -0
- package/src/app/components/project-item/project-item.component.ts +316 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.html +7 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.ts +22 -5
- package/src/app/pages/authentication/login/login.page.ts +2 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.html +5 -3
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +122 -30
- package/src/app/pages/conversations-list/conversations-list.page.html +40 -24
- package/src/app/pages/conversations-list/conversations-list.page.scss +146 -1
- package/src/app/pages/conversations-list/conversations-list.page.ts +87 -6
- package/src/app/pages/unassigned-conversations/unassigned-conversations-routing.module.ts +17 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.module.ts +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.spec.ts +24 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +108 -0
- package/src/app/services/nav-proxy.service.ts +1 -1
- package/src/app/services/tiledesk/tiledesk.service.ts +22 -1
- package/src/app/services/websocket/websocket-js.ts +559 -0
- package/src/app/services/websocket/websocket.service.spec.ts +12 -0
- package/src/app/services/websocket/websocket.service.ts +274 -0
- package/src/app/shared/shared.module.ts +7 -1
- package/src/assets/i18n/en.json +9 -1
- package/src/assets/i18n/it.json +10 -2
- package/src/assets/js/chat21client.js +141 -67
- package/src/assets/transparent.png +0 -0
- package/src/chat-config-pre-test.json +4 -2
- package/src/chat-config-template.json +3 -1
- package/src/chat-config.json +3 -1
- package/src/chat21-core/providers/abstract/app-storage.service.ts +2 -2
- package/src/chat21-core/providers/chat-manager.ts +3 -3
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +125 -79
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +11 -17
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +2 -2
- package/src/chat21-core/providers/firebase/firebase-typing.service.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-upload.service.ts +1 -1
- package/src/chat21-core/providers/localSessionStorage.ts +155 -154
- package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
- package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
- package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +1 -1
- package/src/chat21-core/utils/utils.ts +1 -1
- package/src/global.scss +2 -7
- package/src/index.html +1 -1
package/src/app/app.component.ts
CHANGED
|
@@ -55,9 +55,9 @@ import { getImageUrlThumbFromFirebasestorage } from 'src/chat21-core/utils/utils
|
|
|
55
55
|
import { TiledeskService } from './services/tiledesk/tiledesk.service';
|
|
56
56
|
import { NetworkService } from './services/network-service/network.service';
|
|
57
57
|
import * as PACKAGE from 'package.json';
|
|
58
|
+
import { filter } from 'rxjs/operators'
|
|
59
|
+
import { WebSocketJs } from './services/websocket/websocket-js';
|
|
58
60
|
|
|
59
|
-
import { Subject } from 'rxjs';
|
|
60
|
-
import { filter, takeUntil } from 'rxjs/operators'
|
|
61
61
|
// import { filter } from 'rxjs/operators';
|
|
62
62
|
|
|
63
63
|
@Component({
|
|
@@ -73,7 +73,7 @@ export class AppComponent implements OnInit {
|
|
|
73
73
|
// public appIsOnline$: Observable<boolean> = undefined;
|
|
74
74
|
checkInternet: boolean;
|
|
75
75
|
|
|
76
|
-
private
|
|
76
|
+
private BSAuthStateChangedSubscriptionRef: Subscription;
|
|
77
77
|
public sidebarPage: any;
|
|
78
78
|
public notificationsEnabled: boolean;
|
|
79
79
|
public zone: NgZone;
|
|
@@ -98,8 +98,10 @@ export class AppComponent implements OnInit {
|
|
|
98
98
|
public missingConnectionToast: any
|
|
99
99
|
public executedInitializeAppByWatchConnection: boolean = false;
|
|
100
100
|
private version: string;
|
|
101
|
-
|
|
102
|
-
private isOnline: boolean = false;
|
|
101
|
+
|
|
102
|
+
// private isOnline: boolean = false;
|
|
103
|
+
|
|
104
|
+
wsService: WebSocketJs;
|
|
103
105
|
|
|
104
106
|
constructor(
|
|
105
107
|
private platform: Platform,
|
|
@@ -135,98 +137,201 @@ export class AppComponent implements OnInit {
|
|
|
135
137
|
public toastController: ToastController,
|
|
136
138
|
// private network: Network,
|
|
137
139
|
// private tiledeskService: TiledeskService,
|
|
138
|
-
private networkService: NetworkService
|
|
140
|
+
private networkService: NetworkService,
|
|
141
|
+
public webSocketJs: WebSocketJs,
|
|
139
142
|
) {
|
|
140
|
-
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
// t.dismiss();
|
|
146
|
-
// });
|
|
143
|
+
|
|
144
|
+
// this.saveInStorageChatOpenedTab();
|
|
145
|
+
// FOR TEST
|
|
146
|
+
// const last_project = { "user_available": true, "number_assigned_requests": 59, "last_login_at": "2021-08-09T17:30:55.234Z", "status": "active", "_id": "6112bc8f58c958003495a2cb", "id_project": { "status": 100, "_id": "60ffe291f725db00347661ef", "name": "27-LUGLIO-21-STRIPE-TEST", "activeOperatingHours": false, "createdBy": "608ad02d3a4dc000344ade17", "profile": { "name": "pro", "trialDays": 30, "agents": 5, "type": "payment", "subStart": "2021-11-18T10:42:41.000Z", "subEnd": "2021-11-19T10:42:41.000Z", "subscriptionId": "sub_Jvf4kABe9t8JvX", "last_stripe_event": "invoice.payment_succeeded" }, "versions": 20115, "channels": [{ "name": "chat21" }], "createdAt": "2021-07-27T10:40:17.752Z", "updatedAt": "2021-11-18T11:55:01.346Z", "__v": 0, "widget": { "preChatForm": true, "preChatFormJson": [{ "name": "userFullname", "type": "text", "mandatory": true, "label": { "en": "Your name", "it": "Il tuo nome" } }, { "name": "userEmail", "type": "text", "mandatory": true, "regex": "/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/", "label": { "en": "Your email", "it": "La tua email" }, "errorLabel": { "en": "Invalid email address", "it": "Indirizzo email non valido" } }, { "name": "tel", "mandatory": true, "label": { "en": "Your phone number", "it": "Il tuo numero di telefono" } }], "preChatFormCustomFieldsEnabled": true }, "trialExpired": true, "trialDaysLeft": 84, "isActiveSubscription": true, "id": "60ffe291f725db00347661ef" }, "id_user": "60aa0fef1482fe00346854a7", "role": "admin", "createdBy": "608ad02d3a4dc000344ade17", "createdAt": "2021-08-10T17:51:11.318Z", "updatedAt": "2021-11-19T08:08:21.437Z", "__v": 0, "presence": { "status": "online", "changedAt": "2021-11-19T08:08:21.432Z" }, "isAuthenticated": true, "id": "6112bc8f58c958003495a2cb" }
|
|
147
|
+
// localStorage.setItem('last_project', JSON.stringify(last_project))
|
|
147
148
|
}
|
|
149
|
+
saveInStorageChatOpenedTab() {
|
|
150
|
+
// if (+localStorage.tabCount > 0) {
|
|
151
|
+
// alert('Already open!');
|
|
152
|
+
// } else {
|
|
153
|
+
// localStorage.tabCount = 0;
|
|
154
|
+
// }
|
|
155
|
+
|
|
156
|
+
// window.addEventListener('load', (event) => {
|
|
157
|
+
// console.log('[CONVS-LIST-PAGE] page is fully loaded', event);
|
|
158
|
+
// // let tab = + localStorage.getItem('tab')
|
|
159
|
+
// // console.log('[CONVS-LIST-PAGE] page is fully loaded getItem tab', + tab);
|
|
160
|
+
// // localStorage.setItem('tab', "1" )
|
|
161
|
+
// localStorage.tabCount = +localStorage.tabCount + 1;
|
|
162
|
+
// });
|
|
163
|
+
|
|
164
|
+
// // https://developers.google.com/web/updates/2018/07/page-lifecycle-api#the-beforeunload-event
|
|
165
|
+
// const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
|
|
166
|
+
// window.addEventListener(terminationEvent, (event) => {
|
|
167
|
+
// console.log('[CONVS-LIST-PAGE] page is terminationEvent', event);
|
|
168
|
+
// localStorage.tabCount = +localStorage.tabCount - 1;
|
|
169
|
+
// }, { capture: true });
|
|
170
|
+
const getState = () => {
|
|
171
|
+
if (document.visibilityState === 'hidden') {
|
|
172
|
+
return 'hidden';
|
|
173
|
+
}
|
|
174
|
+
if (document.hasFocus()) {
|
|
175
|
+
return 'active';
|
|
176
|
+
}
|
|
177
|
+
return 'passive';
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
let state = getState();
|
|
181
|
+
console.log('[CONVS-LIST-PAGE] page state ', state)
|
|
182
|
+
if (state === 'hidden') {
|
|
183
|
+
localStorage.setItem('hidden', 'true')
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const logStateChange = (nextState) => {
|
|
187
|
+
const prevState = state;
|
|
188
|
+
if (nextState !== prevState) {
|
|
189
|
+
console.log(`State change: ${prevState} >>> ${nextState}`);
|
|
190
|
+
state = nextState;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
|
|
195
|
+
window.addEventListener(type, () => logStateChange(getState()), { capture: true });
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// The next two listeners, on the other hand, can determine the next
|
|
199
|
+
// state from the event itself.
|
|
200
|
+
window.addEventListener('freeze', () => {
|
|
201
|
+
// In the freeze event, the next state is always frozen.
|
|
202
|
+
logStateChange('frozen');
|
|
203
|
+
}, { capture: true });
|
|
204
|
+
|
|
205
|
+
window.addEventListener('pagehide', (event) => {
|
|
206
|
+
if (event.persisted) {
|
|
207
|
+
// If the event's persisted property is `true` the page is about
|
|
208
|
+
// to enter the Back-Forward Cache, which is also in the frozen state.
|
|
209
|
+
logStateChange('frozen');
|
|
210
|
+
localStorage.setItem('terminated', 'true')
|
|
211
|
+
} else {
|
|
212
|
+
// If the event's persisted property is not `true` the page is
|
|
213
|
+
// about to be unloaded.
|
|
214
|
+
logStateChange('terminated');
|
|
215
|
+
localStorage.setItem('terminated', 'true')
|
|
216
|
+
}
|
|
217
|
+
}, { capture: true });
|
|
148
218
|
|
|
149
|
-
param() {
|
|
150
|
-
// PARAM
|
|
151
|
-
const url: URL = new URL(window.top.location.href);
|
|
152
|
-
const params: URLSearchParams = url.searchParams;
|
|
153
|
-
return params;
|
|
154
219
|
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
// param() {
|
|
223
|
+
// // PARAM
|
|
224
|
+
// const url: URL = new URL(window.top.location.href);
|
|
225
|
+
// const params: URLSearchParams = url.searchParams;
|
|
226
|
+
// return params;
|
|
227
|
+
// }
|
|
155
228
|
/**
|
|
156
229
|
*/
|
|
157
230
|
ngOnInit() {
|
|
158
231
|
const appconfig = this.appConfigProvider.getConfig();
|
|
159
232
|
this.persistence = appconfig.authPersistence;
|
|
160
233
|
this.appStorageService.initialize(environment.storage_prefix, this.persistence, '')
|
|
161
|
-
this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
|
|
162
|
-
this.logger.
|
|
234
|
+
// this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
|
|
235
|
+
// this.logger.log('[APP-COMP] ngOnInit this.route.snapshot.params -->', this.route.snapshot.params);
|
|
163
236
|
// this.initializeApp('oninit');
|
|
164
237
|
const token = getParameterByName('jwt')
|
|
165
|
-
this.logger.
|
|
166
|
-
|
|
238
|
+
// this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName -->', token);
|
|
239
|
+
|
|
167
240
|
if (token) {
|
|
168
|
-
this.isOnline = false;
|
|
169
|
-
this.logger.log('[APP-COMP]
|
|
241
|
+
// this.isOnline = false;
|
|
242
|
+
// this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with this.isOnline ', this.isOnline)
|
|
243
|
+
this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName ', token)
|
|
170
244
|
// save token in local storage then
|
|
171
|
-
|
|
245
|
+
|
|
246
|
+
const storedToken = this.appStorageService.getItem('tiledeskToken');
|
|
247
|
+
this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN storedToken ', storedToken)
|
|
248
|
+
this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN SAVE THE PARAMS TOKEN ', token)
|
|
249
|
+
if (storedToken !== token) {
|
|
250
|
+
this.appStorageService.setItem('tiledeskToken', token);
|
|
251
|
+
} else {
|
|
252
|
+
this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN the current user already exist DON\'T SAVE ')
|
|
253
|
+
}
|
|
172
254
|
}
|
|
173
255
|
this.initializeApp('oninit');
|
|
174
|
-
// else {
|
|
175
|
-
// this.isOnline = false;
|
|
176
|
-
// this.logger.log('[APP-COMP] NO AUTLOGIN > RUN INIZIALIZE APP')
|
|
177
|
-
// this.initializeApp('oninit');
|
|
178
|
-
// }
|
|
179
256
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
// this.logger.info('[APP-COMP] ngOnInit token geet from params -->', token);
|
|
183
|
-
|
|
184
|
-
// this.subscription = this.router.events.subscribe((event) => {
|
|
185
|
-
// if (event instanceof NavigationStart) {
|
|
186
|
-
// const current_url = event.url
|
|
187
|
-
// this.logger.info('[APP-COMP] - NavigationStart event current_url ', current_url);
|
|
188
|
-
// if (current_url.includes('jwt')) {
|
|
189
|
-
// this.logger.info('[APP-COMP] - NavigationStart event current_url INCLUDES jwt');
|
|
190
|
-
// const tokenString = current_url.slice(current_url.lastIndexOf('=') + 1)
|
|
191
|
-
// // const token = tokenString.substring(1, tokenString.length - 1)
|
|
192
|
-
// const token = tokenString
|
|
193
|
-
// this.logger.info('[APP-COMP] - NavigationStart event current_url INCLUDES jwt > token ', token);
|
|
194
|
-
// this.signInWithCustomToken("JWT%20eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDhhZDAyZDNhNGRjMDAwMzQ0YWRlMTciLCJlbWFpbCI6Im51b3ZvcHJlZ2lub0BtYWlsbmEuY28iLCJmaXJzdG5hbWUiOiJOdW92byIsImxhc3RuYW1lIjoiUHJlZ2lubyIsImVtYWlsdmVyaWZpZWQiOnRydWUsImlhdCI6MTYzNDE5OTU1NiwiYXVkIjoiaHR0cHM6Ly90aWxlZGVzay5jb20iLCJpc3MiOiJodHRwczovL3RpbGVkZXNrLmNvbSIsInN1YiI6InVzZXIiLCJqdGkiOiIwMGQyNTI0MS05MDI4LTRmYTYtYmJhNi0xOGNmZTUwNzdiYTMifQ.4kCuHOyceIMWnlyOiCvQEiDPqDZR8HwYgyQoqMYJxX0")
|
|
195
|
-
// } else {
|
|
196
|
-
// this.logger.info('[APP-COMP] - NavigationStart event current_url NOT INCLUDES jwt');
|
|
197
|
-
// }
|
|
198
|
-
// }
|
|
199
|
-
// });
|
|
257
|
+
this.listenToPostMsgs();
|
|
258
|
+
}
|
|
200
259
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
listenToPostMsgs() {
|
|
263
|
+
window.addEventListener("message", (event) => {
|
|
264
|
+
// console.log("[APP-COMP] message event ", event);
|
|
265
|
+
|
|
266
|
+
if (event && event.data && event.data.action && event.data.parameter) {
|
|
267
|
+
if (event.data.action === 'openJoinConversationModal') {
|
|
268
|
+
// console.log("[APP-COMP] message event action ", event.data.action);
|
|
269
|
+
// console.log("[APP-COMP] message event parameter ", event.data.parameter);
|
|
270
|
+
this.presentAlertConfirmJoinRequest(event.data.parameter, event.data.calledBy)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (event && event.data && event.data.action && event.data.text) {
|
|
274
|
+
if (event.data.action === "display_toast_join_complete") {
|
|
275
|
+
this.presentToastJoinComplete(event.data.text)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
async presentToastJoinComplete(text) {
|
|
282
|
+
const toast = await this.toastController.create({
|
|
283
|
+
message: text,
|
|
284
|
+
duration: 2000,
|
|
285
|
+
color: "success"
|
|
286
|
+
});
|
|
287
|
+
toast.present();
|
|
223
288
|
}
|
|
224
289
|
|
|
290
|
+
async presentAlertConfirmJoinRequest(requestid, calledby) {
|
|
291
|
+
var iframeWin = <HTMLIFrameElement>document.getElementById("unassigned-convs-iframe")
|
|
292
|
+
// console.log("[APP-COMP] message event iframeWin ", iframeWin);
|
|
225
293
|
|
|
226
|
-
|
|
294
|
+
const isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
|
|
295
|
+
input !== null && input.tagName === 'IFRAME';
|
|
296
|
+
|
|
297
|
+
const keys = ['YouAreAboutToJoinThisChat', 'Cancel', 'AreYouSure'];
|
|
298
|
+
const translationMap = this.translateService.translateLanguage(keys);
|
|
299
|
+
|
|
300
|
+
const alert = await this.alertController.create({
|
|
301
|
+
cssClass: 'my-custom-class',
|
|
302
|
+
header: translationMap.get('AreYouSure'),
|
|
303
|
+
message: translationMap.get('YouAreAboutToJoinThisChat'),
|
|
304
|
+
buttons: [
|
|
305
|
+
{
|
|
306
|
+
text: translationMap.get('Cancel'),
|
|
307
|
+
role: 'cancel',
|
|
308
|
+
cssClass: 'secondary',
|
|
309
|
+
handler: (blah) => {
|
|
310
|
+
// console.log('Confirm Cancel: blah', blah);
|
|
311
|
+
}
|
|
312
|
+
}, {
|
|
313
|
+
text: 'Ok',
|
|
314
|
+
handler: () => {
|
|
315
|
+
// console.log('Confirm Okay');
|
|
316
|
+
|
|
317
|
+
if (isIFrame(iframeWin) && iframeWin.contentWindow) {
|
|
318
|
+
const msg = { action: "joinConversation", parameter: requestid, calledBy: calledby }
|
|
319
|
+
iframeWin.contentWindow.postMessage(msg, '*');
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
]
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
await alert.present();
|
|
327
|
+
}
|
|
227
328
|
|
|
228
|
-
|
|
229
|
-
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
signInWithCustomToken(token) {
|
|
333
|
+
// this.isOnline = false;
|
|
334
|
+
this.logger.log('[APP-COMP] SIGNINWITHCUSTOMTOKEN token', token)
|
|
230
335
|
this.tiledeskAuthService.signInWithCustomToken(token)
|
|
231
336
|
.then((user: any) => {
|
|
232
337
|
this.logger.log('[APP-COMP] SIGNINWITHCUSTOMTOKEN AUTLOGIN user', user)
|
|
@@ -235,26 +340,22 @@ export class AppComponent implements OnInit {
|
|
|
235
340
|
.catch(error => {
|
|
236
341
|
this.logger.error('[APP-COMP] SIGNINWITHCUSTOMTOKEN error::', error)
|
|
237
342
|
})
|
|
238
|
-
|
|
239
343
|
}
|
|
240
344
|
|
|
241
|
-
|
|
242
|
-
|
|
243
345
|
/** */
|
|
244
346
|
initializeApp(calledby: string) {
|
|
245
|
-
this.logger.
|
|
246
|
-
|
|
247
|
-
this.logger.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
|
|
347
|
+
// this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
|
|
348
|
+
// console.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
|
|
248
349
|
|
|
249
|
-
if (!this.platform.is('cordova')) {
|
|
250
|
-
|
|
251
|
-
}
|
|
350
|
+
// if (!this.platform.is('cordova')) {
|
|
351
|
+
this.splashScreen.show();
|
|
352
|
+
// }
|
|
252
353
|
this.tabTitle = document.title;
|
|
253
354
|
|
|
254
355
|
this.getRouteParamsAndSetLoggerConfig();
|
|
255
356
|
|
|
256
357
|
const appconfig = this.appConfigProvider.getConfig();
|
|
257
|
-
this.logger.info('[APP-COMP] appconfig: ', appconfig)
|
|
358
|
+
// this.logger.info('[APP-COMP] appconfig: ', appconfig)
|
|
258
359
|
this.version = PACKAGE.version;
|
|
259
360
|
this.logger.info('[APP-COMP] version: ', this.version)
|
|
260
361
|
|
|
@@ -263,19 +364,42 @@ export class AppComponent implements OnInit {
|
|
|
263
364
|
|
|
264
365
|
this.tenant = appconfig.firebaseConfig.tenant;
|
|
265
366
|
this.logger.info('[APP-COMP] appconfig firebaseConfig tenant: ', this.tenant);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
367
|
this.notificationsEnabled = true;
|
|
271
368
|
this.zone = new NgZone({}); // a cosa serve?
|
|
272
369
|
|
|
370
|
+
// ------------------------------------------
|
|
371
|
+
// Platform ready
|
|
372
|
+
// ------------------------------------------
|
|
273
373
|
this.platform.ready().then(() => {
|
|
274
|
-
|
|
374
|
+
// console.log("Check platform");
|
|
375
|
+
if (this.platform.is('cordova')) {
|
|
376
|
+
// console.log("the device running Cordova");
|
|
377
|
+
}
|
|
378
|
+
if (!this.platform.is('cordova')) {
|
|
379
|
+
// console.log("the device Not running Cordova");
|
|
380
|
+
}
|
|
275
381
|
|
|
276
|
-
if (this.
|
|
277
|
-
|
|
382
|
+
if (this.platform.is('android')) {
|
|
383
|
+
// console.log("running on Android device!");
|
|
278
384
|
}
|
|
385
|
+
if (this.platform.is('ios')) {
|
|
386
|
+
// console.log("running on iOS device!");
|
|
387
|
+
}
|
|
388
|
+
if (this.platform.is('mobileweb')) {
|
|
389
|
+
// console.log("running in a browser on mobile!");
|
|
390
|
+
}
|
|
391
|
+
if (this.platform.is('desktop')) {
|
|
392
|
+
// console.log("running on desktop!");
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
this.setLanguage();
|
|
399
|
+
|
|
400
|
+
// if (this.splashScreen) {
|
|
401
|
+
this.splashScreen.hide();
|
|
402
|
+
// }
|
|
279
403
|
this.statusBar.styleDefault();
|
|
280
404
|
this.navService.init(this.sidebarNav, this.detailNav);
|
|
281
405
|
// this.persistence = appconfig.authPersistence;
|
|
@@ -298,35 +422,19 @@ export class AppComponent implements OnInit {
|
|
|
298
422
|
|
|
299
423
|
this.initAuthentication();
|
|
300
424
|
this.initSubscriptions();
|
|
301
|
-
this.initAudio()
|
|
425
|
+
this.initAudio();
|
|
302
426
|
|
|
303
427
|
this.logger.debug('[APP-COMP] initializeApp:: ', this.sidebarNav, this.detailNav);
|
|
304
|
-
|
|
428
|
+
|
|
305
429
|
this.translateToastMsgs();
|
|
306
430
|
|
|
307
431
|
// ---------------------------------------
|
|
308
432
|
// Watch to network status
|
|
309
433
|
// ---------------------------------------
|
|
310
434
|
this.watchToConnectionStatus();
|
|
311
|
-
// this.listenToUserIsSignedIn();
|
|
312
|
-
|
|
313
|
-
|
|
314
435
|
});
|
|
315
436
|
}
|
|
316
437
|
|
|
317
|
-
// listenToUserIsSignedIn() {
|
|
318
|
-
// this.tiledeskAuthService.isOnline$
|
|
319
|
-
// .pipe(filter((isOnline) => isOnline !== null))
|
|
320
|
-
// .subscribe((isOnline: any) => {
|
|
321
|
-
// console.log('[APP-COMP] user isOnline: ', isOnline);
|
|
322
|
-
|
|
323
|
-
// // if (isOnline === false) {
|
|
324
|
-
// // this.events.publish('profileInfoButtonClick:logout', true);
|
|
325
|
-
// // }
|
|
326
|
-
// });
|
|
327
|
-
// }
|
|
328
|
-
|
|
329
|
-
|
|
330
438
|
|
|
331
439
|
watchToConnectionStatus() {
|
|
332
440
|
this.networkService.checkInternetFunc().subscribe(isOnline => {
|
|
@@ -352,7 +460,7 @@ export class AppComponent implements OnInit {
|
|
|
352
460
|
if (elemIonNavchildNodes.length === 0) {
|
|
353
461
|
this.logger.log('[APP-COMP] - watchToConnectionStatus - elemIonNavchildNodes HERE YES', elemIonNavchildNodes);
|
|
354
462
|
|
|
355
|
-
this.initializeApp('checkinternet');
|
|
463
|
+
// this.initializeApp('checkinternet');
|
|
356
464
|
this.executedInitializeAppByWatchConnection = true;
|
|
357
465
|
}
|
|
358
466
|
}, 2000);
|
|
@@ -366,7 +474,7 @@ export class AppComponent implements OnInit {
|
|
|
366
474
|
const childElementCount = elemIonRouterOutlet.childElementCount;
|
|
367
475
|
this.logger.log('[APP-COMP] - watchToConnectionStatus - mobile * childElementCount *', childElementCount)
|
|
368
476
|
if (childElementCount === 1) {
|
|
369
|
-
this.initializeApp('checkinternet');
|
|
477
|
+
// this.initializeApp('checkinternet');
|
|
370
478
|
this.executedInitializeAppByWatchConnection = true;
|
|
371
479
|
}
|
|
372
480
|
}, 2000);
|
|
@@ -383,9 +491,9 @@ export class AppComponent implements OnInit {
|
|
|
383
491
|
getRouteParamsAndSetLoggerConfig() {
|
|
384
492
|
const appconfig = this.appConfigProvider.getConfig();
|
|
385
493
|
this.route.queryParams.subscribe(params => {
|
|
386
|
-
this.logger.
|
|
494
|
+
// this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
|
|
387
495
|
if (params.logLevel) {
|
|
388
|
-
this.logger.
|
|
496
|
+
this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
|
|
389
497
|
this.logger.setLoggerConfig(true, params.logLevel)
|
|
390
498
|
} else {
|
|
391
499
|
this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from appconfig: ', appconfig.logLevel)
|
|
@@ -415,51 +523,50 @@ export class AppComponent implements OnInit {
|
|
|
415
523
|
/**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
|
|
416
524
|
private initAuthentication() {
|
|
417
525
|
const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
526
|
+
|
|
418
527
|
this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
|
|
419
528
|
this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.logger.log('[APP-COMP] >>> initAuthentication currentUser ', currentUser)
|
|
529
|
+
// const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
530
|
+
// this.logger.log('[APP-COMP] >>> initAuthentication currentUser ', currentUser)
|
|
423
531
|
if (tiledeskToken) {
|
|
424
532
|
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 <<<')
|
|
425
|
-
|
|
426
533
|
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
|
|
427
534
|
this.logger.log('[APP-COMP] >>> initAuthentication user ', user)
|
|
428
535
|
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
429
|
-
}).catch(error => {
|
|
430
|
-
|
|
536
|
+
}).catch(error => {
|
|
537
|
+
this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::', error)
|
|
538
|
+
})
|
|
431
539
|
} else {
|
|
432
540
|
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
|
|
433
|
-
const that = this;
|
|
434
|
-
clearTimeout(this.timeModalLogin);
|
|
435
|
-
this.timeModalLogin = setTimeout(() => {
|
|
436
|
-
if (!this.hadBeenCalledOpenModal) {
|
|
437
|
-
this.authModal = this.presentModal('initAuthentication');
|
|
438
|
-
this.hadBeenCalledOpenModal = true;
|
|
439
|
-
}
|
|
440
|
-
}, 1000);
|
|
441
|
-
}
|
|
442
541
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
// this.logger.error('[APP-COMP] SIGNINWITHCUSTOMTOKEN error::', error)
|
|
452
|
-
// })
|
|
453
|
-
// }
|
|
454
|
-
// });
|
|
542
|
+
// clearTimeout(this.timeModalLogin);
|
|
543
|
+
// this.timeModalLogin = setTimeout(() => {
|
|
544
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
545
|
+
this.authModal = this.presentModal('initAuthentication');
|
|
546
|
+
this.hadBeenCalledOpenModal = true;
|
|
547
|
+
}
|
|
548
|
+
// }, 1000);
|
|
549
|
+
}
|
|
455
550
|
}
|
|
456
551
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
552
|
+
// checkTokenAndGoOffline() {
|
|
553
|
+
// let token = this.appStorageService.getItem('tiledeskToken');
|
|
554
|
+
// this.logger.info('[APP-COMP] ***** checkTokenAndGoOffline - stored token *****', token);
|
|
555
|
+
// if (!token) {
|
|
556
|
+
// this.goOffLine()
|
|
557
|
+
// }
|
|
558
|
+
// }
|
|
559
|
+
|
|
560
|
+
connetWebsocket(tiledeskToken) {
|
|
561
|
+
const appconfig = this.appConfigProvider.getConfig();
|
|
562
|
+
this.logger.log('connetWebsocket appconfig wsUrl ', appconfig.wsUrl)
|
|
563
|
+
const WS_URL = appconfig.wsUrl + '?token=' + tiledeskToken
|
|
564
|
+
this.webSocketJs.init(
|
|
565
|
+
WS_URL,
|
|
566
|
+
undefined,
|
|
567
|
+
undefined,
|
|
568
|
+
undefined
|
|
569
|
+
);
|
|
463
570
|
}
|
|
464
571
|
|
|
465
572
|
/**
|
|
@@ -470,15 +577,16 @@ export class AppComponent implements OnInit {
|
|
|
470
577
|
* @param user
|
|
471
578
|
*/
|
|
472
579
|
goOnLine = () => {
|
|
473
|
-
this.isOnline = true;
|
|
474
|
-
this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO
|
|
580
|
+
// this.isOnline = true;
|
|
581
|
+
// this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
|
|
475
582
|
|
|
476
|
-
|
|
477
|
-
clearTimeout(this.timeModalLogin);
|
|
583
|
+
// clearTimeout(this.timeModalLogin);
|
|
478
584
|
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
|
|
585
|
+
this.connetWebsocket(tiledeskToken)
|
|
586
|
+
|
|
479
587
|
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
480
588
|
// this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
|
|
481
|
-
this.logger.log('[APP-COMP] -
|
|
589
|
+
this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
|
|
482
590
|
this.chatManager.setTiledeskToken(tiledeskToken);
|
|
483
591
|
this.chatManager.setCurrentUser(currentUser);
|
|
484
592
|
// ----------------------------------------------
|
|
@@ -490,9 +598,8 @@ export class AppComponent implements OnInit {
|
|
|
490
598
|
if (pushEngine && pushEngine !== 'none') {
|
|
491
599
|
this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
|
|
492
600
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
601
|
this.presenceService.setPresence(currentUser.uid);
|
|
602
|
+
|
|
496
603
|
this.initConversationsHandler(currentUser.uid);
|
|
497
604
|
this.initArchivedConversationsHandler(currentUser.uid);
|
|
498
605
|
}
|
|
@@ -508,9 +615,17 @@ export class AppComponent implements OnInit {
|
|
|
508
615
|
this.chatManager.startApp();
|
|
509
616
|
}
|
|
510
617
|
|
|
618
|
+
|
|
619
|
+
webSocketClose() {
|
|
620
|
+
this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
|
|
621
|
+
this.webSocketJs.close()
|
|
622
|
+
}
|
|
623
|
+
|
|
511
624
|
goOffLine = () => {
|
|
512
|
-
this.logger.log('[APP-COMP]
|
|
513
|
-
|
|
625
|
+
this.logger.log('[APP-COMP] - GO-OFFLINE');
|
|
626
|
+
|
|
627
|
+
this.webSocketClose()
|
|
628
|
+
// this.isOnline = false;
|
|
514
629
|
// this.conversationsHandlerService.conversations = [];
|
|
515
630
|
|
|
516
631
|
this.chatManager.setTiledeskToken(null);
|
|
@@ -518,14 +633,14 @@ export class AppComponent implements OnInit {
|
|
|
518
633
|
this.chatManager.goOffLine();
|
|
519
634
|
|
|
520
635
|
this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
|
|
521
|
-
|
|
522
|
-
clearTimeout(this.timeModalLogin);
|
|
523
|
-
this.timeModalLogin = setTimeout(() => {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}, 1000);
|
|
636
|
+
|
|
637
|
+
// clearTimeout(this.timeModalLogin);
|
|
638
|
+
// this.timeModalLogin = setTimeout(() => {
|
|
639
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
640
|
+
this.authModal = this.presentModal('goOffLine');
|
|
641
|
+
this.hadBeenCalledOpenModal = true
|
|
642
|
+
}
|
|
643
|
+
// }, 1000);
|
|
529
644
|
|
|
530
645
|
// this.unsubscribe$.next();
|
|
531
646
|
// this.unsubscribe$.complete();
|
|
@@ -671,20 +786,31 @@ export class AppComponent implements OnInit {
|
|
|
671
786
|
this.logger.log('initialize FROM [APP-COMP] - initSubscriptions');
|
|
672
787
|
|
|
673
788
|
|
|
674
|
-
|
|
675
|
-
|
|
789
|
+
// ---------------------------------------------------------------------------------------------------
|
|
790
|
+
// Protecting from multiple subsciptions due to multiple app initializations (call to initializeApp())
|
|
791
|
+
// Only one subscriber x application allowed
|
|
792
|
+
// ---------------------------------------------------------------------------------------------------
|
|
793
|
+
if (this.BSAuthStateChangedSubscriptionRef) {
|
|
794
|
+
this.logger.log('initialize FROM [APP-COMP] - BSAuthStateChanged ALREADY SUBSCRIBED');
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
this.BSAuthStateChangedSubscriptionRef = this.messagingAuthService.BSAuthStateChanged
|
|
799
|
+
|
|
800
|
+
// .pipe(takeUntil(this.unsubscribe$))
|
|
676
801
|
.pipe(filter((state) => state !== null))
|
|
677
802
|
.subscribe((state: any) => {
|
|
678
|
-
this.logger.
|
|
679
|
-
this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged isOnline', this.isOnline);
|
|
803
|
+
this.logger.log('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged state', state);
|
|
804
|
+
// this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged isOnline', this.isOnline);
|
|
680
805
|
if (state && state === AUTH_STATE_ONLINE) {
|
|
681
|
-
const user = this.tiledeskAuthService.getCurrentUser();
|
|
682
|
-
if (this.isOnline === false) {
|
|
683
|
-
|
|
684
|
-
|
|
806
|
+
// const user = this.tiledeskAuthService.getCurrentUser();
|
|
807
|
+
// if (this.isOnline === false) {
|
|
808
|
+
// if (AUTH_STATE_ONLINE) {
|
|
809
|
+
this.goOnLine();
|
|
810
|
+
// }
|
|
685
811
|
} else if (state === AUTH_STATE_OFFLINE) {
|
|
686
|
-
//
|
|
687
|
-
this.
|
|
812
|
+
// this.checkTokenAndGoOffline() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
|
|
813
|
+
this.goOffLine()
|
|
688
814
|
}
|
|
689
815
|
}, error => {
|
|
690
816
|
this.logger.error('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged * error * ', error)
|
|
@@ -726,7 +852,7 @@ export class AppComponent implements OnInit {
|
|
|
726
852
|
* apro dettaglio conversazione
|
|
727
853
|
*/
|
|
728
854
|
subscribeChangedConversationSelected = (user: UserModel, type: string) => {
|
|
729
|
-
this.logger.
|
|
855
|
+
this.logger.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
|
|
730
856
|
// this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
|
|
731
857
|
this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
|
|
732
858
|
}
|
|
@@ -916,31 +1042,43 @@ export class AppComponent implements OnInit {
|
|
|
916
1042
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
|
|
917
1043
|
@HostListener('window:storage', ['$event'])
|
|
918
1044
|
onStorageChanged(event: any) {
|
|
919
|
-
|
|
1045
|
+
|
|
920
1046
|
if (event.key !== 'chat_sv5__tiledeskToken') {
|
|
921
1047
|
return;
|
|
922
1048
|
}
|
|
923
1049
|
|
|
924
1050
|
if (this.appStorageService.getItem('tiledeskToken') === null) {
|
|
925
|
-
|
|
1051
|
+
// console.log('[APP-COMP] - onStorageChanged tiledeskToken is null - RUN LOGOUT')
|
|
926
1052
|
this.tiledeskAuthService.logOut()
|
|
927
1053
|
this.messagingAuthService.logout();
|
|
928
1054
|
this.events.publish('profileInfoButtonClick:logout', true);
|
|
929
|
-
this.isOnline = false;
|
|
1055
|
+
// this.isOnline = false;
|
|
930
1056
|
}
|
|
931
1057
|
else {
|
|
932
1058
|
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
1059
|
+
// console.log('[APP-COMP] - X - onStorageChanged currentUser', currentUser)
|
|
1060
|
+
|
|
1061
|
+
const currentToken = this.tiledeskAuthService.getTiledeskToken();
|
|
1062
|
+
// console.log('[APP-COMP] - onStorageChanged currentToken', currentToken)
|
|
1063
|
+
if (this.appStorageService.getItem('tiledeskToken') !== null && currentToken !== this.appStorageService.getItem('tiledeskToken')) {
|
|
1064
|
+
|
|
1065
|
+
// console.log('[APP-COMP] - onStorageChanged wentOnline 2')
|
|
1066
|
+
// DEALLOCO RISORSE OCCUPATE
|
|
1067
|
+
this.messagingAuthService.logout();
|
|
1068
|
+
this.appStorageService.removeItem('currentUser')
|
|
1069
|
+
this.tiledeskAuthService.setCurrentUser(null);
|
|
1070
|
+
// this.unsubscribe$.next();
|
|
1071
|
+
// this.unsubscribe$.complete();
|
|
1072
|
+
this.initializeApp('onstoragechanged');
|
|
933
1073
|
|
|
934
|
-
if (!currentUser && this.appStorageService.getItem('tiledeskToken') !== null) {
|
|
935
|
-
this.logger.log('[APP-COMP] - onStorageChanged currentUser', currentUser)
|
|
936
|
-
// console.log('[APP-COMP] - onStorageChanged wentOnline 2', this.wentOnline)
|
|
937
1074
|
|
|
938
|
-
|
|
1075
|
+
|
|
1076
|
+
// console.log('[APP-COMP] onAuthStateChanged HERE !!! ')
|
|
1077
|
+
// firebase.auth().onAuthStateChanged(user => {
|
|
1078
|
+
// console.log('[APP-COMP] onAuthStateChanged', user)
|
|
1079
|
+
// })
|
|
939
1080
|
|
|
940
1081
|
}
|
|
941
1082
|
}
|
|
942
1083
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
1084
|
}
|