@chat21/chat21-web-widget 5.0.61-rc.1 → 5.0.63

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # chat21-web-widget ver 5.0
2
2
 
3
+ ### 5.0.62 in PROD
4
+ - added: LWT e imHere() for presence management
5
+
6
+ ### 5.0.63-rc.1
7
+ - added: skip info messages in conversations-list component
8
+
9
+ ### 5.0.62 in PROD
10
+ - added: pending messages
11
+ - added: disconnect from messaging handler if no interaction exist within 1 minute
12
+ - bug-fixed: cannot able to send messages due to undefined in conversationHandlerService
13
+
3
14
  ### 5.0.61-rc.1
4
15
  - added: 'flags' emojii category in conversatio-footer component
5
16
  - added: 'share prototype' button inside 'chatbot-panel.html' page to copy link to clipboard
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-web-widget",
3
3
  "author": "Tiledesk SRL",
4
- "version": "5.0.61-rc.1",
4
+ "version": "5.0.63",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -1727,6 +1727,12 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
1727
1727
  public onSelectedConversation($event: ConversationModel) {
1728
1728
  if ($event) {
1729
1729
  if (this.g.isOpen === false) {
1730
+
1731
+ if(this.forceDisconnect){
1732
+ console.log('[FORCE] onSelectedConversation --> reconnect', this.forceDisconnect)
1733
+ this.messagingAuthService.createCustomToken(this.g.tiledeskToken)
1734
+ this.forceDisconnect = false;
1735
+ }
1730
1736
  //this.f21_open();
1731
1737
  this._f21_open()
1732
1738
  }
@@ -2094,7 +2100,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
2094
2100
  //disconnect
2095
2101
  this.forceDisconnect = true
2096
2102
  this.messagingAuthService.logout()
2097
- }, 10*1000);
2103
+ }, 60*1000);
2098
2104
  window.addEventListener("click", function(){
2099
2105
  console.log('[FORCE] <<INTERACTION>> within 1 minute')
2100
2106
  clearTimeout(clickTimeout)
@@ -342,6 +342,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
342
342
  channelType: channelType
343
343
  })
344
344
 
345
+ this.conversationHandlerService = this.chatManager.getConversationHandlerByConversationId(this.conversationWith);
345
346
  const messageSent = this.conversationHandlerService.sendMessage(
346
347
  msg,
347
348
  type,
@@ -239,9 +239,9 @@
239
239
  box-shadow: none;
240
240
  vertical-align: top;
241
241
 
242
- // button.c21-button-primary{
243
- // margin: 5px 0px;
244
- // }
242
+ button.c21-button-primary{
243
+ margin: 20px 0px;
244
+ }
245
245
  }
246
246
 
247
247
  .c21-footer{
@@ -184,7 +184,6 @@ export class ChatManager {
184
184
  getConversationHandlerByConversationId(conversationId): any {
185
185
  let handler = null;
186
186
  this.handlers.forEach(conv => {
187
- this.logger.log('[CHAT MANAGER]forEach ***', conversationId, this.handlers, conv);
188
187
  if (conv.conversationWith === conversationId) {
189
188
  handler = conv;
190
189
  return;
@@ -17,6 +17,8 @@ import { LoggerInstance } from '../logger/loggerInstance';
17
17
  // utils
18
18
  import { avatarPlaceholder, getColorBck } from '../../utils/utils-user';
19
19
  import { compareValues, conversationsPathForUserId, searchIndexInArrayForUid, isGroup } from '../../utils/utils';
20
+ import { messageType } from 'src/chat21-core/utils/utils-message';
21
+ import { MESSAGE_TYPE_INFO } from 'src/chat21-core/utils/constants';
20
22
 
21
23
 
22
24
 
@@ -475,6 +477,10 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
475
477
  //TODO-GAB: ora emit singola conversation e non dell'intero array di conversations
476
478
  private changed(childSnapshot: any) {
477
479
  const oldConversation = this.conversations[searchIndexInArrayForUid(this.conversations, childSnapshot.key)]
480
+ //skip info message updates
481
+ if(messageType(MESSAGE_TYPE_INFO, oldConversation) ){
482
+ return;
483
+ }
478
484
  if (this.conversationGenerate(childSnapshot)) {
479
485
  const index = searchIndexInArrayForUid(this.conversations, childSnapshot.key);
480
486
  if (index > -1) {
@@ -127,13 +127,19 @@ export class MQTTConversationHandler extends ConversationHandlerService {
127
127
  this.conversationWith, (message, topic) => {
128
128
  this.logger.log('[MQTTConversationHandlerSERVICE] message added:', message, 'on topic:', topic, this.messages);
129
129
  // this.addedMessage(msg);
130
- const msg: MessageModel = message;
131
- msg.uid = message.message_id;
130
+ const msg: MessageModel = message;
132
131
 
133
- //escape command message is already is in list checking by parendUid
134
- if(this.messages.filter(message => message.attributes['parentUid'] === msg.uid).length > 0){
135
- return;
132
+ //allow to replace message in unknown status (pending status: '0')
133
+ if(message.attributes && message.attributes.tempUID){
134
+ msg.uid = message.attributes.tempUID;
135
+ }else{
136
+ msg.uid = message.message_id
136
137
  }
138
+
139
+ //escape command message is already is in list checking by parendUid
140
+ // if(this.messages.filter(message => message.attributes['parentUid'] === msg.uid).length > 0){
141
+ // return;
142
+ // }
137
143
 
138
144
  if (msg.attributes && msg.attributes.commands) {
139
145
  this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', msg)
@@ -191,6 +197,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
191
197
  const recipientFullname = conversationWithFullname;
192
198
  const recipientId = conversationWith;
193
199
  attributes.lang = language;
200
+ attributes.tempUID = uuidv4(); //allow to show message in a pending status
194
201
  this.chat21Service.chatClient.sendMessage(
195
202
  msg,
196
203
  typeMsg,
@@ -210,6 +217,25 @@ export class MQTTConversationHandler extends ConversationHandlerService {
210
217
  }
211
218
  }
212
219
  );
220
+
221
+ const message = new MessageModel(
222
+ attributes.tempUID, //allow to show message in a pending status
223
+ language,
224
+ conversationWith,
225
+ recipientFullname,
226
+ sender,
227
+ senderFullname,
228
+ 0,
229
+ metadataMsg,
230
+ msg,
231
+ Date.now(),
232
+ typeMsg,
233
+ attributes,
234
+ channelType,
235
+ false
236
+ );
237
+ this.addedMessage(message) //allow to show message in a pending status: add pending message in array of messages
238
+
213
239
  return new MessageModel(
214
240
  '',
215
241
  language,
@@ -410,7 +436,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
410
436
  */
411
437
  private updateMessageStatusReceived(msg) {
412
438
  this.logger.log('[MQTTConversationHandlerSERVICE] updateMessageStatusReceived', msg);
413
- if (msg['status'] < MSG_STATUS_RECEIVED) {
439
+ if (msg['status'] < MSG_STATUS_RECEIVED && msg['status'] > 0) {
414
440
  this.logger.log('[MQTTConversationHandlerSERVICE] status ', msg['status'], ' < (RECEIVED:200)', MSG_STATUS_RECEIVED);
415
441
  let uid = msg.uid
416
442
  msg.attributes.commands? uid = msg.attributes.parentUid: null
@@ -15,6 +15,8 @@ import { avatarPlaceholder, getColorBck } from '../../utils/utils-user';
15
15
  import { compareValues, searchIndexInArrayForUid } from '../../utils/utils';
16
16
  import { LoggerService } from '../abstract/logger.service';
17
17
  import { LoggerInstance } from '../logger/loggerInstance';
18
+ import { messageType } from 'src/chat21-core/utils/utils-message';
19
+ import { MESSAGE_TYPE_INFO } from 'src/chat21-core/utils/constants';
18
20
 
19
21
  // @Injectable({ providedIn: 'root' })
20
22
  @Injectable()
@@ -267,6 +269,12 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
267
269
  if (!conversation.conversation_with) {
268
270
  conversation.conversation_with = conversation.conversWith // conversWith comes from remote
269
271
  }
272
+
273
+ //skip info message updates
274
+ if(messageType(MESSAGE_TYPE_INFO, conversation) ){
275
+ return;
276
+ }
277
+
270
278
  const index = searchIndexInArrayForUid(this.conversations, conversation.conversation_with);
271
279
  const oldConversation = this.conversations[index]
272
280
  if (index > -1) {