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

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,10 @@
1
1
  # chat21-web-widget ver 5.0
2
2
 
3
+ ### 5.0.62 in PROD
4
+ - added: pending messages
5
+ - added: disconnect from messaging handler if no interaction exist within 1 minute
6
+ - bug-fixed: cannot able to send messages due to undefined in conversationHandlerService
7
+
3
8
  ### 5.0.61-rc.1
4
9
  - added: 'flags' emojii category in conversatio-footer component
5
10
  - 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.62",
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{
@@ -979,12 +979,12 @@ class Chat21Client {
979
979
  // clean: true,
980
980
  reconnectPeriod: 1000,
981
981
  // connectTimeout: 30 * 1000,
982
- will: {
983
- topic: this.presence_topic,
984
- payload: '{"disconnected":true}',
985
- qos: 1,
986
- retain: true
987
- },
982
+ // will: {
983
+ // topic: this.presence_topic,
984
+ // payload: '{"disconnected":true}',
985
+ // qos: 1,
986
+ // retain: true
987
+ // },
988
988
  clientId: this.client_id,
989
989
  username: 'JWT',
990
990
  password: jwt,
@@ -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;
@@ -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
@@ -72,9 +72,9 @@ export class MQTTPresenceService extends PresenceService {
72
72
 
73
73
  public imHere(): void {
74
74
  this.logger.debug('[MQTT-PRESENCE] imHere', this.tenant);
75
- setTimeout(() => {
76
- this.chat21Service.chatClient.ImHere()
77
- }, 2000);
75
+ // setTimeout(() => {
76
+ // this.chat21Service.chatClient.ImHere()
77
+ // }, 2000);
78
78
  }
79
79
 
80
80
  /**