@chat21/chat21-ionic 3.0.54-RC2 → 3.0.55-RC6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/config.xml +1 -0
- package/package.json +6 -2
- package/resources/Android/icon/drawable-hdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-ldpi-icon.png +0 -0
- package/resources/Android/icon/drawable-mdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xhdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xxhdpi-icon.png +0 -0
- package/resources/Android/icon/drawable-xxxhdpi-icon.png +0 -0
- package/resources/Android/icon.png +0 -0
- package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash.png +0 -0
- package/src/app/app.component.ts +504 -433
- package/src/app/app.module.ts +9 -4
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +4 -0
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +27 -30
- package/src/app/chatlib/conversation-detail/message/text/text.component.html +1 -1
- package/src/app/chatlib/conversation-detail/message/text/text.component.ts +27 -3
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +4 -4
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +5 -5
- package/src/app/components/conversation-info/info-content/info-content.component.ts +8 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +33 -25
- package/src/chat-config-pre-test.json +2 -1
- package/src/chat21-core/providers/abstract/messagingAuth.service.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +3 -2
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +84 -17
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +6 -4
- package/src/chat21-core/providers/localSessionStorage.ts +2 -1
- package/src/index.html +87 -6
package/src/app/app.module.ts
CHANGED
|
@@ -92,7 +92,8 @@ import { ConversationInfoModule } from 'src/app/components/conversation-info/con
|
|
|
92
92
|
// Directives
|
|
93
93
|
import { TooltipModule } from 'ng2-tooltip-directive';
|
|
94
94
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
95
|
-
|
|
95
|
+
import { Network } from '@ionic-native/network/ngx';
|
|
96
|
+
import { ConnectionService } from 'ng-connection-service';
|
|
96
97
|
|
|
97
98
|
|
|
98
99
|
// FACTORIES
|
|
@@ -101,7 +102,7 @@ export function createTranslateLoader(http: HttpClient) {
|
|
|
101
102
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
export function authenticationFactory(http: HttpClient, appConfig: AppConfigProvider, chat21Service: Chat21Service, appSorage: AppStorageService) {
|
|
105
|
+
export function authenticationFactory(http: HttpClient, appConfig: AppConfigProvider, chat21Service: Chat21Service, appSorage: AppStorageService, network: Network, connectionService:ConnectionService) {
|
|
105
106
|
const config = appConfig.getConfig()
|
|
106
107
|
if (config.chatEngine === CHAT_ENGINE_MQTT) {
|
|
107
108
|
|
|
@@ -111,12 +112,15 @@ export function authenticationFactory(http: HttpClient, appConfig: AppConfigProv
|
|
|
111
112
|
const auth = new MQTTAuthService(http, chat21Service, appSorage);
|
|
112
113
|
|
|
113
114
|
auth.setBaseUrl(appConfig.getConfig().apiUrl)
|
|
115
|
+
|
|
114
116
|
return auth
|
|
115
117
|
} else {
|
|
116
118
|
|
|
117
119
|
FirebaseInitService.initFirebase(config.firebaseConfig)
|
|
118
|
-
|
|
120
|
+
console.log('[APP-MOD] FirebaseInitService config ', config)
|
|
121
|
+
const auth = new FirebaseAuthService(http, network, connectionService);
|
|
119
122
|
auth.setBaseUrl(config.apiUrl)
|
|
123
|
+
|
|
120
124
|
return auth
|
|
121
125
|
}
|
|
122
126
|
}
|
|
@@ -283,7 +287,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
|
|
|
283
287
|
{
|
|
284
288
|
provide: MessagingAuthService,
|
|
285
289
|
useFactory: authenticationFactory,
|
|
286
|
-
deps: [HttpClient, AppConfigProvider, Chat21Service, AppStorageService]
|
|
290
|
+
deps: [HttpClient, AppConfigProvider, Chat21Service, AppStorageService, Network, ConnectionService]
|
|
287
291
|
},
|
|
288
292
|
{
|
|
289
293
|
provide: PresenceService,
|
|
@@ -343,6 +347,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
|
|
|
343
347
|
StatusBar,
|
|
344
348
|
SplashScreen,
|
|
345
349
|
Keyboard,
|
|
350
|
+
Network,
|
|
346
351
|
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
|
|
347
352
|
EventsService,
|
|
348
353
|
Chooser,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
:host .base_sent .msg_sent ::ng-deep div > div > div > tiledeskwidget-text > p > p > a {
|
|
2
2
|
color: lightblue;
|
|
3
|
+
|
|
3
4
|
}
|
|
4
5
|
|
|
5
6
|
:host .base_sent .msg_sent ::ng-deep div > div > div > tiledeskwidget-text > p > p {
|
|
6
7
|
margin-top:12px !important;
|
|
8
|
+
white-space: nowrap;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
text-overflow: ellipsis;
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
:host .base_sent .msg_sent ::ng-deep > div > div > tiledeskwidget-image > div {
|
package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<!-- [ngClass]="{'button-in-msg' : message.metadata && message.metadata.button}" -->
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<div [ngStyle]="{'padding': (isImage(message) || isFrame(message))?'0px':'0 8px'}" class="messages primary-color"
|
|
3
|
+
[class.emoticon]="message?.emoticon">
|
|
4
|
+
|
|
5
|
+
|
|
5
6
|
<div>
|
|
6
7
|
<!-- message type:: image -->
|
|
7
8
|
<!-- <div *ngIf="message.type == 'image' && message.metadata" [ngStyle] = "{ 'max-width': getSizeImg(message).width, 'max-height': getSizeImg(message).height }">
|
|
@@ -12,16 +13,16 @@
|
|
|
12
13
|
[src]="message.metadata.src" [width]="getSizeImg(message).width"
|
|
13
14
|
[height]="getSizeImg(message).height" /> -->
|
|
14
15
|
|
|
15
|
-
<tiledeskwidget-image *ngIf="isImage(message)"
|
|
16
|
+
<tiledeskwidget-image *ngIf="isImage(message)"
|
|
16
17
|
[metadata]="message.metadata"
|
|
17
|
-
[width]="getMetadataSize(message.metadata).width"
|
|
18
|
+
[width]="getMetadataSize(message.metadata).width"
|
|
18
19
|
[height]="getMetadataSize(message.metadata).height"
|
|
19
20
|
(onImageRendered)="onImageRenderedFN($event)">
|
|
20
21
|
</tiledeskwidget-image>
|
|
21
22
|
|
|
22
|
-
<tiledeskwidget-frame *ngIf="isFrame(message)"
|
|
23
|
+
<tiledeskwidget-frame *ngIf="isFrame(message)"
|
|
23
24
|
[metadata]="message.metadata"
|
|
24
|
-
[width]="getMetadataSize(message.metadata).width"
|
|
25
|
+
[width]="getMetadataSize(message.metadata).width"
|
|
25
26
|
[height]="getMetadataSize(message.metadata).height">
|
|
26
27
|
</tiledeskwidget-frame>
|
|
27
28
|
|
|
@@ -30,22 +31,24 @@
|
|
|
30
31
|
[width]="message.metadata.width"
|
|
31
32
|
[height]="message.metadata.height">
|
|
32
33
|
</tiledeskwidget-frame> -->
|
|
33
|
-
|
|
34
|
-
<!-- message type:: text -->
|
|
35
|
-
<!-- <div *ngIf="message.type == 'text'"> -->
|
|
36
|
-
<div *ngIf="message?.text" [tooltip]="timeTooltipLeft" [options]="tooltipOptions" placement="left" content-type="template" (click)="handleTooltipEvents($event)">
|
|
37
|
-
<ng-template #timeTooltipLeft>
|
|
38
|
-
<span>{{message.timestamp | amTimeAgo}}</span>
|
|
39
|
-
</ng-template>
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
<!-- message type:: text -->
|
|
36
|
+
<!-- <div *ngIf="message.type == 'text'"> -->
|
|
37
|
+
<div *ngIf="message?.text" [tooltip]="timeTooltipLeft" [options]="tooltipOptions" placement="left"
|
|
38
|
+
content-type="template" (click)="handleTooltipEvents($event)">
|
|
39
|
+
<ng-template #timeTooltipLeft>
|
|
40
|
+
<span>{{message.timestamp | amTimeAgo}}</span>
|
|
41
|
+
</ng-template>
|
|
42
|
+
|
|
43
|
+
<tiledeskwidget-text
|
|
44
|
+
[text]="message?.text"
|
|
45
|
+
[color]="textColor"
|
|
46
|
+
[message]="message"
|
|
47
|
+
(onBeforeMessageRender)="returnOnBeforeMessageRender($event)"
|
|
48
|
+
(onAfterMessageRender)="returnOnAfterMessageRender($event)">
|
|
49
|
+
</tiledeskwidget-text>
|
|
50
|
+
<!-- <p #messageEl class="message_innerhtml marked" [innerHTML]="printMessage(message, messageEl, this) | marked"></p> -->
|
|
51
|
+
<!-- <div *ngIf="isPopupUrl(message.text); then contentPopup else contentNewTab">here
|
|
49
52
|
is ignored</div>
|
|
50
53
|
<ng-template #contentPopup>
|
|
51
54
|
<p style="text-decoration: underline; padding:8px; cursor: pointer;"
|
|
@@ -54,13 +57,7 @@
|
|
|
54
57
|
<ng-template #contentNewTab>
|
|
55
58
|
<p #messageEl [innerHTML]="printMessage(message, messageEl, this) | linky"></p>
|
|
56
59
|
</ng-template> -->
|
|
57
|
-
|
|
60
|
+
</div>
|
|
58
61
|
</div>
|
|
59
62
|
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, Sanitizer } from '@angular/core';
|
|
2
|
-
|
|
2
|
+
import { MAX_WIDTH_IMAGES } from 'src/chat21-core/utils/constants';
|
|
3
3
|
@Component({
|
|
4
4
|
selector: 'tiledeskwidget-text',
|
|
5
5
|
templateUrl: './text.component.html',
|
|
@@ -11,7 +11,12 @@ export class TextComponent implements OnInit {
|
|
|
11
11
|
@Input() color: string;
|
|
12
12
|
@Output() onBeforeMessageRender = new EventEmitter();
|
|
13
13
|
@Output() onAfterMessageRender = new EventEmitter();
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
@Input() message: any;
|
|
16
|
+
|
|
17
|
+
public media_width: number;
|
|
18
|
+
public media_height: number;
|
|
19
|
+
|
|
15
20
|
constructor() { }
|
|
16
21
|
|
|
17
22
|
ngOnInit() {
|
|
@@ -19,7 +24,7 @@ export class TextComponent implements OnInit {
|
|
|
19
24
|
|
|
20
25
|
|
|
21
26
|
printMessage(text, messageEl, component) {
|
|
22
|
-
const messageOBJ = { messageEl: messageEl, component: component}
|
|
27
|
+
const messageOBJ = { messageEl: messageEl, component: component }
|
|
23
28
|
this.onBeforeMessageRender.emit(messageOBJ)
|
|
24
29
|
const messageText = text;
|
|
25
30
|
this.onAfterMessageRender.emit(messageOBJ)
|
|
@@ -29,4 +34,23 @@ export class TextComponent implements OnInit {
|
|
|
29
34
|
return messageText;
|
|
30
35
|
}
|
|
31
36
|
|
|
37
|
+
ngOnChanges() {
|
|
38
|
+
if (this.message.type === 'image') {
|
|
39
|
+
console.log('TextComponent message ', this.message)
|
|
40
|
+
if (this.message.metadata.width && this.message.metadata.width > MAX_WIDTH_IMAGES) {
|
|
41
|
+
|
|
42
|
+
const ratio = (this.message.metadata['width'] / this.message.metadata['height']);
|
|
43
|
+
|
|
44
|
+
this.media_width = MAX_WIDTH_IMAGES;
|
|
45
|
+
this.media_height = MAX_WIDTH_IMAGES / ratio;
|
|
46
|
+
|
|
47
|
+
console.log('TextComponent media_width ', this.media_width, ' media_height' , this.media_height)
|
|
48
|
+
} else {
|
|
49
|
+
this.media_width = this.message.metadata.width;
|
|
50
|
+
this.media_height = this.message.metadata.height;
|
|
51
|
+
console.log('TextComponent media_width ', this.media_width, ' media_height' , this.media_height)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
32
56
|
}
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
|
|
41
41
|
</div>
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
<div *ngIf="conversationAvatar" class="tile-info-with" (click)="onOpenCloseInfoConversation()">
|
|
44
44
|
<span class="tile-username">{{ conversationAvatar.conversation_with_fullname }} </span>
|
|
45
|
-
</div>
|
|
45
|
+
</div>
|
|
46
46
|
|
|
47
|
-
<div *ngIf="conversationWithFullname" class="tile-info-with" (click)="onOpenCloseInfoConversation()">
|
|
47
|
+
<!-- <div *ngIf="conversationWithFullname" class="tile-info-with" (click)="onOpenCloseInfoConversation()">
|
|
48
48
|
<span class="tile-username">{{ conversationWithFullname }} </span>
|
|
49
|
-
</div>
|
|
49
|
+
</div> -->
|
|
50
50
|
|
|
51
51
|
</ion-title>
|
|
52
52
|
<!-- openInfoConversation {{openInfoConversation}} -->
|
|
@@ -39,13 +39,13 @@ export class HeaderConversationDetailComponent implements OnInit, OnChanges {
|
|
|
39
39
|
public imageRepoService: ImageRepoService,
|
|
40
40
|
private route: ActivatedRoute,
|
|
41
41
|
) {
|
|
42
|
-
this.route.paramMap.subscribe(params => {
|
|
42
|
+
// this.route.paramMap.subscribe(params => {
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
45
|
+
// this.conversationWithFullname = params.get('FullNameConv');
|
|
46
|
+
// this.logger.log('[CONVS-DETAIL][HEADER]- initialize -> params: ', params);
|
|
47
|
+
// this.logger.log('[CONVS-DETAIL][HEADER]- initialize -> params > : ', this.conversationWithFullname);
|
|
48
|
+
// });
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// ----------------------------------------------------
|
|
@@ -78,8 +78,15 @@ export class InfoContentComponent implements OnInit {
|
|
|
78
78
|
this.logger.log('[INFO-CONTENT-COMP] - paramMap.subscribe conversationWith: ', this.conversationWith);
|
|
79
79
|
this.conversationWithFullname = params.get('FullNameConv');
|
|
80
80
|
this.conv_type = params.get('Convtype');
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
const conversationWith_segments = this.conversationWith.split('-');
|
|
83
|
+
|
|
84
|
+
// Removes the last element of the array if is = to the separator
|
|
85
|
+
if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
|
|
86
|
+
conversationWith_segments.pop();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
83
90
|
this.logger.log('[INFO-CONTENT-COMP] - paramMap.subscribe conversationWith_segments: ', conversationWith_segments);
|
|
84
91
|
|
|
85
92
|
if (this.conversationWith.startsWith("support-group")) {
|
|
@@ -490,31 +490,35 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
490
490
|
// this.logger.log('[CONVS-DETAIL] - setHeaderContent conversationWith', this.conversationWith)
|
|
491
491
|
// this.logger.log('[CONVS-DETAIL] - setHeaderContent conversationsHandlerService', this.conversationsHandlerService)
|
|
492
492
|
// this.logger.log('[CONVS-DETAIL] - setHeaderContent conv_type', this.conv_type)
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
this.
|
|
493
|
+
if (this.conversationWith && this.conversationsHandlerService && this.conv_type === 'active') {
|
|
494
|
+
this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail CALLING')
|
|
495
|
+
this.conversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
|
|
496
|
+
this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail (active)', this.conversationWith, conv)
|
|
497
|
+
this.conversationAvatar = setConversationAvatar(
|
|
498
|
+
conv.conversation_with,
|
|
499
|
+
conv.conversation_with_fullname,
|
|
500
|
+
conv.channel_type
|
|
501
|
+
);
|
|
502
|
+
this.logger.log('[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ', this.conversationAvatar);
|
|
503
|
+
})
|
|
504
|
+
}
|
|
505
|
+
else { //get conversation from 'conversations' firebase node
|
|
506
|
+
this.archivedConversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
|
|
507
|
+
this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail (archived)', this.conversationWith, conv)
|
|
508
|
+
this.conversationAvatar = setConversationAvatar(
|
|
509
|
+
conv.conversation_with,
|
|
510
|
+
conv.conversation_with_fullname,
|
|
511
|
+
conv.channel_type
|
|
512
|
+
);
|
|
513
|
+
})
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// this.conversationAvatar = setConversationAvatar(
|
|
517
|
+
// this.conversationWith,
|
|
518
|
+
// this.conversationWithFullname,
|
|
519
|
+
// this.channelType
|
|
520
|
+
// );
|
|
521
|
+
// this.logger.log('[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ', this.conversationAvatar);
|
|
518
522
|
}
|
|
519
523
|
|
|
520
524
|
returnSendMessage(e: any) {
|
|
@@ -844,6 +848,10 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
844
848
|
this.logger.log("[CONVS-DETAIL] - loadTagsCanned conversationWith ", conversationWith);
|
|
845
849
|
|
|
846
850
|
const conversationWith_segments = conversationWith.split('-');
|
|
851
|
+
// Removes the last element of the array if is = to the separator
|
|
852
|
+
if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
|
|
853
|
+
conversationWith_segments.pop();
|
|
854
|
+
}
|
|
847
855
|
this.logger.log("[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ", conversationWith_segments);
|
|
848
856
|
let projectId = ""
|
|
849
857
|
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"chatEngine": "firebase",
|
|
3
3
|
"uploadEngine": "firebase",
|
|
4
4
|
"pushEngine": "firebase",
|
|
5
|
-
"logLevel": "
|
|
5
|
+
"logLevel": "debug",
|
|
6
6
|
"fileUploadAccept":"*/*",
|
|
7
|
+
"authPersistence": "LOCAL",
|
|
7
8
|
"firebaseConfig": {
|
|
8
9
|
"tenant": "tilechat",
|
|
9
10
|
"apiKey": "AIzaSyCoWXHNvP1-qOllCpTshhC6VjPXeRTK0T4",
|
|
@@ -16,7 +16,7 @@ export abstract class MessagingAuthService {
|
|
|
16
16
|
abstract BSSignOut: BehaviorSubject<any> = new BehaviorSubject<any>(null);
|
|
17
17
|
|
|
18
18
|
// params
|
|
19
|
-
public DEFAULT_PERSISTENCE: string = '
|
|
19
|
+
public DEFAULT_PERSISTENCE: string = 'NONE';
|
|
20
20
|
public DEFAULT_URL: string = 'https://api.tiledesk.com/v2/auth/';
|
|
21
21
|
|
|
22
22
|
private persistence;
|
|
@@ -189,7 +189,8 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
|
|
|
189
189
|
firebaseMessages.on('value', (childSnapshot) => {
|
|
190
190
|
const childData: ConversationModel = childSnapshot.val();
|
|
191
191
|
this.logger.log('[FIREBASEArchivedConversationsHandlerSERVICE] childData *****', childData)
|
|
192
|
-
if (childSnapshot && childSnapshot.key && childData.uid) {
|
|
192
|
+
// if (childSnapshot && childSnapshot.key && childData.uid) {
|
|
193
|
+
if (childSnapshot && childSnapshot.key) {
|
|
193
194
|
childData.uid = childSnapshot.key;
|
|
194
195
|
const conversation = this.completeConversation(childData);
|
|
195
196
|
if (conversation) {
|
|
@@ -392,7 +393,7 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
|
|
|
392
393
|
// conv.last_message_text = htmlEntities(conv.last_message_text)
|
|
393
394
|
conv.conversation_with_fullname = conversation_with_fullname;
|
|
394
395
|
conv.status = this.setStatusConversation(conv.sender, conv.uid);
|
|
395
|
-
conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
|
|
396
|
+
// conv.time_last_message = this.getTimeLastMessage(conv.timestamp); // evaluate if is used
|
|
396
397
|
conv.avatar = avatarPlaceholder(conversation_with_fullname);
|
|
397
398
|
conv.color = getColorBck(conversation_with_fullname);
|
|
398
399
|
conv.archived = true;
|
|
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
|
|
2
2
|
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
|
|
3
3
|
import { BehaviorSubject } from 'rxjs';
|
|
4
4
|
import { ActivatedRoute } from '@angular/router';
|
|
5
|
-
|
|
5
|
+
import { ConnectionService } from 'ng-connection-service';
|
|
6
6
|
// firebase
|
|
7
7
|
// import * as firebase from 'firebase/app';
|
|
8
8
|
import firebase from "firebase/app";
|
|
@@ -30,6 +30,9 @@ import { LoggerInstance } from '../logger/loggerInstance';
|
|
|
30
30
|
import { LoggerService } from '../abstract/logger.service';
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
import { Observable, Observer, fromEvent, merge } from 'rxjs';
|
|
34
|
+
import { map } from 'rxjs/operators'
|
|
35
|
+
import { Network } from '@ionic-native/network/ngx';
|
|
33
36
|
// @Injectable({ providedIn: 'root' })
|
|
34
37
|
@Injectable()
|
|
35
38
|
export class FirebaseAuthService extends MessagingAuthService {
|
|
@@ -53,9 +56,15 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
53
56
|
// private imageRepo: ImageRepoService = new FirebaseImageRepoService();
|
|
54
57
|
|
|
55
58
|
private firebaseToken: string;
|
|
56
|
-
private logger:LoggerService = LoggerInstance.getInstance()
|
|
59
|
+
private logger: LoggerService = LoggerInstance.getInstance()
|
|
60
|
+
|
|
61
|
+
status = 'ONLINE';
|
|
62
|
+
isConnected = true;
|
|
63
|
+
|
|
57
64
|
constructor(
|
|
58
|
-
public http: HttpClient
|
|
65
|
+
public http: HttpClient,
|
|
66
|
+
private network: Network,
|
|
67
|
+
private connectionService: ConnectionService
|
|
59
68
|
) {
|
|
60
69
|
super();
|
|
61
70
|
}
|
|
@@ -64,7 +73,7 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
64
73
|
*
|
|
65
74
|
*/
|
|
66
75
|
initialize() {
|
|
67
|
-
|
|
76
|
+
|
|
68
77
|
this.SERVER_BASE_URL = this.getBaseUrl();
|
|
69
78
|
this.URL_TILEDESK_CREATE_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'chat21/firebase/auth/createCustomToken';
|
|
70
79
|
this.logger.info('[FIREBASEAuthSERVICE] - initialize URL_TILEDESK_CREATE_CUSTOM_TOKEN ', this.URL_TILEDESK_CREATE_CUSTOM_TOKEN)
|
|
@@ -72,9 +81,66 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
72
81
|
// this.URL_TILEDESK_SIGNIN_ANONYMOUSLY = this.SERVER_BASE_URL + 'auth/signinAnonymously'
|
|
73
82
|
// this.URL_TILEDESK_SIGNIN_WITH_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'auth/signinWithCustomToken';
|
|
74
83
|
// this.checkIsAuth();
|
|
84
|
+
|
|
85
|
+
// this.createOnline$().subscribe((isOnline) =>{
|
|
86
|
+
// console.log('FIREBASEAuthSERVICE] isOnline ', isOnline);
|
|
87
|
+
// if (isOnline === true ) {
|
|
88
|
+
// this.onAuthStateChanged();
|
|
89
|
+
// }
|
|
90
|
+
// })
|
|
91
|
+
this.checkInternetConnection()
|
|
92
|
+
|
|
75
93
|
this.onAuthStateChanged();
|
|
76
94
|
}
|
|
77
95
|
|
|
96
|
+
checkInternetConnection () {
|
|
97
|
+
this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection');
|
|
98
|
+
// let connectSubscription = this.network.onConnect().subscribe(() => {
|
|
99
|
+
// this.logger.log('[FIREBASEAuthSERVICE] - network connected!');
|
|
100
|
+
// // We just got a connection but we need to wait briefly
|
|
101
|
+
// // before we determine the connection type. Might need to wait.
|
|
102
|
+
// // prior to doing any api requests as well.
|
|
103
|
+
// setTimeout(() => {
|
|
104
|
+
// if (this.network.type === 'wifi') {
|
|
105
|
+
// this.logger.log('[FIREBASEAuthSERVICE] - we got a wifi connection, woohoo!');
|
|
106
|
+
// }
|
|
107
|
+
// }, 3000);
|
|
108
|
+
// });
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
this.connectionService.monitor().subscribe(isConnected => {
|
|
112
|
+
this.isConnected = isConnected;
|
|
113
|
+
this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection isConnected', isConnected);
|
|
114
|
+
if (this.isConnected) {
|
|
115
|
+
this.status = "ONLINE";
|
|
116
|
+
|
|
117
|
+
// this.onAuthStateChanged();
|
|
118
|
+
firebase.auth().onAuthStateChanged(user => {
|
|
119
|
+
this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.status = "OFFLINE";
|
|
124
|
+
// this.onAuthStateChanged();
|
|
125
|
+
firebase.auth().onAuthStateChanged(user => {
|
|
126
|
+
this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// createOnline$() {
|
|
135
|
+
// return merge<boolean>(
|
|
136
|
+
// fromEvent(window, 'offline').pipe(map(() => false)),
|
|
137
|
+
// fromEvent(window, 'online').pipe(map(() => true)),
|
|
138
|
+
// new Observable((sub: Observer<boolean>) => {
|
|
139
|
+
// sub.next(navigator.onLine);
|
|
140
|
+
// sub.complete();
|
|
141
|
+
// }));
|
|
142
|
+
// }
|
|
143
|
+
|
|
78
144
|
/**
|
|
79
145
|
* checkIsAuth
|
|
80
146
|
*/
|
|
@@ -113,12 +179,12 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
113
179
|
onAuthStateChanged() {
|
|
114
180
|
const that = this;
|
|
115
181
|
firebase.auth().onAuthStateChanged(user => {
|
|
116
|
-
this.logger.
|
|
182
|
+
this.logger.log('[FIREBASEAuthSERVICE] onAuthStateChanged', user)
|
|
117
183
|
if (!user) {
|
|
118
|
-
this.logger.
|
|
184
|
+
this.logger.log('[FIREBASEAuthSERVICE] 1 - PASSO OFFLINE AL CHAT MANAGER')
|
|
119
185
|
that.BSAuthStateChanged.next('offline');
|
|
120
186
|
} else {
|
|
121
|
-
this.logger.
|
|
187
|
+
this.logger.log('[FIREBASEAuthSERVICE] 2 - PASSO ONLINE AL CHAT MANAGER')
|
|
122
188
|
that.BSAuthStateChanged.next('online');
|
|
123
189
|
}
|
|
124
190
|
});
|
|
@@ -131,6 +197,7 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
131
197
|
signInFirebaseWithCustomToken(token: string): Promise<any> {
|
|
132
198
|
const that = this;
|
|
133
199
|
let firebasePersistence;
|
|
200
|
+
console.log('FB-AUTH firebasePersistence', this.getPersistence())
|
|
134
201
|
switch (this.getPersistence()) {
|
|
135
202
|
case 'SESSION': {
|
|
136
203
|
firebasePersistence = firebase.auth.Auth.Persistence.SESSION;
|
|
@@ -149,13 +216,13 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
149
216
|
break;
|
|
150
217
|
}
|
|
151
218
|
}
|
|
152
|
-
return firebase.auth().setPersistence(firebasePersistence).then(
|
|
153
|
-
return firebase.auth().signInWithCustomToken(token).then(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
219
|
+
return firebase.auth().setPersistence(firebasePersistence).then(async () => {
|
|
220
|
+
return firebase.auth().signInWithCustomToken(token).then(async () => {
|
|
221
|
+
// that.firebaseSignInWithCustomToken.next(response);
|
|
222
|
+
}).catch((error) => {
|
|
223
|
+
that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
|
|
224
|
+
// that.firebaseSignInWithCustomToken.next(null);
|
|
225
|
+
});
|
|
159
226
|
}).catch((error) => {
|
|
160
227
|
that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
|
|
161
228
|
});
|
|
@@ -200,7 +267,7 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
200
267
|
private signOut() {
|
|
201
268
|
const that = this;
|
|
202
269
|
firebase.auth().signOut().then(() => {
|
|
203
|
-
that.logger.
|
|
270
|
+
that.logger.log('[FIREBASEAuthSERVICE] signOut firebase-sign-out');
|
|
204
271
|
// cancello token
|
|
205
272
|
// this.appStorage.removeItem('tiledeskToken');
|
|
206
273
|
//localStorage.removeItem('firebaseToken');
|
|
@@ -244,12 +311,12 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
244
311
|
//localStorage.setItem('firebaseToken', that.firebaseToken);
|
|
245
312
|
that.signInFirebaseWithCustomToken(data)
|
|
246
313
|
}, error => {
|
|
247
|
-
that.logger.error('[FIREBASEAuthSERVICE] createFirebaseCustomToken ERR ', error)
|
|
314
|
+
that.logger.error('[FIREBASEAuthSERVICE] createFirebaseCustomToken ERR ', error)
|
|
248
315
|
});
|
|
249
316
|
}
|
|
250
317
|
|
|
251
318
|
logout() {
|
|
252
|
-
this.logger.
|
|
319
|
+
this.logger.log('[FIREBASEAuthSERVICE] logout');
|
|
253
320
|
// cancello token firebase dal local storage e da firebase
|
|
254
321
|
// dovrebbe scattare l'evento authchangeStat
|
|
255
322
|
this.signOut();
|
|
@@ -279,9 +279,11 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
279
279
|
const firebaseMessages = firebase.database().ref(urlNodeFirebase);
|
|
280
280
|
firebaseMessages.on('value', (childSnapshot) => {
|
|
281
281
|
const childData: ConversationModel = childSnapshot.val();
|
|
282
|
-
this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot *****', childSnapshot.val())
|
|
283
|
-
|
|
284
|
-
|
|
282
|
+
this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot.val() *****', childSnapshot.val());
|
|
283
|
+
this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot *****', childSnapshot)
|
|
284
|
+
// && childData.uid
|
|
285
|
+
if (childSnapshot && childSnapshot.key) {
|
|
286
|
+
// if (childData) {
|
|
285
287
|
childData.uid = childSnapshot.key;
|
|
286
288
|
const conversation = this.completeConversation(childData);
|
|
287
289
|
if (conversation) {
|
|
@@ -485,7 +487,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
485
487
|
conv.conversation_with = conversation_with;
|
|
486
488
|
conv.conversation_with_fullname = conversation_with_fullname;
|
|
487
489
|
conv.status = this.setStatusConversation(conv.sender, conv.uid);
|
|
488
|
-
conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
|
|
490
|
+
// conv.time_last_message = this.getTimeLastMessage(conv.timestamp); // evaluate if is used
|
|
489
491
|
conv.avatar = avatarPlaceholder(conversation_with_fullname);
|
|
490
492
|
conv.color = getColorBck(conversation_with_fullname);
|
|
491
493
|
//conv.image = this.imageRepo.getImagePhotoUrl(conversation_with);
|
|
@@ -17,6 +17,7 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
17
17
|
this.storagePrefix = storagePrefix;
|
|
18
18
|
this.projectID = projectID;
|
|
19
19
|
this.persistence = persistence;
|
|
20
|
+
// this.persistence = 'LOCAL';
|
|
20
21
|
this.logger.info('[LocalSessionStorage] - initialize ', this.storagePrefix, this.persistence, this.projectID)
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -30,7 +31,7 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
30
31
|
// prefix = prefix + sv;
|
|
31
32
|
prefix = this.storagePrefix + '_';
|
|
32
33
|
} catch (e) {
|
|
33
|
-
this.logger.error('[LocalSessionStorage] getItem
|
|
34
|
+
this.logger.error('[LocalSessionStorage] getItem - Error :' + e);
|
|
34
35
|
}
|
|
35
36
|
const newKey = prefix + this.projectID + '_' + key;
|
|
36
37
|
return this.getValueForKey(newKey);
|