@chat21/chat21-ionic 3.0.55-RC18 → 3.0.55-RC20
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 +8 -1
- package/package.json +1 -1
- package/src/app/app.component.ts +32 -32
- package/src/app/pages/conversations-list/conversations-list.page.ts +41 -12
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +23 -21
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +29 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
# chat21-ionic ver 3.0
|
|
2
2
|
|
|
3
|
+
### 3.0.55-RC20
|
|
4
|
+
- Improve the method that solves the bug: if the chat is open on more than one tab, the previous ones disconnect
|
|
5
|
+
- Displays the message "sent an image" when the sender sends an image
|
|
6
|
+
- Removes the "setTimeout" set on the onStorageChanged event
|
|
7
|
+
|
|
8
|
+
### 3.0.55-RC19
|
|
9
|
+
- Fixes the bug: opening the "conversations info" side panel for support type conversations causes the chat to log out
|
|
10
|
+
|
|
3
11
|
### 3.0.55-RC18
|
|
4
|
-
- Fixes the bug: check if exist the user before to remove the notification instance to avoid the error "Permission denied"
|
|
5
12
|
- Fixes the bug: if the chat is open on more than one tab, the previous ones logging out
|
|
6
13
|
|
|
7
14
|
### 3.0.55-RC16
|
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -692,7 +692,7 @@ export class AppComponent implements OnInit {
|
|
|
692
692
|
that.removePresenceAndLogout();
|
|
693
693
|
} else {
|
|
694
694
|
that.removePresenceAndLogout();
|
|
695
|
-
that.presentToast();
|
|
695
|
+
// that.presentToast();
|
|
696
696
|
}
|
|
697
697
|
})
|
|
698
698
|
}
|
|
@@ -858,48 +858,48 @@ export class AppComponent implements OnInit {
|
|
|
858
858
|
onStorageChanged(event: any) {
|
|
859
859
|
// console.log('[APP-COMP] - onStorageChanged event', event)
|
|
860
860
|
// console.log('[APP-COMP] - onStorageChanged tiledeskToken', this.appStorageService.getItem('tiledeskToken'))
|
|
861
|
-
const storage = event.storageArea;
|
|
861
|
+
// const storage = event.storageArea;
|
|
862
862
|
// console.log('[APP-COMP] - onStorageChanged event storage', storage)
|
|
863
863
|
|
|
864
|
-
setTimeout(() => {
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
864
|
+
// setTimeout(() => {
|
|
865
|
+
// if (storage && storage['chat_sv5__tiledeskToken'] === undefined) {
|
|
866
|
+
// this.logger.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken', storage['chat_sv5__tiledeskToken'])
|
|
867
|
+
// this.tiledeskAuthService.logOut()
|
|
868
|
+
// this.messagingAuthService.logout();
|
|
869
|
+
// // this.events.publish('profileInfoButtonClick:logout', true);
|
|
870
|
+
// this.conversationsHandlerService.conversations = [];
|
|
871
|
+
// } else if (storage && storage['chat_sv5__tiledeskToken']) {
|
|
872
872
|
|
|
873
|
-
|
|
874
|
-
|
|
873
|
+
// this.logger.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken * IS DEFINED *')
|
|
874
|
+
// const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
875
875
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
876
|
+
// if (!currentUser) {
|
|
877
|
+
// window.location.reload();
|
|
878
|
+
// }
|
|
879
879
|
|
|
880
|
-
|
|
881
|
-
}, 1000);
|
|
880
|
+
// }
|
|
881
|
+
// }, 1000);
|
|
882
882
|
|
|
883
883
|
// else {
|
|
884
884
|
// console.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken', storage['chat_sv5__tiledeskToken'])
|
|
885
885
|
// }
|
|
886
886
|
|
|
887
|
+
// setTimeout(() => {
|
|
888
|
+
if (this.appStorageService.getItem('tiledeskToken') === null) {
|
|
889
|
+
this.tiledeskAuthService.logOut()
|
|
890
|
+
this.messagingAuthService.logout();
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
887
893
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
//
|
|
897
|
-
// } else {
|
|
898
|
-
// this.initializeApp()
|
|
899
|
-
// }
|
|
900
|
-
// }, 1000);
|
|
901
|
-
|
|
902
|
-
// }
|
|
894
|
+
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
895
|
+
if (currentUser) {
|
|
896
|
+
console.log('[APP-COMP] - onStorageChanged currentUser', currentUser)
|
|
897
|
+
} else {
|
|
898
|
+
// this.initializeApp();
|
|
899
|
+
window.location.reload();
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
// }, 1000);
|
|
903
903
|
}
|
|
904
904
|
|
|
905
905
|
}
|
|
@@ -60,7 +60,7 @@ export class ConversationListPage implements OnInit {
|
|
|
60
60
|
|
|
61
61
|
public conversationType = 'active'
|
|
62
62
|
headerTitle: string;
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
|
|
65
65
|
constructor(
|
|
66
66
|
private router: Router,
|
|
@@ -423,13 +423,15 @@ export class ConversationListPage implements OnInit {
|
|
|
423
423
|
this.logger.log('[CONVS-LIST-PAGE] tenant:: ' + this.tenant);
|
|
424
424
|
if (this.route.component['name'] !== "ConversationListPage") {
|
|
425
425
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
426
|
+
if (this.route && this.route.snapshot && this.route.snapshot.firstChild) {
|
|
427
|
+
const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
|
|
428
|
+
this.logger.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv);
|
|
429
|
+
if (IDConv) {
|
|
430
|
+
this.setUidConvSelected(IDConv);
|
|
431
|
+
} else {
|
|
431
432
|
|
|
432
|
-
|
|
433
|
+
this.logger.log('[CONVS-LIST-PAGE] conversationWith 2 (else): ', IDConv);
|
|
434
|
+
}
|
|
433
435
|
}
|
|
434
436
|
}
|
|
435
437
|
}
|
|
@@ -490,7 +492,7 @@ export class ConversationListPage implements OnInit {
|
|
|
490
492
|
}
|
|
491
493
|
|
|
492
494
|
onConversationLoaded(conversation: ConversationModel) {
|
|
493
|
-
|
|
495
|
+
this.logger.log('[CONVS-LIST-PAGE] onConversationLoaded ', conversation)
|
|
494
496
|
const keys = ['YOU', 'SENT_AN_IMAGE', 'SENT_AN_ATTACHMENT'];
|
|
495
497
|
const translationMap = this.translateService.translateLanguage(keys);
|
|
496
498
|
// Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly in the convesations list
|
|
@@ -515,14 +517,41 @@ export class ConversationListPage implements OnInit {
|
|
|
515
517
|
conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_IMAGE;
|
|
516
518
|
|
|
517
519
|
} else if (conversation.type === "file") {
|
|
518
|
-
this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
|
|
520
|
+
// this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
|
|
519
521
|
const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
|
|
520
522
|
conversation.last_message_text = translationMap.get('YOU') + ': ' + SENT_AN_ATTACHMENT;
|
|
521
523
|
}
|
|
522
|
-
}
|
|
524
|
+
} else {
|
|
525
|
+
if (conversation.type === "image") {
|
|
526
|
+
|
|
527
|
+
// this.logger.log('[CONVS-LIST-PAGE] HAS SENT AN IMAGE');
|
|
528
|
+
// this.logger.log("[CONVS-LIST-PAGE] translationMap.get('YOU')")
|
|
529
|
+
const SENT_AN_IMAGE = conversation['last_message_text'] = translationMap.get('SENT_AN_IMAGE')
|
|
530
|
+
|
|
531
|
+
conversation.last_message_text = SENT_AN_IMAGE;
|
|
532
|
+
|
|
533
|
+
}
|
|
534
|
+
// else if (conversation.type !== "text" && conversation.type !== "image") {
|
|
535
|
+
// // this.logger.log('[CONVS-LIST-PAGE] HAS SENT FILE')
|
|
536
|
+
// const SENT_AN_ATTACHMENT = conversation['last_message_text'] = translationMap.get('SENT_AN_ATTACHMENT')
|
|
537
|
+
// conversation.last_message_text = SENT_AN_ATTACHMENT;
|
|
538
|
+
|
|
539
|
+
// }
|
|
540
|
+
}
|
|
523
541
|
}
|
|
524
542
|
}
|
|
525
543
|
|
|
544
|
+
// isMarkdownLink(last_message_text) {
|
|
545
|
+
// this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 1')
|
|
546
|
+
// var regex = /^(^|[\n\r])\s*1\.\s.*\s+1\.\s$/
|
|
547
|
+
// let matchRegex = false
|
|
548
|
+
// if (regex.test(last_message_text)) {
|
|
549
|
+
// this.logger.log('[CONVS-LIST-PAGE] isMarkdownLink 2')
|
|
550
|
+
// matchRegex = true
|
|
551
|
+
// return matchRegex
|
|
552
|
+
// }
|
|
553
|
+
// }
|
|
554
|
+
|
|
526
555
|
|
|
527
556
|
navigateByUrl(converationType: string, uidConvSelected: string) {
|
|
528
557
|
this.logger.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected);
|
|
@@ -652,11 +681,11 @@ export class ConversationListPage implements OnInit {
|
|
|
652
681
|
|
|
653
682
|
}, () => {
|
|
654
683
|
this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *');
|
|
655
|
-
|
|
684
|
+
|
|
656
685
|
});
|
|
657
686
|
}
|
|
658
687
|
|
|
659
|
-
archiveSupportGroupConv(tiledeskToken, project_id,conversationId) {
|
|
688
|
+
archiveSupportGroupConv(tiledeskToken, project_id, conversationId) {
|
|
660
689
|
this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation projectId: ', project_id)
|
|
661
690
|
this.tiledeskService.closeSupportGroup(tiledeskToken, project_id, conversationId).subscribe(res => {
|
|
662
691
|
|
|
@@ -165,33 +165,35 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
165
165
|
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.userId', self.userId);
|
|
166
166
|
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > FCMcurrentToken', self.FCMcurrentToken);
|
|
167
167
|
// this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.tenant', this.tenant);
|
|
168
|
-
|
|
169
|
-
const connectionsRefinstancesId = urlNodeFirebase + '/users/' + self.userId + '/instances/'
|
|
170
|
-
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
|
|
171
|
-
let connectionsRefURL = '';
|
|
172
|
-
if (connectionsRefinstancesId) {
|
|
173
|
-
connectionsRefURL = connectionsRefinstancesId + self.FCMcurrentToken;
|
|
174
|
-
const connectionsRef = firebase.database().ref().child(connectionsRefURL);
|
|
175
|
-
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef ', connectionsRef);
|
|
176
|
-
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef url ', connectionsRefURL);
|
|
177
|
-
connectionsRef.off()
|
|
178
|
-
connectionsRef.remove()
|
|
179
|
-
.then(() => {
|
|
180
|
-
self.logger.log("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > Remove succeeded.")
|
|
181
|
-
callback('success')
|
|
182
|
-
}).catch((error) => {
|
|
183
|
-
self.logger.error("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance Remove failed: " + error.message)
|
|
184
|
-
callback('error')
|
|
185
|
-
}).finally(() => {
|
|
186
|
-
self.logger.log('[FIREBASE-NOTIFICATIONS] COMPLETED');
|
|
187
|
-
})
|
|
188
|
-
}
|
|
168
|
+
|
|
189
169
|
|
|
190
170
|
} else {
|
|
191
171
|
self.logger.debug('[FIREBASE-NOTIFICATIONS] - No FB user is signed in. ', user)
|
|
192
172
|
}
|
|
193
173
|
});
|
|
194
174
|
|
|
175
|
+
const urlNodeFirebase = '/apps/' + self.tenant
|
|
176
|
+
const connectionsRefinstancesId = urlNodeFirebase + '/users/' + self.userId + '/instances/'
|
|
177
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
|
|
178
|
+
let connectionsRefURL = '';
|
|
179
|
+
if (connectionsRefinstancesId) {
|
|
180
|
+
connectionsRefURL = connectionsRefinstancesId + self.FCMcurrentToken;
|
|
181
|
+
const connectionsRef = firebase.database().ref().child(connectionsRefURL);
|
|
182
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef ', connectionsRef);
|
|
183
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef url ', connectionsRefURL);
|
|
184
|
+
connectionsRef.off()
|
|
185
|
+
connectionsRef.remove()
|
|
186
|
+
.then(() => {
|
|
187
|
+
self.logger.log("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > Remove succeeded.")
|
|
188
|
+
callback('success')
|
|
189
|
+
}).catch((error) => {
|
|
190
|
+
self.logger.error("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance Remove failed: " + error.message)
|
|
191
|
+
callback('error')
|
|
192
|
+
}).finally(() => {
|
|
193
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] COMPLETED');
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
|
|
195
197
|
|
|
196
198
|
}
|
|
197
199
|
|
|
@@ -22,9 +22,9 @@ export class TiledeskAuthService {
|
|
|
22
22
|
private tiledeskToken: string;
|
|
23
23
|
private currentUser: UserModel;
|
|
24
24
|
private logger: LoggerService = LoggerInstance.getInstance()
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
constructor(public http: HttpClient,
|
|
27
|
-
|
|
27
|
+
public appStorage: AppStorageService) { }
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
initialize(serverBaseUrl: string) {
|
|
@@ -57,7 +57,8 @@ export class TiledeskAuthService {
|
|
|
57
57
|
if (data['success'] && data['token']) {
|
|
58
58
|
that.tiledeskToken = data['token'];
|
|
59
59
|
that.createCompleteUser(data['user']);
|
|
60
|
-
that.appStorage.setItem('tiledeskToken', that.tiledeskToken);
|
|
60
|
+
// that.appStorage.setItem('tiledeskToken', that.tiledeskToken);
|
|
61
|
+
this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
|
|
61
62
|
resolve(that.tiledeskToken)
|
|
62
63
|
}
|
|
63
64
|
}, (error) => {
|
|
@@ -86,7 +87,8 @@ export class TiledeskAuthService {
|
|
|
86
87
|
if (data['success'] && data['token']) {
|
|
87
88
|
that.tiledeskToken = data['token'];
|
|
88
89
|
that.createCompleteUser(data['user']);
|
|
89
|
-
that.appStorage.setItem('tiledeskToken', that.tiledeskToken);
|
|
90
|
+
// that.appStorage.setItem('tiledeskToken', that.tiledeskToken);
|
|
91
|
+
this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
|
|
90
92
|
resolve(that.tiledeskToken)
|
|
91
93
|
}
|
|
92
94
|
}, (error) => {
|
|
@@ -111,7 +113,9 @@ export class TiledeskAuthService {
|
|
|
111
113
|
if (data['success'] && data['token']) {
|
|
112
114
|
that.tiledeskToken = data['token'];
|
|
113
115
|
that.createCompleteUser(data['user']);
|
|
114
|
-
|
|
116
|
+
|
|
117
|
+
// that.appStorage.setItem('tiledeskToken', that.tiledeskToken); // salvarlo esternamente nell'app.component
|
|
118
|
+
this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
|
|
115
119
|
resolve(this.currentUser)
|
|
116
120
|
}
|
|
117
121
|
}, (error) => {
|
|
@@ -120,7 +124,7 @@ export class TiledeskAuthService {
|
|
|
120
124
|
});
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
logOut(){
|
|
127
|
+
logOut() {
|
|
124
128
|
this.logger.debug('[TILEDESK-AUTH] logOut()')
|
|
125
129
|
this.appStorage.removeItem('tiledeskToken')
|
|
126
130
|
this.appStorage.removeItem('currentUser')
|
|
@@ -150,13 +154,28 @@ export class TiledeskAuthService {
|
|
|
150
154
|
member.fullname = fullname;
|
|
151
155
|
member.avatar = avatar;
|
|
152
156
|
member.color = color;
|
|
153
|
-
this.currentUser = member;
|
|
154
|
-
this.logger.debug('[TILEDESK-AUTH] - createCompleteUser member ', member)
|
|
157
|
+
this.currentUser = member;
|
|
158
|
+
this.logger.debug('[TILEDESK-AUTH] - createCompleteUser member ', member);
|
|
155
159
|
this.appStorage.setItem('currentUser', JSON.stringify(this.currentUser));
|
|
156
160
|
} catch (err) {
|
|
157
|
-
this.logger.error('[TILEDESK-AUTH]- createCompleteUser ERR ', err)
|
|
161
|
+
this.logger.error('[TILEDESK-AUTH]- createCompleteUser ERR ', err)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
private checkAndSetInStorageTiledeskToken(tiledeskToken) {
|
|
167
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken tiledeskToken from request', tiledeskToken)
|
|
168
|
+
const storedTiledeskToken = this.appStorage.getItem('tiledeskToken');
|
|
169
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken storedTiledeskToken ', storedTiledeskToken)
|
|
170
|
+
if (!storedTiledeskToken) {
|
|
171
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken TOKEN DOES NOT EXIST - RUN SET ')
|
|
172
|
+
this.appStorage.setItem('tiledeskToken', tiledeskToken);
|
|
173
|
+
} else if (storedTiledeskToken && storedTiledeskToken !== tiledeskToken) {
|
|
174
|
+
console.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken STORED-TOKEN EXIST BUT IS != FROM TOKEN - RUN SET ')
|
|
175
|
+
this.appStorage.setItem('tiledeskToken', tiledeskToken);
|
|
176
|
+
} else if (storedTiledeskToken && storedTiledeskToken === tiledeskToken){
|
|
177
|
+
this.logger.log('[TILEDESK-AUTH] - checkAndSetInStorageTiledeskToken STORED-TOKEN EXIST AND IS = TO TOKEN ')
|
|
158
178
|
}
|
|
159
|
-
|
|
160
179
|
}
|
|
161
180
|
|
|
162
181
|
|