@chat21/chat21-ionic 3.0.59-rc2 → 3.0.59-rc21
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 +72 -1
- package/README.md +5 -0
- package/config.xml +2 -2
- package/env.sample +3 -1
- 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.scss +10 -5
- package/src/app/app.component.ts +339 -65
- package/src/app/app.module.ts +16 -8
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +20 -8
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +0 -144
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +14 -17
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
- package/src/app/components/authentication/login/login.component.html +10 -10
- 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/header-conversation-detail/header-conversation-detail.component.html +2 -4
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +7 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +20 -15
- 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/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 +317 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.html +9 -3
- package/src/app/pages/authentication/login/login.page.html +1 -2
- package/src/app/pages/authentication/login/login.page.ts +1 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +26 -22
- package/src/app/pages/conversations-list/conversations-list.page.html +45 -23
- package/src/app/pages/conversations-list/conversations-list.page.scss +290 -127
- package/src/app/pages/conversations-list/conversations-list.page.ts +189 -17
- 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/app-config.ts +77 -5
- package/src/app/services/tiledesk/tiledesk.service.ts +22 -1
- package/src/app/services/websocket/websocket-js.ts +557 -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 +3 -0
- package/src/assets/i18n/en.json +9 -1
- package/src/assets/i18n/it.json +9 -1
- package/src/assets/js/chat21client.js +144 -82
- package/src/assets/logo.png +0 -0
- package/src/assets/transparent.png +0 -0
- package/src/chat-config-pre-test.json +3 -1
- package/src/chat-config-template.json +4 -1
- package/src/chat-config.json +4 -1
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +2 -2
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +31 -23
- package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +3 -5
- 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 +13 -4
- package/src/chat21-core/utils/utils-message.ts +2 -2
- package/src/firebase-messaging-sw-template.js +1 -1
- package/src/assets/images/tiledesk_logo_50x50.png +0 -0
package/src/app/app.component.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { URL_SOUND_LIST_CONVERSATION } from './../chat21-core/utils/constants';
|
|
|
2
2
|
import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service';
|
|
3
3
|
import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
|
|
4
4
|
|
|
5
|
-
import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, } from '@angular/core';
|
|
5
|
+
import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, AfterViewInit, } from '@angular/core';
|
|
6
6
|
import { Config, Platform, IonRouterOutlet, IonSplitPane, NavController, MenuController, AlertController, IonNav, ToastController } from '@ionic/angular';
|
|
7
7
|
import { ActivatedRoute, NavigationStart, Router } from '@angular/router';
|
|
8
8
|
import { Subscription, VirtualTimeScheduler } from 'rxjs';
|
|
@@ -55,10 +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
|
-
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
|
|
58
|
+
import { filter } from 'rxjs/operators'
|
|
59
|
+
import { WebSocketJs } from './services/websocket/websocket-js';
|
|
60
|
+
import { Location } from '@angular/common'
|
|
62
61
|
// import { filter } from 'rxjs/operators';
|
|
63
62
|
|
|
64
63
|
@Component({
|
|
@@ -99,15 +98,17 @@ export class AppComponent implements OnInit {
|
|
|
99
98
|
public missingConnectionToast: any
|
|
100
99
|
public executedInitializeAppByWatchConnection: boolean = false;
|
|
101
100
|
private version: string;
|
|
102
|
-
|
|
101
|
+
|
|
103
102
|
// private isOnline: boolean = false;
|
|
104
103
|
|
|
104
|
+
wsService: WebSocketJs;
|
|
105
|
+
|
|
105
106
|
constructor(
|
|
106
107
|
private platform: Platform,
|
|
107
108
|
private splashScreen: SplashScreen,
|
|
108
109
|
private statusBar: StatusBar,
|
|
109
110
|
private appConfigProvider: AppConfigProvider,
|
|
110
|
-
|
|
111
|
+
public events: EventsService,
|
|
111
112
|
public config: Config,
|
|
112
113
|
public chatManager: ChatManager,
|
|
113
114
|
public translate: TranslateService,
|
|
@@ -136,39 +137,173 @@ export class AppComponent implements OnInit {
|
|
|
136
137
|
public toastController: ToastController,
|
|
137
138
|
// private network: Network,
|
|
138
139
|
// private tiledeskService: TiledeskService,
|
|
139
|
-
private networkService: NetworkService
|
|
140
|
+
private networkService: NetworkService,
|
|
141
|
+
public webSocketJs: WebSocketJs,
|
|
142
|
+
public location: Location
|
|
140
143
|
) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
|
|
144
|
+
|
|
145
|
+
this.saveInStorageNumberOfOpenedChatTab();
|
|
146
|
+
|
|
147
|
+
this.listenToUrlChanges();
|
|
148
|
+
// this.getPageState();
|
|
149
|
+
|
|
150
|
+
// location.subscribe((val) => {
|
|
151
|
+
|
|
152
|
+
// console.log('location subscribe val', val)
|
|
153
|
+
// if (val.type == "hashchange") {
|
|
154
|
+
// const convId = getParameterByName('convId')
|
|
155
|
+
// console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
|
|
156
|
+
// const requesterFullaname = getParameterByName('requester_fullaname')
|
|
157
|
+
// console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', requesterFullaname);
|
|
158
|
+
|
|
159
|
+
// this.navigateToDetail(convId, requesterFullaname)
|
|
160
|
+
|
|
161
|
+
// this.events.publish('convid:haschanged', convId);
|
|
162
|
+
// }
|
|
147
163
|
// });
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
148
168
|
}
|
|
149
169
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
170
|
+
listenToUrlChanges() {
|
|
171
|
+
const self = this;
|
|
172
|
+
window.addEventListener('hashchange', function () {
|
|
173
|
+
// console.log('location changed!');
|
|
174
|
+
|
|
175
|
+
const convId = getParameterByName('convId')
|
|
176
|
+
// console.log('[APP-COMP] getParameterByName convId ', convId)
|
|
177
|
+
if (convId) {
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
self.events.publish('supportconvid:haschanged', convId);
|
|
180
|
+
}, 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const contact_id = getParameterByName('contact_id')
|
|
184
|
+
// console.log('[APP-COMP] getParameterByName contact_id ', contact_id)
|
|
185
|
+
const contact_fullname = getParameterByName('contact_fullname')
|
|
186
|
+
// console.log('[APP-COMP] getParameterByName contact_fullname ', contact_fullname)
|
|
187
|
+
if (contact_id && contact_fullname) {
|
|
188
|
+
setTimeout(() => {
|
|
189
|
+
self.router.navigateByUrl('conversation-detail/' + contact_id + '/' + contact_fullname + '/new');
|
|
190
|
+
self.events.publish('directconvid:haschanged', contact_id);
|
|
191
|
+
}, 0);
|
|
192
|
+
|
|
193
|
+
} else {
|
|
194
|
+
// console.log('[APP-COMP] contact_id and contact_fullname are null')
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const conversation_detail = getParameterByName('conversation_detail')
|
|
198
|
+
// console.log('[APP-COMP] getParameterByName conversation_detail ', conversation_detail)
|
|
199
|
+
if (conversation_detail) {
|
|
200
|
+
setTimeout(() => {
|
|
201
|
+
self.router.navigate(['conversation-detail/'])
|
|
202
|
+
}, 0);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
saveInStorageNumberOfOpenedChatTab() {
|
|
208
|
+
this.logger.log('Calling saveInStorageChatOpenedTab!');
|
|
209
|
+
|
|
210
|
+
// https://jsfiddle.net/jjjs5wd3/3/å
|
|
211
|
+
if (+localStorage.tabCount > 0) {
|
|
212
|
+
this.logger.log('Chat IONIC Already open!');
|
|
213
|
+
} else {
|
|
214
|
+
localStorage.tabCount = 0;
|
|
215
|
+
|
|
216
|
+
localStorage.tabCount = +localStorage.tabCount + 1;
|
|
217
|
+
}
|
|
218
|
+
const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
|
|
219
|
+
window.addEventListener(terminationEvent, (event) => {
|
|
220
|
+
if (localStorage.tabCount > 0) {
|
|
221
|
+
localStorage.tabCount = +localStorage.tabCount - 1;
|
|
222
|
+
}
|
|
223
|
+
}, { capture: true });
|
|
155
224
|
}
|
|
225
|
+
|
|
226
|
+
getPageState() {
|
|
227
|
+
const getState = () => {
|
|
228
|
+
localStorage.setItem('visibilityState', document.visibilityState)
|
|
229
|
+
if (document.visibilityState === 'hidden') {
|
|
230
|
+
return 'hidden';
|
|
231
|
+
}
|
|
232
|
+
if (document.hasFocus()) {
|
|
233
|
+
return 'active';
|
|
234
|
+
}
|
|
235
|
+
return 'passive';
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
let state = getState();
|
|
239
|
+
// console.log('[CONVS-LIST-PAGE] page state ', state)
|
|
240
|
+
// if (state === 'hidden') {
|
|
241
|
+
// console.log(`State change: state ${state}`);
|
|
242
|
+
// localStorage.setItem('hidden', 'true')
|
|
243
|
+
// }
|
|
244
|
+
|
|
245
|
+
const logStateChange = (nextState) => {
|
|
246
|
+
|
|
247
|
+
const prevState = state;
|
|
248
|
+
if (nextState !== prevState) {
|
|
249
|
+
console.log(`State change: ${prevState} >>> ${nextState}`);
|
|
250
|
+
state = nextState;
|
|
251
|
+
localStorage.setItem('state', nextState)
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
|
|
257
|
+
window.addEventListener(type, () => logStateChange(getState()), { capture: true });
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// The next two listeners, on the other hand, can determine the next
|
|
261
|
+
// state from the event itself.
|
|
262
|
+
window.addEventListener('freeze', () => {
|
|
263
|
+
// In the freeze event, the next state is always frozen.
|
|
264
|
+
logStateChange('frozen');
|
|
265
|
+
}, { capture: true });
|
|
266
|
+
|
|
267
|
+
window.addEventListener('pagehide', (event) => {
|
|
268
|
+
if (event.persisted) {
|
|
269
|
+
// If the event's persisted property is `true` the page is about
|
|
270
|
+
// to enter the Back-Forward Cache, which is also in the frozen state.
|
|
271
|
+
logStateChange('frozen');
|
|
272
|
+
localStorage.setItem('state', 'frozen')
|
|
273
|
+
} else {
|
|
274
|
+
// If the event's persisted property is not `true` the page is
|
|
275
|
+
// about to be unloaded.
|
|
276
|
+
logStateChange('terminated');
|
|
277
|
+
localStorage.setItem('state', 'terminated')
|
|
278
|
+
localStorage.setItem('terminated', 'true')
|
|
279
|
+
}
|
|
280
|
+
}, { capture: true });
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
// param() {
|
|
286
|
+
// // PARAM
|
|
287
|
+
// const url: URL = new URL(window.top.location.href);
|
|
288
|
+
// const params: URLSearchParams = url.searchParams;
|
|
289
|
+
// return params;
|
|
290
|
+
// }
|
|
156
291
|
/**
|
|
157
292
|
*/
|
|
158
293
|
ngOnInit() {
|
|
159
294
|
const appconfig = this.appConfigProvider.getConfig();
|
|
160
295
|
this.persistence = appconfig.authPersistence;
|
|
161
296
|
this.appStorageService.initialize(environment.storage_prefix, this.persistence, '')
|
|
162
|
-
this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
|
|
163
|
-
this.logger.log('[APP-COMP] ngOnInit this.route.snapshot.params -->', this.route.snapshot.params);
|
|
297
|
+
// this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
|
|
298
|
+
// this.logger.log('[APP-COMP] ngOnInit this.route.snapshot.params -->', this.route.snapshot.params);
|
|
164
299
|
// this.initializeApp('oninit');
|
|
165
300
|
const token = getParameterByName('jwt')
|
|
166
|
-
this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName -->', token);
|
|
301
|
+
// this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName -->', token);
|
|
167
302
|
|
|
168
303
|
if (token) {
|
|
169
304
|
// this.isOnline = false;
|
|
170
305
|
// this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with this.isOnline ', this.isOnline)
|
|
171
|
-
|
|
306
|
+
console.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName ', token)
|
|
172
307
|
// save token in local storage then
|
|
173
308
|
|
|
174
309
|
const storedToken = this.appStorageService.getItem('tiledeskToken');
|
|
@@ -180,11 +315,83 @@ export class AppComponent implements OnInit {
|
|
|
180
315
|
this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN the current user already exist DON\'T SAVE ')
|
|
181
316
|
}
|
|
182
317
|
}
|
|
318
|
+
|
|
319
|
+
|
|
183
320
|
this.initializeApp('oninit');
|
|
321
|
+
this.listenToPostMsgs();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
listenToPostMsgs() {
|
|
326
|
+
window.addEventListener("message", (event) => {
|
|
327
|
+
// console.log("[APP-COMP] message event ", event);
|
|
328
|
+
|
|
329
|
+
if (event && event.data && event.data.action && event.data.parameter) {
|
|
330
|
+
if (event.data.action === 'openJoinConversationModal') {
|
|
331
|
+
// console.log("[APP-COMP] message event action ", event.data.action);
|
|
332
|
+
// console.log("[APP-COMP] message event parameter ", event.data.parameter);
|
|
333
|
+
this.presentAlertConfirmJoinRequest(event.data.parameter, event.data.calledBy)
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (event && event.data && event.data.action && event.data.text) {
|
|
337
|
+
if (event.data.action === "display_toast_join_complete") {
|
|
338
|
+
this.presentToastJoinComplete(event.data.text)
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
}
|
|
184
343
|
|
|
344
|
+
async presentToastJoinComplete(text) {
|
|
345
|
+
const toast = await this.toastController.create({
|
|
346
|
+
message: text,
|
|
347
|
+
duration: 2000,
|
|
348
|
+
color: "success"
|
|
349
|
+
});
|
|
350
|
+
toast.present();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
async presentAlertConfirmJoinRequest(requestid, calledby) {
|
|
354
|
+
var iframeWin = <HTMLIFrameElement>document.getElementById("unassigned-convs-iframe")
|
|
355
|
+
// console.log("[APP-COMP] message event iframeWin ", iframeWin);
|
|
356
|
+
|
|
357
|
+
const isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
|
|
358
|
+
input !== null && input.tagName === 'IFRAME';
|
|
359
|
+
|
|
360
|
+
const keys = ['YouAreAboutToJoinThisChat', 'Cancel', 'AreYouSure'];
|
|
361
|
+
const translationMap = this.translateService.translateLanguage(keys);
|
|
362
|
+
|
|
363
|
+
const alert = await this.alertController.create({
|
|
364
|
+
cssClass: 'my-custom-class',
|
|
365
|
+
header: translationMap.get('AreYouSure'),
|
|
366
|
+
message: translationMap.get('YouAreAboutToJoinThisChat'),
|
|
367
|
+
buttons: [
|
|
368
|
+
{
|
|
369
|
+
text: translationMap.get('Cancel'),
|
|
370
|
+
role: 'cancel',
|
|
371
|
+
cssClass: 'secondary',
|
|
372
|
+
handler: (blah) => {
|
|
373
|
+
// console.log('Confirm Cancel: blah', blah);
|
|
374
|
+
}
|
|
375
|
+
}, {
|
|
376
|
+
text: 'Ok',
|
|
377
|
+
handler: () => {
|
|
378
|
+
// console.log('Confirm Okay');
|
|
379
|
+
|
|
380
|
+
if (isIFrame(iframeWin) && iframeWin.contentWindow) {
|
|
381
|
+
const msg = { action: "joinConversation", parameter: requestid, calledBy: calledby }
|
|
382
|
+
iframeWin.contentWindow.postMessage(msg, '*');
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
]
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
await alert.present();
|
|
185
390
|
}
|
|
186
391
|
|
|
187
392
|
|
|
393
|
+
|
|
394
|
+
|
|
188
395
|
signInWithCustomToken(token) {
|
|
189
396
|
// this.isOnline = false;
|
|
190
397
|
this.logger.log('[APP-COMP] SIGNINWITHCUSTOMTOKEN token', token)
|
|
@@ -200,12 +407,12 @@ export class AppComponent implements OnInit {
|
|
|
200
407
|
|
|
201
408
|
/** */
|
|
202
409
|
initializeApp(calledby: string) {
|
|
203
|
-
this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
|
|
204
|
-
|
|
410
|
+
// this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
|
|
411
|
+
// console.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
|
|
205
412
|
|
|
206
|
-
if (!this.platform.is('cordova')) {
|
|
207
|
-
|
|
208
|
-
}
|
|
413
|
+
// if (!this.platform.is('cordova')) {
|
|
414
|
+
this.splashScreen.show();
|
|
415
|
+
// }
|
|
209
416
|
this.tabTitle = document.title;
|
|
210
417
|
|
|
211
418
|
this.getRouteParamsAndSetLoggerConfig();
|
|
@@ -223,12 +430,39 @@ export class AppComponent implements OnInit {
|
|
|
223
430
|
this.notificationsEnabled = true;
|
|
224
431
|
this.zone = new NgZone({}); // a cosa serve?
|
|
225
432
|
|
|
433
|
+
// ------------------------------------------
|
|
434
|
+
// Platform ready
|
|
435
|
+
// ------------------------------------------
|
|
226
436
|
this.platform.ready().then(() => {
|
|
227
|
-
|
|
437
|
+
// console.log("Check platform");
|
|
438
|
+
if (this.platform.is('cordova')) {
|
|
439
|
+
// console.log("the device running Cordova");
|
|
440
|
+
}
|
|
441
|
+
if (!this.platform.is('cordova')) {
|
|
442
|
+
// console.log("the device Not running Cordova");
|
|
443
|
+
}
|
|
228
444
|
|
|
229
|
-
if (this.
|
|
230
|
-
|
|
445
|
+
if (this.platform.is('android')) {
|
|
446
|
+
// console.log("running on Android device!");
|
|
231
447
|
}
|
|
448
|
+
if (this.platform.is('ios')) {
|
|
449
|
+
// console.log("running on iOS device!");
|
|
450
|
+
}
|
|
451
|
+
if (this.platform.is('mobileweb')) {
|
|
452
|
+
// console.log("running in a browser on mobile!");
|
|
453
|
+
}
|
|
454
|
+
if (this.platform.is('desktop')) {
|
|
455
|
+
// console.log("running on desktop!");
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
this.setLanguage();
|
|
462
|
+
|
|
463
|
+
// if (this.splashScreen) {
|
|
464
|
+
this.splashScreen.hide();
|
|
465
|
+
// }
|
|
232
466
|
this.statusBar.styleDefault();
|
|
233
467
|
this.navService.init(this.sidebarNav, this.detailNav);
|
|
234
468
|
// this.persistence = appconfig.authPersistence;
|
|
@@ -320,7 +554,7 @@ export class AppComponent implements OnInit {
|
|
|
320
554
|
getRouteParamsAndSetLoggerConfig() {
|
|
321
555
|
const appconfig = this.appConfigProvider.getConfig();
|
|
322
556
|
this.route.queryParams.subscribe(params => {
|
|
323
|
-
this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
|
|
557
|
+
// this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
|
|
324
558
|
if (params.logLevel) {
|
|
325
559
|
this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
|
|
326
560
|
this.logger.setLoggerConfig(true, params.logLevel)
|
|
@@ -352,6 +586,7 @@ export class AppComponent implements OnInit {
|
|
|
352
586
|
/**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
|
|
353
587
|
private initAuthentication() {
|
|
354
588
|
const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
589
|
+
|
|
355
590
|
this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
|
|
356
591
|
this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
|
|
357
592
|
// const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
@@ -360,19 +595,19 @@ export class AppComponent implements OnInit {
|
|
|
360
595
|
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 <<<')
|
|
361
596
|
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
|
|
362
597
|
this.logger.log('[APP-COMP] >>> initAuthentication user ', user)
|
|
363
|
-
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
598
|
+
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
364
599
|
}).catch(error => {
|
|
365
600
|
this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::', error)
|
|
366
601
|
})
|
|
367
602
|
} else {
|
|
368
603
|
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
|
|
369
|
-
|
|
604
|
+
|
|
370
605
|
// clearTimeout(this.timeModalLogin);
|
|
371
606
|
// this.timeModalLogin = setTimeout(() => {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
607
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
608
|
+
this.authModal = this.presentModal('initAuthentication');
|
|
609
|
+
this.hadBeenCalledOpenModal = true;
|
|
610
|
+
}
|
|
376
611
|
// }, 1000);
|
|
377
612
|
}
|
|
378
613
|
}
|
|
@@ -385,6 +620,18 @@ export class AppComponent implements OnInit {
|
|
|
385
620
|
// }
|
|
386
621
|
// }
|
|
387
622
|
|
|
623
|
+
connetWebsocket(tiledeskToken) {
|
|
624
|
+
const appconfig = this.appConfigProvider.getConfig();
|
|
625
|
+
this.logger.log('connetWebsocket appconfig wsUrl ', appconfig.wsUrl)
|
|
626
|
+
const WS_URL = appconfig.wsUrl + '?token=' + tiledeskToken
|
|
627
|
+
this.webSocketJs.init(
|
|
628
|
+
WS_URL,
|
|
629
|
+
undefined,
|
|
630
|
+
undefined,
|
|
631
|
+
undefined
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
|
|
388
635
|
/**
|
|
389
636
|
* goOnLine:
|
|
390
637
|
* 1 - nascondo splashscreen
|
|
@@ -393,11 +640,14 @@ export class AppComponent implements OnInit {
|
|
|
393
640
|
* @param user
|
|
394
641
|
*/
|
|
395
642
|
goOnLine = () => {
|
|
643
|
+
// console.log('[APP-COMP] - GO-ONLINE ');
|
|
396
644
|
// this.isOnline = true;
|
|
397
645
|
// this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
|
|
398
646
|
|
|
399
|
-
clearTimeout(this.timeModalLogin);
|
|
647
|
+
// clearTimeout(this.timeModalLogin);
|
|
400
648
|
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
|
|
649
|
+
this.connetWebsocket(tiledeskToken)
|
|
650
|
+
this.events.publish('go:online', true);
|
|
401
651
|
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
402
652
|
// this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
|
|
403
653
|
this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
|
|
@@ -426,11 +676,20 @@ export class AppComponent implements OnInit {
|
|
|
426
676
|
} catch (err) {
|
|
427
677
|
this.logger.error('[APP-COMP] -> error:', err);
|
|
428
678
|
}
|
|
429
|
-
|
|
679
|
+
// this.chatManager.startApp() // nk moved in chevk platform
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
webSocketClose() {
|
|
684
|
+
this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
|
|
685
|
+
this.webSocketJs.close()
|
|
686
|
+
this.events.publish('go:offline', true);
|
|
430
687
|
}
|
|
431
688
|
|
|
432
689
|
goOffLine = () => {
|
|
433
|
-
|
|
690
|
+
// console.log('[APP-COMP] - GO-OFFLINE');
|
|
691
|
+
|
|
692
|
+
this.webSocketClose()
|
|
434
693
|
// this.isOnline = false;
|
|
435
694
|
// this.conversationsHandlerService.conversations = [];
|
|
436
695
|
|
|
@@ -439,13 +698,13 @@ export class AppComponent implements OnInit {
|
|
|
439
698
|
this.chatManager.goOffLine();
|
|
440
699
|
|
|
441
700
|
this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
|
|
442
|
-
|
|
701
|
+
|
|
443
702
|
// clearTimeout(this.timeModalLogin);
|
|
444
703
|
// this.timeModalLogin = setTimeout(() => {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
704
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
705
|
+
this.authModal = this.presentModal('goOffLine');
|
|
706
|
+
this.hadBeenCalledOpenModal = true
|
|
707
|
+
}
|
|
449
708
|
// }, 1000);
|
|
450
709
|
|
|
451
710
|
// this.unsubscribe$.next();
|
|
@@ -472,7 +731,7 @@ export class AppComponent implements OnInit {
|
|
|
472
731
|
}
|
|
473
732
|
|
|
474
733
|
checkPlatform() {
|
|
475
|
-
|
|
734
|
+
// console.log('[APP-COMP] checkPlatform');
|
|
476
735
|
// let pageUrl = '';
|
|
477
736
|
// try {
|
|
478
737
|
// const pathPage = this.route.snapshot.firstChild.routeConfig.path;
|
|
@@ -488,16 +747,23 @@ export class AppComponent implements OnInit {
|
|
|
488
747
|
// }
|
|
489
748
|
|
|
490
749
|
if (checkPlatformIsMobile()) {
|
|
750
|
+
this.chatManager.startApp()
|
|
751
|
+
console.log('[APP-COMP] checkPlatformIsMobile',checkPlatformIsMobile());
|
|
491
752
|
this.platformIs = PLATFORM_MOBILE;
|
|
492
753
|
const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
|
|
493
|
-
|
|
754
|
+
// console.log('[APP-COMP] platformIs', this.platformIs);
|
|
755
|
+
// console.log('[APP-COMP] PLATFORM', PLATFORM_MOBILE, 'route.snapshot', this.route.snapshot);
|
|
494
756
|
if (!IDConv) {
|
|
495
757
|
this.router.navigateByUrl('conversations-list')
|
|
496
758
|
}
|
|
497
759
|
// this.router.navigateByUrl(pageUrl);
|
|
498
760
|
// this.navService.setRoot(ConversationListPage, {});
|
|
499
761
|
} else {
|
|
762
|
+
this.chatManager.startApp()
|
|
763
|
+
console.log('[APP-COMP] checkPlatformIsMobile',checkPlatformIsMobile());
|
|
500
764
|
this.platformIs = PLATFORM_DESKTOP;
|
|
765
|
+
// console.log('[APP-COMP] platformIs', this.platformIs);
|
|
766
|
+
// console.log('[APP-COMP] PLATFORM', PLATFORM_DESKTOP, 'route.snapshot', this.route.snapshot);
|
|
501
767
|
this.logger.log('[APP-COMP] PLATFORM_DESKTOP ', this.navService);
|
|
502
768
|
|
|
503
769
|
this.navService.setRoot(ConversationListPage, {});
|
|
@@ -537,16 +803,23 @@ export class AppComponent implements OnInit {
|
|
|
537
803
|
}
|
|
538
804
|
|
|
539
805
|
private initAudio() {
|
|
806
|
+
// console.log('HERE IS initAudio ')
|
|
540
807
|
// SET AUDIO
|
|
808
|
+
const href = window.location.href;
|
|
809
|
+
const hrefArray = href.split('/#/');
|
|
810
|
+
const chatBaseUrl = hrefArray[0]
|
|
811
|
+
// console.log('initAudio href', href)
|
|
812
|
+
// console.log('initAudio chatBaseUrl', chatBaseUrl)
|
|
813
|
+
|
|
541
814
|
this.audio = new Audio();
|
|
542
|
-
this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
815
|
+
this.audio.src = chatBaseUrl + URL_SOUND_LIST_CONVERSATION;
|
|
543
816
|
this.audio.load();
|
|
544
817
|
}
|
|
545
818
|
|
|
546
819
|
private manageTabNotification() {
|
|
547
820
|
if (!this.isTabVisible) {
|
|
548
821
|
// TAB IS HIDDEN --> manage title and SOUND
|
|
549
|
-
|
|
822
|
+
// console.log('HERE IS manageTabNotification ')
|
|
550
823
|
let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
|
|
551
824
|
badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
|
|
552
825
|
document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
|
|
@@ -565,6 +838,7 @@ export class AppComponent implements OnInit {
|
|
|
565
838
|
}
|
|
566
839
|
|
|
567
840
|
soundMessage() {
|
|
841
|
+
// console.log('HERE IS soundMessage ')
|
|
568
842
|
const that = this;
|
|
569
843
|
// this.audio = new Audio();
|
|
570
844
|
// // this.audio.src = '/assets/sounds/pling.mp3';
|
|
@@ -576,7 +850,7 @@ export class AppComponent implements OnInit {
|
|
|
576
850
|
that.audio.play().then(() => {
|
|
577
851
|
that.logger.debug('[APP-COMP] ****** soundMessage played *****');
|
|
578
852
|
}).catch((error: any) => {
|
|
579
|
-
that.logger.
|
|
853
|
+
that.logger.error('[APP-COMP] ***soundMessage error*', error);
|
|
580
854
|
});
|
|
581
855
|
}, 1000);
|
|
582
856
|
}
|
|
@@ -601,8 +875,8 @@ export class AppComponent implements OnInit {
|
|
|
601
875
|
return;
|
|
602
876
|
}
|
|
603
877
|
|
|
604
|
-
this.BSAuthStateChangedSubscriptionRef = this.messagingAuthService.BSAuthStateChanged
|
|
605
|
-
|
|
878
|
+
this.BSAuthStateChangedSubscriptionRef = this.messagingAuthService.BSAuthStateChanged
|
|
879
|
+
|
|
606
880
|
// .pipe(takeUntil(this.unsubscribe$))
|
|
607
881
|
.pipe(filter((state) => state !== null))
|
|
608
882
|
.subscribe((state: any) => {
|
|
@@ -639,7 +913,7 @@ export class AppComponent implements OnInit {
|
|
|
639
913
|
|
|
640
914
|
this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
|
|
641
915
|
|
|
642
|
-
|
|
916
|
+
// console.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
|
|
643
917
|
const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
644
918
|
this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
|
|
645
919
|
|
|
@@ -658,7 +932,7 @@ export class AppComponent implements OnInit {
|
|
|
658
932
|
* apro dettaglio conversazione
|
|
659
933
|
*/
|
|
660
934
|
subscribeChangedConversationSelected = (user: UserModel, type: string) => {
|
|
661
|
-
|
|
935
|
+
console.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
|
|
662
936
|
// this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
|
|
663
937
|
this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
|
|
664
938
|
}
|
|
@@ -811,8 +1085,8 @@ export class AppComponent implements OnInit {
|
|
|
811
1085
|
onResize(event: any) {
|
|
812
1086
|
const that = this;
|
|
813
1087
|
// this.logger.debug('this.doitResize)', this.doitResize)
|
|
814
|
-
clearTimeout(this.doitResize);
|
|
815
|
-
this.doitResize = setTimeout(() => {
|
|
1088
|
+
// clearTimeout(this.doitResize);
|
|
1089
|
+
// this.doitResize = setTimeout(() => {
|
|
816
1090
|
let platformIsNow = PLATFORM_DESKTOP;
|
|
817
1091
|
if (checkPlatformIsMobile()) {
|
|
818
1092
|
platformIsNow = PLATFORM_MOBILE;
|
|
@@ -822,11 +1096,14 @@ export class AppComponent implements OnInit {
|
|
|
822
1096
|
}
|
|
823
1097
|
this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
|
|
824
1098
|
this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
|
|
825
|
-
|
|
1099
|
+
console.log('[APP-COMP] onResize width:::: this.platformIs', this.platformIs);
|
|
1100
|
+
console.log('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
|
|
826
1101
|
if (platformIsNow !== this.platformIs) {
|
|
827
|
-
window.location.reload();
|
|
1102
|
+
// window.location.reload();
|
|
1103
|
+
this.checkPlatform()
|
|
828
1104
|
}
|
|
829
|
-
|
|
1105
|
+
|
|
1106
|
+
// }, 0);
|
|
830
1107
|
}
|
|
831
1108
|
// END RESIZE FUNCTIONS //
|
|
832
1109
|
|
|
@@ -848,7 +1125,7 @@ export class AppComponent implements OnInit {
|
|
|
848
1125
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
|
|
849
1126
|
@HostListener('window:storage', ['$event'])
|
|
850
1127
|
onStorageChanged(event: any) {
|
|
851
|
-
|
|
1128
|
+
|
|
852
1129
|
if (event.key !== 'chat_sv5__tiledeskToken') {
|
|
853
1130
|
return;
|
|
854
1131
|
}
|
|
@@ -877,7 +1154,7 @@ export class AppComponent implements OnInit {
|
|
|
877
1154
|
// this.unsubscribe$.complete();
|
|
878
1155
|
this.initializeApp('onstoragechanged');
|
|
879
1156
|
|
|
880
|
-
|
|
1157
|
+
|
|
881
1158
|
|
|
882
1159
|
// console.log('[APP-COMP] onAuthStateChanged HERE !!! ')
|
|
883
1160
|
// firebase.auth().onAuthStateChanged(user => {
|
|
@@ -887,7 +1164,4 @@ export class AppComponent implements OnInit {
|
|
|
887
1164
|
}
|
|
888
1165
|
}
|
|
889
1166
|
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
1167
|
}
|