@chat21/chat21-ionic 3.0.62-rc2 → 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 +38 -0
- package/README.md +6 -2
- package/deploy_prod.sh +5 -5
- package/package.json +7 -1
- package/src/app/app.component.ts +127 -69
- package/src/app/app.module.ts +1 -0
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +2 -0
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +2 -1
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +34 -22
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +33 -12
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +4 -40
- 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.scss +1 -1
- 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/chatlib/conversation-detail/message/image/image.component.ts +5 -3
- package/src/app/chatlib/conversation-detail/message/return-receipt/return-receipt.component.scss +1 -1
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.html +1 -1
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.scss +4 -4
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.html +1 -1
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.scss +3 -3
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +3 -3
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +10 -55
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +10 -4
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +4 -2
- package/src/app/components/image-viewer/image-viewer.component.ts +28 -10
- package/src/app/components/project-item/project-item.component.ts +6 -30
- package/src/app/components/sidebar/sidebar.component.html +2 -2
- package/src/app/components/sidebar/sidebar.component.ts +49 -83
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +17 -1
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +52 -6
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +81 -111
- package/src/app/directives/safe-html.pipe.ts +2 -2
- package/src/app/pages/authentication/login/login.page.ts +20 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.html +42 -19
- package/src/app/pages/conversation-detail/conversation-detail.page.scss +15 -6
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +188 -264
- 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/services/nav-proxy.service.ts +15 -13
- package/src/app/shared/shared.module.ts +4 -0
- package/src/assets/i18n/de.json +2 -1
- package/src/assets/i18n/en.json +2 -1
- package/src/assets/i18n/es.json +2 -1
- package/src/assets/i18n/fr.json +2 -1
- package/src/assets/i18n/it.json +2 -1
- package/src/assets/i18n/pt.json +2 -1
- package/src/assets/i18n/ru.json +2 -1
- package/src/assets/i18n/sr.json +2 -1
- package/src/assets/i18n/tr.json +2 -1
- package/src/chat-config-pre-test.json +2 -1
- package/src/chat-config-pre.json +15 -3
- 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-conversation-handler.ts +2 -3
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +65 -9
- package/src/chat21-core/providers/logger/customLogger.ts +2 -10
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +1 -1
- package/src/chat21-core/utils/utils-message.ts +101 -85
- package/src/variables.scss +4 -1
package/src/assets/i18n/pt.json
CHANGED
|
@@ -261,5 +261,6 @@
|
|
|
261
261
|
"First_name_of_recipient": "Nome do destinatário",
|
|
262
262
|
"First_name_of_agent": "Nome do agente",
|
|
263
263
|
"EnterCannedResponseTitle": "Insira o título da resposta predeterminada",
|
|
264
|
-
"WriteMsgToSendToYourVisitors": "Escreva uma mensagem de resposta pronta para enviar aos seus visitantes"
|
|
264
|
+
"WriteMsgToSendToYourVisitors": "Escreva uma mensagem de resposta pronta para enviar aos seus visitantes",
|
|
265
|
+
"EditProfile": "Editar Perfil"
|
|
265
266
|
}
|
package/src/assets/i18n/ru.json
CHANGED
|
@@ -261,5 +261,6 @@
|
|
|
261
261
|
"First_name_of_recipient": "Имя получателя",
|
|
262
262
|
"First_name_of_agent": "Имя агента",
|
|
263
263
|
"EnterCannedResponseTitle": "Введите готовый заголовок ответа",
|
|
264
|
-
"WriteMsgToSendToYourVisitors": "Напишите готовое ответное сообщение для отправки своим посетителям"
|
|
264
|
+
"WriteMsgToSendToYourVisitors": "Напишите готовое ответное сообщение для отправки своим посетителям",
|
|
265
|
+
"EditProfile": "Редактировать профиль"
|
|
265
266
|
}
|
package/src/assets/i18n/sr.json
CHANGED
|
@@ -261,5 +261,6 @@
|
|
|
261
261
|
"First_name_of_recipient": "Име примаоца",
|
|
262
262
|
"First_name_of_agent": "Име агента",
|
|
263
263
|
"EnterCannedResponseTitle": "Унесите назив унапред припремљеног одговора",
|
|
264
|
-
"WriteMsgToSendToYourVisitors": "Напишите унапред припремљену одговор поруку коју ћете послати посетиоцима"
|
|
264
|
+
"WriteMsgToSendToYourVisitors": "Напишите унапред припремљену одговор поруку коју ћете послати посетиоцима",
|
|
265
|
+
"EditProfile": "Уреди профил"
|
|
265
266
|
}
|
package/src/assets/i18n/tr.json
CHANGED
|
@@ -261,5 +261,6 @@
|
|
|
261
261
|
"First_name_of_recipient": "Alıcının adı",
|
|
262
262
|
"First_name_of_agent": "Ajanın adı",
|
|
263
263
|
"EnterCannedResponseTitle": "Hazır yanıt başlığını girin",
|
|
264
|
-
"WriteMsgToSendToYourVisitors": "Ziyaretçilerinize göndermek için hazır bir yanıt mesajı yazın"
|
|
264
|
+
"WriteMsgToSendToYourVisitors": "Ziyaretçilerinize göndermek için hazır bir yanıt mesajı yazın",
|
|
265
|
+
"EditProfile": "Profili Düzenle"
|
|
265
266
|
}
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"apiUrl": "https://tiledesk-server-pre.herokuapp.com/",
|
|
31
31
|
"baseImageUrl": "https://firebasestorage.googleapis.com/v0/b/",
|
|
32
32
|
"dashboardUrl": "/dashboard/",
|
|
33
|
-
"wsUrl": "wss://tiledesk-server-pre.herokuapp.com/"
|
|
33
|
+
"wsUrl": "wss://tiledesk-server-pre.herokuapp.com/",
|
|
34
|
+
"storage_prefix": "chat_sv5"
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
|
package/src/chat-config-pre.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
+
"t2y12PruGU9wUtEGzBJfolMIgK": "CAR:T-PAY:T-ANA:T-ACT:T-APP:T",
|
|
2
3
|
"chatEngine": "firebase",
|
|
4
|
+
"uploadEngine": "firebase",
|
|
5
|
+
"pushEngine": "firebase",
|
|
6
|
+
"logLevel": "info",
|
|
7
|
+
"fileUploadAccept":"*/*",
|
|
8
|
+
"authPersistence": "LOCAL",
|
|
9
|
+
"supportMode": true,
|
|
10
|
+
"writeToButton": true,
|
|
11
|
+
"archivedButton": true,
|
|
3
12
|
"firebaseConfig": {
|
|
13
|
+
"tenant": "tilechat",
|
|
4
14
|
"apiKey": "AIzaSyCoWXHNvP1-qOllCpTshhC6VjPXeRTK0T4",
|
|
5
15
|
"authDomain": "chat21-pre-01.firebaseapp.com",
|
|
6
16
|
"databaseURL": "https://chat21-pre-01.firebaseio.com",
|
|
@@ -8,16 +18,18 @@
|
|
|
8
18
|
"storageBucket": "chat21-pre-01.appspot.com",
|
|
9
19
|
"messagingSenderId": "269505353043",
|
|
10
20
|
"appId": "1:269505353043:web:b82af070572669e3707da6",
|
|
11
|
-
"chat21ApiUrl": "https://us-central1-chat21-pre-01.cloudfunctions.net"
|
|
21
|
+
"chat21ApiUrl": "https://us-central1-chat21-pre-01.cloudfunctions.net",
|
|
22
|
+
"vapidKey": "BOsgS2ADwspKdWAmiFDZXEYqY1HSYADVfJT3j67wsySh3NxaViJqoabPJH8WM02wb5r8cQIm5TgM0UK047Z1D1c"
|
|
12
23
|
},
|
|
13
24
|
"chat21Config": {
|
|
14
25
|
"appId": "tilechat",
|
|
15
|
-
"MQTTendpoint": "
|
|
26
|
+
"MQTTendpoint": "ws://99.80.197.164:15675/ws",
|
|
16
27
|
"APIendpoint": "http://99.80.197.164:8004/api",
|
|
17
28
|
"loginServiceEndpoint": "http://99.80.197.164:/tilechat/signin"
|
|
18
29
|
},
|
|
19
30
|
"apiUrl": "https://tiledesk-server-pre.herokuapp.com/",
|
|
20
31
|
"baseImageUrl": "https://firebasestorage.googleapis.com/v0/b/",
|
|
21
|
-
"dashboardUrl": "
|
|
32
|
+
"dashboardUrl": "/dashboard/",
|
|
33
|
+
"wsUrl": "wss://tiledesk-server-pre.herokuapp.com/"
|
|
22
34
|
}
|
|
23
35
|
|
|
@@ -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;
|
|
@@ -156,8 +156,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
156
156
|
typeMsg,
|
|
157
157
|
attributes,
|
|
158
158
|
channelType,
|
|
159
|
-
false
|
|
160
|
-
isEmojii(msg)
|
|
159
|
+
false
|
|
161
160
|
);
|
|
162
161
|
const messageRef = firebaseMessagesCustomUid.push({
|
|
163
162
|
language: lang,
|
|
@@ -291,7 +290,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
291
290
|
msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
|
|
292
291
|
|
|
293
292
|
//check if message contains only an emojii
|
|
294
|
-
msg.emoticon = isEmojii(msg.text)
|
|
293
|
+
// msg.emoticon = isEmojii(msg.text)
|
|
295
294
|
|
|
296
295
|
// traduco messaggi se sono del server
|
|
297
296
|
if (msg.attributes && msg.attributes.subtype) {
|
|
@@ -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)
|
|
@@ -17,18 +17,10 @@ export class CustomLogger implements LoggerService {
|
|
|
17
17
|
constructor(private logger: NGXLogger) { }
|
|
18
18
|
|
|
19
19
|
setLoggerConfig(isLogEnabled: boolean, logLevel: string) {
|
|
20
|
-
|
|
21
20
|
this.isLogEnabled = isLogEnabled;
|
|
22
|
-
// console.log('LoggerService this.logLevel ', this.logLevel)
|
|
23
|
-
|
|
24
21
|
if (logLevel) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.logLevel = LogLevel[logLevel.toUpperCase()];
|
|
28
|
-
// console.log('LoggerService this.logLevel toUpperCase', this.logLevel)
|
|
29
|
-
} else {
|
|
30
|
-
console.error('logLevel is not a string. See the chat21-ionic README.md')
|
|
31
|
-
}
|
|
22
|
+
this.logLevel = LogLevel[logLevel.toUpperCase()];
|
|
23
|
+
console.log('LoggerService this.logLevel ', this.logLevel)
|
|
32
24
|
}
|
|
33
25
|
}
|
|
34
26
|
|
|
@@ -175,7 +175,7 @@ export class TiledeskAuthService {
|
|
|
175
175
|
this.currentUser = member;
|
|
176
176
|
this.logger.log('[TILEDESK-AUTH] - createCompleteUser member ', member);
|
|
177
177
|
this.appStorage.setItem('currentUser', JSON.stringify(this.currentUser));
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
} catch (err) {
|
|
180
180
|
this.logger.error('[TILEDESK-AUTH]- createCompleteUser ERR ', err)
|
|
181
181
|
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
MESSAGE_TYPE_INFO,
|
|
3
|
+
MESSAGE_TYPE_MINE,
|
|
4
|
+
MESSAGE_TYPE_OTHERS,
|
|
5
|
+
MESSAGE_TYPE_DATE,
|
|
6
|
+
MAX_WIDTH_IMAGES,
|
|
7
|
+
CHANNEL_TYPE_GROUP,
|
|
8
|
+
TYPE_SUPPORT_GROUP
|
|
9
9
|
} from '../../chat21-core/utils/constants';
|
|
10
10
|
|
|
11
11
|
/** */
|
|
12
12
|
export function isFirstMessage(i: number) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.error('error: ', err);
|
|
13
|
+
if (i > 0) {
|
|
14
|
+
try {
|
|
15
|
+
const message = this.messages[i];
|
|
16
|
+
const prevMessage = this.messages[i - 1];
|
|
17
|
+
if (prevMessage.sender !== message.sender || message.headerDate || (prevMessage && this.isInfo(prevMessage))) {
|
|
18
|
+
return true;
|
|
23
19
|
}
|
|
20
|
+
return false;
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error('error: ', err);
|
|
24
23
|
}
|
|
24
|
+
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/** */
|
|
28
28
|
export function isImage(message: any) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (message && message.type && message.metadata && message.metadata.src && message.type === 'image') {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function isFrame(message: any) {
|
|
@@ -41,96 +41,112 @@ export function isFrame(message: any) {
|
|
|
41
41
|
|
|
42
42
|
/** */
|
|
43
43
|
export function isFile(message: any) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
if (message && message.type && message.metadata && message.metadata.src && message.type === 'file') {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/** */
|
|
51
51
|
export function isInfo(message: any) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (message.attributes && (message.attributes.subtype === 'info' || message.attributes.subtype === 'info/support')) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/** */
|
|
59
59
|
export function isMine(message: any) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
if (message.isSender) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/** */
|
|
67
67
|
export function messageType(msgType: string, message: any) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
if (msgType === MESSAGE_TYPE_INFO) {
|
|
75
|
-
return this.isInfo(message);
|
|
76
|
-
}
|
|
77
|
-
if (msgType === MESSAGE_TYPE_MINE) {
|
|
78
|
-
return this.isMine(message);
|
|
79
|
-
}
|
|
80
|
-
if (msgType === MESSAGE_TYPE_OTHERS) {
|
|
81
|
-
if (this.isInfo(message) === false && this.isMine(message) === false) {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
68
|
+
if (msgType === MESSAGE_TYPE_DATE) {
|
|
69
|
+
if (message.headerDate && message.headerDate !== '') {
|
|
70
|
+
return true;
|
|
85
71
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function isEmojii(message: any){
|
|
89
|
-
if (message.length > 2) {
|
|
90
72
|
return false;
|
|
91
73
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
74
|
+
if (msgType === MESSAGE_TYPE_INFO) {
|
|
75
|
+
return this.isInfo(message);
|
|
76
|
+
}
|
|
77
|
+
if (msgType === MESSAGE_TYPE_MINE) {
|
|
78
|
+
return this.isMine(message);
|
|
79
|
+
}
|
|
80
|
+
if (msgType === MESSAGE_TYPE_OTHERS) {
|
|
81
|
+
if (this.isInfo(message) === false && this.isMine(message) === false) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
96
84
|
return false;
|
|
97
85
|
}
|
|
86
|
+
}
|
|
98
87
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
88
|
+
export function isEmojii(message: any){
|
|
89
|
+
|
|
90
|
+
// let emoji = '';
|
|
91
|
+
// try {
|
|
92
|
+
// emoji = message.trim(); // .charAt(0);
|
|
93
|
+
// if (emoji.length > 2) {
|
|
94
|
+
// return false;
|
|
95
|
+
// }
|
|
96
|
+
// } catch (e) {
|
|
97
|
+
// return false;
|
|
98
|
+
// }
|
|
99
|
+
// // const regex = '(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])'
|
|
100
|
+
// const ranges = ['(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])'];
|
|
101
|
+
// if (emoji.match(ranges.join('|'))) {
|
|
102
|
+
// return true;
|
|
103
|
+
// } else {
|
|
104
|
+
// return false;
|
|
105
|
+
// }
|
|
106
|
+
// https://localcoder.org/javascript-detect-if-a-string-contains-only-unicode-emojis
|
|
107
|
+
try {
|
|
108
|
+
if(!message) return false;
|
|
109
|
+
const onlyEmojis = message.replace(new RegExp('[\u0000-\u1eeff]', 'g'), '')
|
|
110
|
+
const visibleChars = message.replace(new RegExp('[\n\r\s]+|( )+', 'g'), '')
|
|
111
|
+
if(onlyEmojis === '' || visibleChars == '') return false
|
|
112
|
+
return onlyEmojis.length === visibleChars.length
|
|
113
|
+
} catch(e) {
|
|
114
|
+
return false
|
|
104
115
|
}
|
|
105
116
|
}
|
|
106
117
|
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
107
121
|
/** */
|
|
108
122
|
export function getSizeImg(message: any, maxWidthImage?: number): any {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
return sizeImage;
|
|
124
|
-
} catch (err) {
|
|
125
|
-
console.error('error: ', err);
|
|
126
|
-
return;
|
|
123
|
+
try {
|
|
124
|
+
const metadata = message.metadata;
|
|
125
|
+
const sizeImage = {
|
|
126
|
+
width: metadata.width,
|
|
127
|
+
height: metadata.height
|
|
128
|
+
};
|
|
129
|
+
if (!maxWidthImage) {
|
|
130
|
+
maxWidthImage = MAX_WIDTH_IMAGES;
|
|
131
|
+
}
|
|
132
|
+
if (metadata.width && metadata.width > maxWidthImage) {
|
|
133
|
+
const rapporto = (metadata['width'] / metadata['height']);
|
|
134
|
+
sizeImage.width = maxWidthImage;
|
|
135
|
+
sizeImage.height = maxWidthImage / rapporto;
|
|
127
136
|
}
|
|
137
|
+
return sizeImage;
|
|
138
|
+
} catch (err) {
|
|
139
|
+
console.error('error: ', err);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
128
142
|
}
|
|
129
143
|
|
|
130
144
|
/** */
|
|
131
145
|
export function isChannelTypeGroup(channelType: string) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
if (channelType === CHANNEL_TYPE_GROUP || channelType === TYPE_SUPPORT_GROUP) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
136
150
|
}
|
|
151
|
+
|
|
152
|
+
|
package/src/variables.scss
CHANGED
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
|
|
16
16
|
--light-blue: #C9E4F6;
|
|
17
17
|
--basic-blue: #2a69c1;
|
|
18
|
-
--
|
|
18
|
+
--bubble-blue: rgb(0, 153, 255);
|
|
19
|
+
--bubble-lightyellow: rgb(255, 247, 237);
|
|
20
|
+
--bubble-privateMsg: rgb(254, 214, 168);
|
|
21
|
+
--bubble-privateMsgColor: rgb(47, 57, 65);
|
|
19
22
|
|
|
20
23
|
--basic-yellow: #FFC627;
|
|
21
24
|
--basic-red: #EB1E23;
|