@chat21/chat21-ionic 3.0.63 → 3.0.64-rc1
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 +7 -1
- package/deploy_prod.sh +5 -5
- package/package.json +6 -1
- package/src/app/app.component.ts +45 -59
- package/src/app/app.module.ts +1 -0
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +2 -2
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +0 -1
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +2 -39
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +18 -6
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +2 -2
- package/src/app/chatlib/conversation-detail/message/html/html.component.html +1 -0
- package/src/app/chatlib/conversation-detail/message/html/html.component.scss +79 -0
- package/src/app/chatlib/conversation-detail/message/html/html.component.spec.ts +25 -0
- package/src/app/chatlib/conversation-detail/message/html/html.component.ts +33 -0
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +2 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +2 -2
- package/src/app/directives/safe-html.pipe.ts +2 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.html +4 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +12 -23
- package/src/app/pages/conversations-list/conversations-list.page.html +21 -12
- package/src/app/pages/conversations-list/conversations-list.page.ts +58 -191
- package/src/app/pages/loader-preview/loader-preview.module.ts +1 -2
- package/src/app/shared/shared.module.ts +4 -0
- package/src/assets/js/chat21client.js +1 -1
- package/src/chat21-core/models/conversation.ts +1 -1
- package/src/chat21-core/providers/abstract/conversations-handler.service.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +65 -9
- package/src/chat21-core/utils/utils-message.ts +5 -6
|
@@ -7,7 +7,6 @@ import { LoaderPreviewPage } from './loader-preview.page';
|
|
|
7
7
|
import { TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
|
8
8
|
import { createTranslateLoader } from '../../../chat21-core/utils/utils';
|
|
9
9
|
import { HttpClient } from '@angular/common/http';
|
|
10
|
-
import { SafeHtmlPipe } from 'src/app/directives/safe-html.pipe';
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
@NgModule({
|
|
@@ -24,6 +23,6 @@ import { SafeHtmlPipe } from 'src/app/directives/safe-html.pipe';
|
|
|
24
23
|
}
|
|
25
24
|
})
|
|
26
25
|
],
|
|
27
|
-
declarations: [LoaderPreviewPage
|
|
26
|
+
declarations: [LoaderPreviewPage]
|
|
28
27
|
})
|
|
29
28
|
export class LoaderPreviewPageModule {}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HtmlComponent } from './../chatlib/conversation-detail/message/html/html.component';
|
|
1
2
|
import { BubbleOthersMessageComponent } from './../components/conversation-detail/bubble-others-message/bubble-others-message.component';
|
|
2
3
|
|
|
3
4
|
import { TextComponent } from '../chatlib/conversation-detail/message/text/text.component';
|
|
@@ -46,6 +47,7 @@ import { DefaultTooltipOptions } from 'src/chat21-core/utils/utils';
|
|
|
46
47
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
47
48
|
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
|
48
49
|
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
50
|
+
import { SafeHtmlPipe } from '../directives/safe-html.pipe';
|
|
49
51
|
|
|
50
52
|
// import { MessageTextAreaComponent } from '../components/conversation-detail/message-text-area/message-text-area.component'; // MessageTextAreaComponent is part of the declarations ConversationDetailPageModule
|
|
51
53
|
|
|
@@ -75,6 +77,7 @@ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
|
75
77
|
InfoMessageComponent,
|
|
76
78
|
ReturnReceiptComponent,
|
|
77
79
|
TextComponent,
|
|
80
|
+
HtmlComponent,
|
|
78
81
|
BubbleDayMessageComponent,
|
|
79
82
|
BubbleSystemMessageComponent,
|
|
80
83
|
BubbleMyMessageComponent,
|
|
@@ -87,6 +90,7 @@ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
|
87
90
|
MarkedPipe,
|
|
88
91
|
AutofocusDirective,
|
|
89
92
|
HtmlEntitiesEncodePipe,
|
|
93
|
+
SafeHtmlPipe,
|
|
90
94
|
OptionHeaderComponent
|
|
91
95
|
],
|
|
92
96
|
exports: [
|
|
@@ -962,7 +962,7 @@ class Chat21Client {
|
|
|
962
962
|
}
|
|
963
963
|
if (this.log) {console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)}
|
|
964
964
|
// client = mqtt.connect('mqtt://127.0.0.1:15675/ws',options)
|
|
965
|
-
this.client = mqtt.connect(
|
|
965
|
+
this.client = mqtt.connect(this.endpoint,options)
|
|
966
966
|
|
|
967
967
|
this.client.on('connect', // TODO if token is wrong it must reply with an error!
|
|
968
968
|
() => {
|
|
@@ -15,7 +15,7 @@ export class ConversationModel {
|
|
|
15
15
|
public senderAuthInfo: any,
|
|
16
16
|
public sender_fullname: string,
|
|
17
17
|
public status: string,
|
|
18
|
-
public timestamp:
|
|
18
|
+
public timestamp: number,
|
|
19
19
|
public time_last_message: string,
|
|
20
20
|
public selected: boolean,
|
|
21
21
|
public color: string,
|
|
@@ -29,7 +29,7 @@ export abstract class ConversationsHandlerService {
|
|
|
29
29
|
// functions
|
|
30
30
|
abstract initialize(tenant: string, userId: string, translationMap: Map<string, string>): void;
|
|
31
31
|
// abstract connect(): void;
|
|
32
|
-
abstract subscribeToConversations(callback: any): void;
|
|
32
|
+
abstract subscribeToConversations(lastConversatioTimestamp: number, callback: any): void;
|
|
33
33
|
abstract countIsNew(): number;
|
|
34
34
|
abstract setConversationRead(conversationId: string): void;
|
|
35
35
|
abstract dispose(): void;
|
|
@@ -114,21 +114,62 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
114
114
|
// ---------------------------------------------------------------------------------
|
|
115
115
|
// New connect - renamed subscribeToConversation
|
|
116
116
|
//----------------------------------------------------------------------------------
|
|
117
|
-
subscribeToConversations(callback) {
|
|
117
|
+
subscribeToConversations(lastConversationTimestamp: number, callback) {
|
|
118
118
|
const that = this;
|
|
119
119
|
const urlNodeFirebase = conversationsPathForUserId(this.tenant, this.loggedUserId);
|
|
120
120
|
this.logger.debug('[FIREBASEConversationsHandlerSERVICE] SubscribeToConversations conversations::ACTIVE urlNodeFirebase', urlNodeFirebase)
|
|
121
121
|
this.ref = firebase.database().ref(urlNodeFirebase).orderByChild('timestamp').limitToLast(200);
|
|
122
|
-
|
|
122
|
+
|
|
123
|
+
// this.ref.once('value').then(snapshot => {
|
|
124
|
+
// snapshot.forEach(childSnapshot => {
|
|
125
|
+
// const childData: ConversationModel = childSnapshot.val();
|
|
126
|
+
// childData.uid = childSnapshot.key
|
|
127
|
+
// that.added(childData)
|
|
128
|
+
// lastConversationTimestamp = childData.timestamp
|
|
129
|
+
// });
|
|
130
|
+
|
|
131
|
+
// callback(that.conversations)
|
|
132
|
+
// return lastConversationTimestamp
|
|
133
|
+
// }).then((timestamp)=> {
|
|
134
|
+
// console.log('timestampppppp',timestamp)
|
|
135
|
+
// this.ref.startAt(timestamp).on('child_changed', (childSnapshot) => {
|
|
136
|
+
// const conv: ConversationModel = childSnapshot.val();
|
|
137
|
+
// conv.uid = childSnapshot.key
|
|
138
|
+
// that.changed(conv);
|
|
139
|
+
// });
|
|
140
|
+
// this.ref.startAt(timestamp).on('child_removed', (childSnapshot) => {
|
|
141
|
+
// const conv: ConversationModel = childSnapshot.val();
|
|
142
|
+
// conv.uid = childSnapshot.key
|
|
143
|
+
// that.removed(conv);
|
|
144
|
+
// });
|
|
145
|
+
// this.ref.startAt(timestamp).on('child_added', (childSnapshot) => {
|
|
146
|
+
// const conv: ConversationModel = childSnapshot.val();
|
|
147
|
+
// console.log('addedddd', conv)
|
|
148
|
+
// conv.uid = childSnapshot.key
|
|
149
|
+
// that.added(conv);
|
|
150
|
+
// });
|
|
151
|
+
// });
|
|
152
|
+
// this.ref.on('value', (snaps) => {
|
|
153
|
+
// if(snaps){
|
|
154
|
+
// console.log('convvvvvv', snaps.val(), snaps.val().length)
|
|
155
|
+
// for(let item=0; item<snaps.val().length; item++){
|
|
156
|
+
// that.added(snaps.val()[item])
|
|
157
|
+
// }
|
|
158
|
+
// callback(this.conversations)
|
|
159
|
+
// }
|
|
160
|
+
// })
|
|
161
|
+
this.ref.startAt(lastConversationTimestamp).on('child_changed', (childSnapshot) => {
|
|
123
162
|
that.changed(childSnapshot);
|
|
124
163
|
});
|
|
125
|
-
this.ref.on('child_removed', (childSnapshot) => {
|
|
164
|
+
this.ref.startAt(lastConversationTimestamp).on('child_removed', (childSnapshot) => {
|
|
126
165
|
that.removed(childSnapshot);
|
|
127
166
|
});
|
|
128
|
-
this.ref.on('child_added', (childSnapshot) => {
|
|
167
|
+
this.ref.startAt(lastConversationTimestamp).on('child_added', (childSnapshot) => {
|
|
129
168
|
that.added(childSnapshot);
|
|
130
169
|
});
|
|
131
170
|
|
|
171
|
+
|
|
172
|
+
|
|
132
173
|
setTimeout(() => {
|
|
133
174
|
callback()
|
|
134
175
|
}, 2000);
|
|
@@ -339,7 +380,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
339
380
|
childData.uid = childSnapshot.key;
|
|
340
381
|
const conversation = this.completeConversation(childData);
|
|
341
382
|
if (this.isValidConversation(conversation)) {
|
|
342
|
-
this.setClosingConversation(
|
|
383
|
+
this.setClosingConversation(conversation.uid, false);
|
|
343
384
|
const index = searchIndexInArrayForUid(this.conversations, conversation.uid);
|
|
344
385
|
if (index > -1) {
|
|
345
386
|
this.conversations.splice(index, 1, conversation);
|
|
@@ -477,25 +518,25 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
477
518
|
conversation_with = conv.recipient;
|
|
478
519
|
conversation_with_fullname = conv.recipient_fullname;
|
|
479
520
|
conv.sender_fullname = this.translationMap.get('YOU')
|
|
480
|
-
|
|
481
521
|
// conv.last_message_text = YOU + conv.last_message_text;
|
|
482
522
|
// } else if (conv.channel_type === TYPE_GROUP) {
|
|
483
523
|
} else if (isGroup(conv)) {
|
|
484
524
|
// conversation_with_fullname = conv.sender_fullname;
|
|
485
525
|
// conv.last_message_text = conv.last_message_text;
|
|
486
526
|
conversation_with = conv.recipient;
|
|
487
|
-
conversation_with_fullname = conv.recipient_fullname;
|
|
527
|
+
// conversation_with_fullname = conv.recipient_fullname;
|
|
528
|
+
conversation_with_fullname = this.changeSenderFullName(conv)
|
|
488
529
|
}
|
|
489
530
|
if (conv.attributes && conv.attributes.subtype) {
|
|
490
531
|
if (conv.attributes.subtype === 'info' || conv.attributes.subtype === 'info/support') {
|
|
491
532
|
this.translateInfoSupportMessages(conv);
|
|
492
533
|
}
|
|
493
534
|
}
|
|
494
|
-
|
|
535
|
+
// Fixes the bug: if a snippet of code is pasted and sent it is not displayed correctly in the convesations list
|
|
536
|
+
// conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
|
|
495
537
|
conv.conversation_with = conversation_with;
|
|
496
538
|
conv.conversation_with_fullname = conversation_with_fullname;
|
|
497
539
|
conv.status = this.setStatusConversation(conv.sender, conv.uid);
|
|
498
|
-
// conv.time_last_message = this.getTimeLastMessage(conv.timestamp); // evaluate if is used
|
|
499
540
|
conv.avatar = avatarPlaceholder(conversation_with_fullname);
|
|
500
541
|
conv.color = getColorBck(conversation_with_fullname);
|
|
501
542
|
//conv.image = this.imageRepo.getImagePhotoUrl(conversation_with);
|
|
@@ -504,6 +545,21 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
504
545
|
}
|
|
505
546
|
|
|
506
547
|
|
|
548
|
+
/**BUG-FIX: on Conversation-list, when conversation start, it continuosly change the sender_fullname info from Guest to others name */
|
|
549
|
+
private changeSenderFullName(conversation: ConversationModel): string {
|
|
550
|
+
let old_conv = this.conversations.find(conv => conv.uid === conversation.uid)
|
|
551
|
+
let conversation_with_fullname = conversation.recipient_fullname
|
|
552
|
+
if(old_conv){
|
|
553
|
+
if(conversation.recipient_fullname !== old_conv.recipient_fullname && conversation.recipient_fullname !== 'Guest '){
|
|
554
|
+
conversation_with_fullname = conversation.recipient_fullname
|
|
555
|
+
} else {
|
|
556
|
+
// conversation_with_fullname= old_conv.recipient_fullname
|
|
557
|
+
conversation_with_fullname= old_conv.conversation_with_fullname
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return conversation_with_fullname
|
|
561
|
+
}
|
|
562
|
+
|
|
507
563
|
translateInfoSupportMessages(conv) {
|
|
508
564
|
const INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU = this.translationMap.get('INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU');
|
|
509
565
|
// console.log('[FIREBASEConversationsHandlerSERVICE] INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU', INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU)
|
|
@@ -85,9 +85,8 @@ export function messageType(msgType: string, message: any) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export function isEmojii(message: any)
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
export function isEmojii(message: any){
|
|
89
|
+
|
|
91
90
|
// let emoji = '';
|
|
92
91
|
// try {
|
|
93
92
|
// emoji = message.trim(); // .charAt(0);
|
|
@@ -106,12 +105,12 @@ export function isEmojii(message: any) {
|
|
|
106
105
|
// }
|
|
107
106
|
// https://localcoder.org/javascript-detect-if-a-string-contains-only-unicode-emojis
|
|
108
107
|
try {
|
|
109
|
-
if
|
|
108
|
+
if(!message) return false;
|
|
110
109
|
const onlyEmojis = message.replace(new RegExp('[\u0000-\u1eeff]', 'g'), '')
|
|
111
110
|
const visibleChars = message.replace(new RegExp('[\n\r\s]+|( )+', 'g'), '')
|
|
112
|
-
if
|
|
111
|
+
if(onlyEmojis === '' || visibleChars == '') return false
|
|
113
112
|
return onlyEmojis.length === visibleChars.length
|
|
114
|
-
} catch
|
|
113
|
+
} catch(e) {
|
|
115
114
|
return false
|
|
116
115
|
}
|
|
117
116
|
}
|