@chat21/chat21-ionic 3.0.65-rc1 → 3.0.65-rc2
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 +5 -1
- package/deploy_amazon_beta.sh +0 -0
- package/deploy_prod.sh +1 -1
- package/package.json +1 -1
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +5 -3
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +4 -4
- package/src/app/pages/conversations-list/conversations-list.page.ts +4 -0
- package/src/assets/js/chat21client.js +57 -59
- package/src/chat21-core/models/conversation.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +10 -1
- package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +16 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# chat21-ionic ver 3.0
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
### 3.0.65-rc2 - LATEST
|
|
5
|
+
- changed: behaviour of is_new of a conversation (not update 'is_new' conversation property if conv is the selected one or if sender is me)
|
|
6
|
+
|
|
7
|
+
### 3.0.65-rc1 - LATEST
|
|
4
8
|
- added: improves chat performance by caching conversations
|
|
5
9
|
- added: Displays balloon messages with a light orange background for "internal notes" type message
|
|
6
10
|
- added: the html component
|
package/deploy_amazon_beta.sh
CHANGED
|
File without changes
|
package/deploy_prod.sh
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<ion-header no-border class="ion-no-border">
|
|
2
2
|
<ion-toolbar style="height:60px">
|
|
3
|
-
<ion-buttons slot="start" style="height:60px">
|
|
3
|
+
<ion-buttons slot="start" style="height:60px" *ngIf="isMobile">
|
|
4
4
|
<!-- (click)="pushPage('conversations-list')" defaultHref="/conversations-list" -->
|
|
5
|
-
<ion-back-button style="display: block;" text=""
|
|
5
|
+
<ion-back-button style="display: block;" text="" (click)="goBackToConversationList()">
|
|
6
6
|
</ion-back-button>
|
|
7
7
|
</ion-buttons>
|
|
8
8
|
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
<!-- [ngStyle] = "{ 'left': platformName === 'ios' ? '55px' : '' }" -->
|
|
13
13
|
<div *ngIf="conversationAvatar" class="avatar-container" (click)="onOpenCloseInfoConversation()" style="cursor: pointer"
|
|
14
14
|
[ngClass]="{ 'avatar-container-ios': platformName === 'ios' }">
|
|
15
|
-
<app-avatar-profile
|
|
15
|
+
<app-avatar-profile
|
|
16
|
+
[itemAvatar]=conversationAvatar>
|
|
17
|
+
</app-avatar-profile>
|
|
16
18
|
</div>
|
|
17
19
|
<!-- [ngStyle] = "{ 'left': platformName === 'ios' ? '63px' : '' }" -->
|
|
18
20
|
<div *ngIf="isDirect" class="user-presence" [ngClass]="{ 'user-presence-ios': platformName === 'ios' }">
|
|
@@ -327,10 +327,10 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
327
327
|
this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange showButtonToBottom ', this.showButtonToBottom)
|
|
328
328
|
// UPDATE THE CONVERSATION TO 'READ' IF IT IS ME WHO WRITES THE LAST MESSAGE OF THE CONVERSATION
|
|
329
329
|
// AND IF THE POSITION OF THE SCROLL IS AT THE END
|
|
330
|
-
if (!this.showButtonToBottom && conv.is_new) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
330
|
+
// if (!this.showButtonToBottom && conv.is_new) {
|
|
331
|
+
// // ARE AT THE END
|
|
332
|
+
// this.updateConversationBadge()
|
|
333
|
+
// }
|
|
334
334
|
if(conv.uid && conv.uid === this.conversationWith){
|
|
335
335
|
this.conversationAvatar = setConversationAvatar(conv.conversation_with,conv.conversation_with_fullname,conv.channel_type)
|
|
336
336
|
}
|
|
@@ -648,8 +648,10 @@ export class ConversationListPage implements OnInit {
|
|
|
648
648
|
let conversationSelected
|
|
649
649
|
if (conversationType === 'active') {
|
|
650
650
|
conversationSelected = this.conversations.find((item) => item.uid === this.uidConvSelected)
|
|
651
|
+
this.conversationsHandlerService.uidConvSelected = conversationSelected.uid
|
|
651
652
|
} else if (conversationType === 'archived') {
|
|
652
653
|
conversationSelected = this.archivedConversations.find((item) => item.uid === this.uidConvSelected)
|
|
654
|
+
this.archivedConversationsHandlerService.uidConvSelected = conversationSelected.uid
|
|
653
655
|
}
|
|
654
656
|
if (conversationSelected) {
|
|
655
657
|
this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected)
|
|
@@ -664,10 +666,12 @@ export class ConversationListPage implements OnInit {
|
|
|
664
666
|
this.logger.log('onConversationSelected conversation', conversation)
|
|
665
667
|
if (conversation.archived) {
|
|
666
668
|
this.navigateByUrl('archived', conversation.uid)
|
|
669
|
+
this.archivedConversationsHandlerService.uidConvSelected = conversation.uid
|
|
667
670
|
this.logger.log('[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ', conversation.uid,
|
|
668
671
|
)
|
|
669
672
|
} else {
|
|
670
673
|
this.navigateByUrl('active', conversation.uid)
|
|
674
|
+
this.conversationsHandlerService.uidConvSelected = conversation.uid
|
|
671
675
|
this.logger.log('[CONVS-LIST-PAGE] onConversationSelected active conversation.uid ', conversation.uid)
|
|
672
676
|
}
|
|
673
677
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Chat21Client
|
|
3
3
|
|
|
4
|
-
v0.1.
|
|
4
|
+
v0.1.11
|
|
5
5
|
|
|
6
6
|
@Author Andrea Sponziello
|
|
7
7
|
(c) Tiledesk 2020
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
//
|
|
10
|
+
//let mqtt = require('mqtt');
|
|
11
|
+
//let axios = require('axios');
|
|
12
12
|
|
|
13
13
|
const _CLIENTADDED = "/clientadded"
|
|
14
14
|
const _CLIENTUPDATED = "/clientupdated"
|
|
@@ -141,7 +141,7 @@ class Chat21Client {
|
|
|
141
141
|
const payload = JSON.stringify(outgoing_message)
|
|
142
142
|
this.client.publish(dest_topic, payload, null, (err) => {
|
|
143
143
|
callback(err, outgoing_message)
|
|
144
|
-
})
|
|
144
|
+
});
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
updateMessageStatus(messageId, conversWith, status, callback) {
|
|
@@ -236,10 +236,6 @@ class Chat21Client {
|
|
|
236
236
|
group_members: members
|
|
237
237
|
},
|
|
238
238
|
method: 'POST'
|
|
239
|
-
// url: options.url,
|
|
240
|
-
// headers: options.headers,
|
|
241
|
-
// json: options.json,
|
|
242
|
-
// method: options.method
|
|
243
239
|
}
|
|
244
240
|
Chat21Client.myrequest(options, (err, response, json) => {
|
|
245
241
|
if (err) {
|
|
@@ -249,23 +245,6 @@ class Chat21Client {
|
|
|
249
245
|
callback(null, json);
|
|
250
246
|
}
|
|
251
247
|
}, this.log);
|
|
252
|
-
// var xmlhttp = new XMLHttpRequest();
|
|
253
|
-
// xmlhttp.open("POST", URL, true);
|
|
254
|
-
// xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
255
|
-
// xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
256
|
-
// xmlhttp.onreadystatechange = function() {
|
|
257
|
-
// if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
258
|
-
// try {
|
|
259
|
-
// const json = JSON.parse(xmlhttp.responseText)
|
|
260
|
-
// callback(null, json.result)
|
|
261
|
-
// }
|
|
262
|
-
// catch (err) {
|
|
263
|
-
// console.log("parsing json ERROR", err)
|
|
264
|
-
// callback(err, null)
|
|
265
|
-
// }
|
|
266
|
-
// }
|
|
267
|
-
// };
|
|
268
|
-
// xmlhttp.send(JSON.stringify(data));
|
|
269
248
|
}
|
|
270
249
|
|
|
271
250
|
groupData(group_id, callback) {
|
|
@@ -590,7 +569,7 @@ class Chat21Client {
|
|
|
590
569
|
}
|
|
591
570
|
// map.forEach((value, key, map) =>)
|
|
592
571
|
this.onConversationUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
593
|
-
callback(JSON.parse(message.toString()),
|
|
572
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
594
573
|
});
|
|
595
574
|
}
|
|
596
575
|
}
|
|
@@ -602,7 +581,7 @@ class Chat21Client {
|
|
|
602
581
|
console.log("conversation deleted! /conversations/, topic:", topic, message.toString() );
|
|
603
582
|
}
|
|
604
583
|
this.onConversationDeletedCallbacks.forEach((callback, handler, map) => {
|
|
605
|
-
callback(JSON.parse(message.toString()),
|
|
584
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
606
585
|
});
|
|
607
586
|
}
|
|
608
587
|
}
|
|
@@ -611,7 +590,7 @@ class Chat21Client {
|
|
|
611
590
|
if (topic.includes("/archived_conversations/") && topic.endsWith(_CLIENTADDED)) {
|
|
612
591
|
// map.forEach((value, key, map) =>)
|
|
613
592
|
this.onArchivedConversationAddedCallbacks.forEach((callback, handler, map) => {
|
|
614
|
-
callback(JSON.parse(message.toString()),
|
|
593
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
615
594
|
});
|
|
616
595
|
}
|
|
617
596
|
}
|
|
@@ -620,7 +599,7 @@ class Chat21Client {
|
|
|
620
599
|
if (topic.includes("/archived_conversations/") && topic.endsWith(_CLIENTDELETED)) {
|
|
621
600
|
// map.forEach((value, key, map) =>)
|
|
622
601
|
this.onArchivedConversationDeletedCallbacks.forEach((callback, handler, map) => {
|
|
623
|
-
callback(JSON.parse(message.toString()),
|
|
602
|
+
callback(JSON.parse(message.toString()), _topic)
|
|
624
603
|
});
|
|
625
604
|
}
|
|
626
605
|
}
|
|
@@ -720,20 +699,20 @@ class Chat21Client {
|
|
|
720
699
|
}
|
|
721
700
|
|
|
722
701
|
parseTopic(topic) {
|
|
723
|
-
var topic_parts = topic.split("/")
|
|
702
|
+
var topic_parts = topic.split("/");
|
|
724
703
|
// /apps/tilechat/users/(ME)/messages/RECIPIENT_ID/ACTION
|
|
725
704
|
if (topic_parts.length >= 7) {
|
|
726
|
-
const app_id = topic_parts[1]
|
|
727
|
-
const sender_id = topic_parts[3]
|
|
728
|
-
const recipient_id = topic_parts[5]
|
|
729
|
-
const convers_with = recipient_id
|
|
730
|
-
const me = sender_id
|
|
705
|
+
const app_id = topic_parts[1];
|
|
706
|
+
const sender_id = topic_parts[3];
|
|
707
|
+
const recipient_id = topic_parts[5];
|
|
708
|
+
const convers_with = recipient_id;
|
|
709
|
+
const me = sender_id;
|
|
731
710
|
const parsed = {
|
|
732
711
|
"conversWith": convers_with
|
|
733
712
|
}
|
|
734
|
-
return parsed
|
|
713
|
+
return parsed;
|
|
735
714
|
}
|
|
736
|
-
return null
|
|
715
|
+
return null;
|
|
737
716
|
}
|
|
738
717
|
|
|
739
718
|
lastArchivedConversations(callback) {
|
|
@@ -801,27 +780,46 @@ class Chat21Client {
|
|
|
801
780
|
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/${path}/${conversWith}`
|
|
802
781
|
console.log("getting conversation detail:", URL)
|
|
803
782
|
console.log("conversWith:", conversWith)
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
catch (err) {
|
|
819
|
-
console.error("parsing json ERROR", err);
|
|
820
|
-
callback(err, null);
|
|
821
|
-
}
|
|
783
|
+
|
|
784
|
+
let options = {
|
|
785
|
+
url: URL,
|
|
786
|
+
headers: {
|
|
787
|
+
"Authorization": this.jwt
|
|
788
|
+
// "Content-Type": "application/json;charset=UTF-8"
|
|
789
|
+
},
|
|
790
|
+
method: 'GET'
|
|
791
|
+
}
|
|
792
|
+
Chat21Client.myrequest(options, (err, response, json) => {
|
|
793
|
+
console.log("JSON...", json)
|
|
794
|
+
if (json && json.result && Array.isArray(json.result) && json.result.length ==1) {
|
|
795
|
+
callback(null, json.result[0]);
|
|
822
796
|
}
|
|
823
|
-
|
|
824
|
-
|
|
797
|
+
else {
|
|
798
|
+
callback(null, null);
|
|
799
|
+
}
|
|
800
|
+
}, this.log);
|
|
801
|
+
|
|
802
|
+
// var xmlhttp = new XMLHttpRequest();
|
|
803
|
+
// xmlhttp.open("GET", URL, true);
|
|
804
|
+
// xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
805
|
+
// xmlhttp.onreadystatechange = function() {
|
|
806
|
+
// if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
807
|
+
// try {
|
|
808
|
+
// const json = JSON.parse(xmlhttp.responseText);
|
|
809
|
+
// if (json && json.result && Array.isArray(json.result) && json.result.length ==1) {
|
|
810
|
+
// callback(null, json.result[0]);
|
|
811
|
+
// }
|
|
812
|
+
// else {
|
|
813
|
+
// callback({"message": "Incorrect conversation result."}, null);
|
|
814
|
+
// }
|
|
815
|
+
// }
|
|
816
|
+
// catch (err) {
|
|
817
|
+
// console.error("parsing json ERROR", err);
|
|
818
|
+
// callback(err, null);
|
|
819
|
+
// }
|
|
820
|
+
// }
|
|
821
|
+
// };
|
|
822
|
+
// xmlhttp.send(null);
|
|
825
823
|
}
|
|
826
824
|
|
|
827
825
|
lastMessages(convers_with, callback) {
|
|
@@ -1033,8 +1031,8 @@ class Chat21Client {
|
|
|
1033
1031
|
|
|
1034
1032
|
function isBrowser() {
|
|
1035
1033
|
return true;
|
|
1036
|
-
//
|
|
1034
|
+
//return false;
|
|
1037
1035
|
}
|
|
1038
1036
|
|
|
1039
1037
|
export { Chat21Client }; // Browser
|
|
1040
|
-
//
|
|
1038
|
+
//module.exports = { Chat21Client };
|
|
@@ -17,7 +17,7 @@ export class ConversationModel {
|
|
|
17
17
|
public status: string,
|
|
18
18
|
public timestamp: number,
|
|
19
19
|
public time_last_message: string,
|
|
20
|
-
public selected: boolean,
|
|
20
|
+
// public selected: boolean,
|
|
21
21
|
public color: string,
|
|
22
22
|
public avatar: string,
|
|
23
23
|
public archived: boolean,
|
|
@@ -505,7 +505,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
505
505
|
* @param conv
|
|
506
506
|
*/
|
|
507
507
|
private completeConversation(conv): ConversationModel {
|
|
508
|
-
conv.selected = false;
|
|
508
|
+
// conv.selected = false;
|
|
509
509
|
if (!conv.sender_fullname || conv.sender_fullname === 'undefined' || conv.sender_fullname.trim() === '') {
|
|
510
510
|
conv.sender_fullname = conv.sender;
|
|
511
511
|
}
|
|
@@ -532,6 +532,15 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
532
532
|
this.translateInfoSupportMessages(conv);
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
|
+
/** START: UPDATE CONVERSATIONS is_new IF conv is selected or sender is me */
|
|
536
|
+
if(conv.uid === this.uidConvSelected){
|
|
537
|
+
conv.is_new = false
|
|
538
|
+
}
|
|
539
|
+
if(conv.sender === this.loggedUserId){
|
|
540
|
+
conv.is_new = false
|
|
541
|
+
}
|
|
542
|
+
/** END: UPDATE CONVERSATIONS is_new IF conv is selected or sender is me */
|
|
543
|
+
|
|
535
544
|
// Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly in the convesations list
|
|
536
545
|
// conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
|
|
537
546
|
conv.conversation_with = conversation_with;
|
|
@@ -59,18 +59,15 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
|
|
|
59
59
|
// 1 search local array
|
|
60
60
|
// 2 search remote
|
|
61
61
|
// callback
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
const conversation = this.conversations.find(conv => conv.conversation_with === conversationWith);
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
if (conversation) {
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
callback(conversation);
|
|
68
68
|
} else {
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
this.chat21Service.chatClient.conversationDetail(conversationWith, (err, conversation) => {
|
|
71
|
-
console.log("--REMOTE CONV IS:" + conversation);
|
|
72
|
-
console.log("--REMOTE CONV IS OBJ:", conversation);
|
|
73
|
-
console.log("--REMOTE ERR IS:" + err);
|
|
74
71
|
|
|
75
72
|
if (conversation) {
|
|
76
73
|
if (callback) {
|
|
@@ -147,7 +144,8 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
|
|
|
147
144
|
// ---------------------------------------------------------------------------------
|
|
148
145
|
// New connect - renamed subscribeToConversation
|
|
149
146
|
//----------------------------------------------------------------------------------
|
|
150
|
-
subscribeToConversations(loaded) {
|
|
147
|
+
subscribeToConversations(lastTimestamp, loaded) {
|
|
148
|
+
// lastTimestamp temporarily ignored
|
|
151
149
|
this.logger.debug('[MQTTConversationsHandler] connecting MQTT conversations handler');
|
|
152
150
|
const handlerConversationAdded = this.chat21Service.chatClient.onConversationAdded( (conv) => {
|
|
153
151
|
this.logger.log("onConversationAdded:", conv);
|
|
@@ -385,8 +383,7 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
|
|
|
385
383
|
}
|
|
386
384
|
|
|
387
385
|
private completeConversation(conv): ConversationModel {
|
|
388
|
-
|
|
389
|
-
conv.selected = false;
|
|
386
|
+
// conv.selected = false;
|
|
390
387
|
if (!conv.sender_fullname || conv.sender_fullname === 'undefined' || conv.sender_fullname.trim() === '') {
|
|
391
388
|
conv.sender_fullname = conv.sender;
|
|
392
389
|
}
|
|
@@ -414,13 +411,19 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
|
|
|
414
411
|
conv.last_message_text = conv.text; // building conv with a message
|
|
415
412
|
}
|
|
416
413
|
conv.uid = conv.conversation_with;
|
|
414
|
+
console.log("uidConvSelected is", this.uidConvSelected);
|
|
415
|
+
if (conv.uid === this.uidConvSelected) {
|
|
416
|
+
this.logger.debug("For selected conversation is_new = false");
|
|
417
|
+
conv.is_new = false;
|
|
418
|
+
}
|
|
419
|
+
if (conv.sender === this.loggedUserId) {
|
|
420
|
+
this.logger.debug("is_new always false if sender it's me")
|
|
421
|
+
conv.is_new = false;
|
|
422
|
+
}
|
|
417
423
|
return conv;
|
|
418
424
|
}
|
|
419
425
|
|
|
420
426
|
private isGroup(conv: ConversationModel) {
|
|
421
|
-
console.log("CONVIS: " + JSON.stringify(conv));
|
|
422
|
-
console.log("CONVIS OBJ:", conv);
|
|
423
|
-
|
|
424
427
|
if (conv.recipient.startsWith('group-') || conv.recipient.startsWith('support-group')) {
|
|
425
428
|
return true;
|
|
426
429
|
};
|