@chat21/chat21-web-widget 5.0.48-rc.1 → 5.0.48-rc.3

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/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.48-rc.1",
4
+ "version": "5.0.48-rc.3",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -147,7 +147,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
147
147
  return;
148
148
  }
149
149
 
150
- if(conversation.sender !== this.g.senderId && !isInfo(conversation)){
150
+ if(conversation.is_new && conversation.sender !== this.g.senderId && !isInfo(conversation)){
151
151
  that.manageTabNotification();
152
152
  }
153
153
 
@@ -1422,6 +1422,13 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
1422
1422
  });
1423
1423
  };
1424
1424
 
1425
+ /** set state reinit */
1426
+ windowContext['tiledesk'].startConversation = function () {
1427
+ ngZone.run(() => {
1428
+ windowContext['tiledesk']['angularcomponent'].component.onNewConversation();
1429
+ });
1430
+ };
1431
+
1425
1432
  /** set state reinit */
1426
1433
  windowContext['tiledesk'].reInit = function () {
1427
1434
  ngZone.run(() => {
@@ -8,7 +8,6 @@ import { Subscription } from 'rxjs';
8
8
 
9
9
  import {
10
10
  CHANNEL_TYPE_DIRECT, CHANNEL_TYPE_GROUP, TYPE_MSG_TEXT,
11
- MSG_STATUS_SENT, MSG_STATUS_RETURN_RECEIPT, MSG_STATUS_SENT_SERVER,
12
11
  UID_SUPPORT_GROUP_MESSAGES
13
12
  } from 'src/app/utils/constants';
14
13
 
@@ -46,6 +45,7 @@ import { StarRatingWidgetService } from 'src/app/providers/star-rating-widget.se
46
45
  import { TiledeskRequestsService } from 'src/chat21-core/providers/tiledesk/tiledesk-requests.service';
47
46
  import moment from 'moment';
48
47
  import { isUserBanned } from 'src/chat21-core/utils/utils-message';
48
+ import { LIVE_PAGE } from 'src/chat21-core/utils/constants';
49
49
  // import { TranslateService } from '@ngx-translate/core';
50
50
 
51
51
  @Component({
@@ -254,6 +254,7 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
254
254
  'INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU',
255
255
  'INFO_SUPPORT_LEAD_UPDATED',
256
256
  'INFO_SUPPORT_MEMBER_LEFT_GROUP',
257
+ 'INFO_SUPPORT_LIVE_PAGE',
257
258
  'LABEL_TODAY',
258
259
  'LABEL_TOMORROW',
259
260
  'LABEL_LOADING',
@@ -577,7 +578,7 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
577
578
 
578
579
  /* SEND FIRST MESSAGE if preChatForm has 'firstMessage' key */
579
580
  this.sendFirstMessagePreChatForm()
580
-
581
+
581
582
  this.logger.debug('[CONV-COMP] DETTAGLIO CONV - messages **************', this.messages);
582
583
  this.chatManager.addConversationHandler(this.conversationHandlerService);
583
584
 
@@ -626,6 +627,23 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
626
627
  }, 1000);
627
628
  }
628
629
 
630
+ /**
631
+ * allow widget to send Live info about the current page where the user is located (sourcePage and sourceTitle)
632
+ * NOT IN USE
633
+ */
634
+ sendLivePage(){
635
+ setTimeout(() => {
636
+ const message= 'Moved to: ' + this.g.attributes.sourcePage
637
+ const attributes={
638
+ subtype: 'info/support',
639
+ messagelabel: {key: LIVE_PAGE}
640
+ }
641
+ this.logger.debug('[CONV-COMP] sendLivePage --> attributes+message', attributes, message)
642
+ this.conversationFooter.sendMessage(message, TYPE_MSG_TEXT, null, attributes);
643
+ }, 1000);
644
+
645
+ }
646
+
629
647
 
630
648
  initializeTyping() {
631
649
  this.logger.debug('[CONV-COMP] membersconversation', this.membersConversation)
@@ -902,6 +920,8 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
902
920
  this.appStorageService.setItem('attributes', JSON.stringify(this.g.attributes));
903
921
  }
904
922
 
923
+
924
+
905
925
  scrollToBottom() {
906
926
  this.conversationContent.scrollToBottom();
907
927
  // const that = this;
@@ -23,6 +23,7 @@ import { environment } from '../../environments/environment';
23
23
  * oggi;
24
24
  * ieri;
25
25
  * giorno della settimana (lunedì, martedì, ecc)
26
+ * @deprecated
26
27
  */
27
28
  export function setHeaderDate(timestamp): string {
28
29
  const date = new Date(timestamp);
@@ -1549,6 +1549,7 @@
1549
1549
  <button class="btn btn-light" onclick="onClickTestButton('close')">Close <em class="fa fa-arrow-down"></em></button>
1550
1550
  <button class="btn btn-light" onclick="onClickTestButton('hide')">Hide</button>
1551
1551
  <button class="btn btn-light" onclick="onClickTestButton('show')">Show</button>
1552
+ <button class="btn btn-light" onclick="onClickTestButton('startConversation')">Start Conversation</button>
1552
1553
  <button class="btn btn-light" onclick="onClickTestButton('dispose')">Dispose</button>
1553
1554
  <button class="btn btn-light" onclick="onClickTestButton('showCallout')">Show callout</button>
1554
1555
  <button class="btn btn-light" onclick="onClickTestButton('reInit')">ReInit</button>
@@ -10,7 +10,6 @@ export class MessageModel {
10
10
  public metadata: any,
11
11
  public text: string,
12
12
  public timestamp: any,
13
- //public headerDate: string,
14
13
  public type: string,
15
14
  public attributes: any,
16
15
  public channel_type: string,
@@ -1,4 +1,4 @@
1
- import { MEMBER_LEFT_GROUP, TOUCHING_OPERATOR } from './../../utils/constants';
1
+ import { LIVE_PAGE, MEMBER_LEFT_GROUP, TOUCHING_OPERATOR } from './../../utils/constants';
2
2
  import { CustomLogger } from './../logger/customLogger';
3
3
 
4
4
  import { Inject, Injectable, Optional } from '@angular/core';
@@ -251,7 +251,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
251
251
  }
252
252
  }
253
253
 
254
-
254
+
255
255
 
256
256
  this.addRepalceMessageInArray(msg.uid, msg);
257
257
  this.messageAdded.next(msg);
@@ -372,6 +372,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
372
372
  const INFO_SUPPORT_LEAD_UPDATED = this.translationMap.get('INFO_SUPPORT_LEAD_UPDATED');
373
373
  const INFO_SUPPORT_MEMBER_LEFT_GROUP = this.translationMap.get('INFO_SUPPORT_MEMBER_LEFT_GROUP');
374
374
  const INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU = this.translationMap.get('INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU');
375
+ const INFO_SUPPORT_LIVE_PAGE = this.translationMap.get('INFO_SUPPORT_LIVE_PAGE');
375
376
 
376
377
  if (message.attributes.messagelabel
377
378
  && message.attributes.messagelabel.parameters
@@ -411,15 +412,21 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
411
412
  message.text = INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU + ': ' + textAfterColon;
412
413
  }
413
414
  } else if ((message.attributes.messagelabel && message.attributes.messagelabel.key === LEAD_UPDATED)) {
414
- message.text = INFO_SUPPORT_LEAD_UPDATED;
415
+ message.text = INFO_SUPPORT_LEAD_UPDATED;
415
416
  } else if ((message.attributes.messagelabel && message.attributes.messagelabel.key === MEMBER_LEFT_GROUP)) {
416
- let subject: string;
417
+ let subject: string = '';
417
418
  if (message.attributes.messagelabel.parameters.fullname) {
418
419
  subject = message.attributes.messagelabel.parameters.fullname;
419
420
  }else{
420
421
  subject = message.attributes.messagelabel.parameters.member_id;
421
422
  }
422
423
  message.text = subject + ' ' + INFO_SUPPORT_MEMBER_LEFT_GROUP ;
424
+ }else if(message.attributes.messagelabel && message.attributes.messagelabel.key === LIVE_PAGE){
425
+ let sourceUrl: string = '';
426
+ if(message.attributes && message.attributes.sourcePage){
427
+ sourceUrl = message.attributes.sourcePage
428
+ }
429
+ message.text= INFO_SUPPORT_LIVE_PAGE + ' ' + sourceUrl
423
430
  }
424
431
  }
425
432
 
@@ -557,7 +564,7 @@ private generateMessageObject(message, command_message, callback) {
557
564
  command_message.attributes.parentUid = parentUid //added to manage message STATUS UPDATES
558
565
  this.addedNew(command_message)
559
566
  callback();
560
- }
567
+ }
561
568
 
562
569
 
563
570
  private isValidMessage(msgToCkeck:MessageModel): boolean{
@@ -21,10 +21,10 @@ import {
21
21
  htmlEntities,
22
22
  compareValues,
23
23
  searchIndexInArrayForUid,
24
- setHeaderDate,
25
24
  conversationMessagesRef
26
25
  } from '../../utils/utils';
27
- import { checkIfIsMemberJoinedGroup, hideInfoMessage, messageType } from '../../utils/utils-message';
26
+ import { v4 as uuidv4 } from 'uuid';
27
+ import { messageType, checkIfIsMemberJoinedGroup, hideInfoMessage, isJustRecived } from '../../utils/utils-message';
28
28
 
29
29
 
30
30
  // @Injectable({ providedIn: 'root' })
@@ -47,7 +47,6 @@ export class MQTTConversationHandler extends ConversationHandlerService {
47
47
  // private variables
48
48
  private translationMap: Map<string, string>; // LABEL_TODAY, LABEL_TOMORROW
49
49
  private showInfoMessage: string[];
50
- // private urlNodeFirebase: string;
51
50
  private recipientId: string;
52
51
  private recipientFullname: string;
53
52
  private tenant: string;
@@ -55,8 +54,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
55
54
  private senderId: string;
56
55
  private listSubsriptions: any[];
57
56
  private CLIENT_BROWSER: string;
58
- private lastDate = '';
59
-
57
+ private startTime: Date = new Date();
60
58
  private logger: LoggerService = LoggerInstance.getInstance()
61
59
 
62
60
  constructor(
@@ -71,7 +69,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
71
69
  */
72
70
  initialize(recipientId: string, recipientFullName: string,loggedUser: UserModel,
73
71
  tenant: string,translationMap: Map<string, string>, showInfoMessage: string[]) {
74
- this.logger.log('[MQTTConversationHandler] initWithRecipient:', tenant);
72
+ this.logger.log('[MQTTConversationHandlerSERVICE] initWithRecipient:', tenant);
75
73
  this.recipientId = recipientId;
76
74
  this.recipientFullname = recipientFullName;
77
75
  this.loggedUser = loggedUser;
@@ -96,37 +94,49 @@ export class MQTTConversationHandler extends ConversationHandlerService {
96
94
  * mi sottoscrivo a change, removed, added
97
95
  */
98
96
  connect() {
99
- this.logger.log('[MQTTConversationHandler] connecting conversation handler...');
97
+ this.logger.log('[MQTTConversationHandlerSERVICE] connecting conversation handler...');
100
98
  if (this.conversationWith == null) {
101
- this.logger.error('[MQTTConversationHandler] cant connect invalid this.conversationWith', this.conversationWith);
99
+ this.logger.error('[MQTTConversationHandlerSERVICE] cant connect invalid this.conversationWith', this.conversationWith);
102
100
  return;
103
101
  }
104
102
  this.chat21Service.chatClient.lastMessages(this.conversationWith, (err, messages) => {
105
103
  if (!err) {
106
- messages.forEach(msg => {
107
- this.addedMessage(msg);
104
+ messages.forEach(message => {
105
+ // this.addedMessage(msg);
106
+ const msg: MessageModel = message;
107
+ msg.uid = message.message_id;
108
+ if (msg.attributes && msg.attributes.commands) {
109
+ // this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', msg)
110
+ this.addCommandMessage(msg)
111
+ } else {
112
+ // this.logger.debug('[MQTTConversationHandlerSERVICE] NOT splitted message::::', msg)
113
+ this.addedMessage(msg)
114
+ }
108
115
  });
109
116
  }
110
117
  });
111
118
  const handler_message_added = this.chat21Service.chatClient.onMessageAddedInConversation(
112
119
  this.conversationWith, (message, topic) => {
113
- this.logger.log('[MQTTConversationHandler] message added:', message, 'on topic:', topic);
114
- this.addedMessage(message);
120
+ this.logger.log('[MQTTConversationHandlerSERVICE] message added:', message, 'on topic:', topic);
121
+ // this.addedMessage(msg);
122
+ const msg: MessageModel = message;
123
+ msg.uid = message.message_id;
124
+
125
+ if (msg.attributes && msg.attributes.commands) {
126
+ this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', msg)
127
+ this.addCommandMessage(msg)
128
+ } else {
129
+ this.logger.debug('[MQTTConversationHandlerSERVICE] NOT splitted message::::', msg)
130
+ this.addedMessage(msg)
131
+ }
115
132
  });
116
133
  const handler_message_updated = this.chat21Service.chatClient.onMessageUpdatedInConversation(
117
134
  this.conversationWith, (message, topic) => {
118
- this.logger.log('[MQTTConversationHandler] message updated:', message, 'on topic:', topic);
135
+ this.logger.log('[MQTTConversationHandlerSERVICE] message updated:', message, 'on topic:', topic);
119
136
  this.updatedMessageStatus(message);
120
137
  });
121
138
  }
122
139
 
123
- isGroup(groupId) {
124
- if (groupId.indexOf('group-') >= 0) {
125
- return true;
126
- }
127
- return false;
128
- }
129
-
130
140
  /**
131
141
  * bonifico url in testo messaggio
132
142
  * recupero time attuale
@@ -163,7 +173,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
163
173
  channelType = TYPE_DIRECT;
164
174
  }
165
175
 
166
- this.logger.log('[MQTTConversationHandler] Senderfullname', senderFullname);
176
+ this.logger.log('[MQTTConversationHandlerSERVICE] Senderfullname', senderFullname);
167
177
  const language = document.documentElement.lang;
168
178
  const recipientFullname = conversationWithFullname;
169
179
  const recipientId = conversationWith;
@@ -181,7 +191,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
181
191
  (err, message) => {
182
192
  if (err) {
183
193
  message.status = '-100';
184
- this.logger.log('[MQTTConversationHandler] ERROR', err);
194
+ this.logger.log('[MQTTConversationHandlerSERVICE] ERROR', err);
185
195
  } else {
186
196
  message.status = '150';
187
197
  }
@@ -213,9 +223,9 @@ export class MQTTConversationHandler extends ConversationHandlerService {
213
223
  }
214
224
 
215
225
  /** */
216
- private addedMessage(messageSnapshot: any) {
226
+ private addedMessage(messageSnapshot: MessageModel) {
217
227
  const msg = this.messageGenerate(messageSnapshot);
218
- msg.uid = msg.message_id;
228
+
219
229
  let isInfoMessage = messageType(MESSAGE_TYPE_INFO, msg)
220
230
  if(isInfoMessage){
221
231
  this.messageInfo.next(msg)
@@ -232,16 +242,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
232
242
  }
233
243
  }
234
244
 
235
-
236
-
237
- // imposto il giorno del messaggio per visualizzare o nascondere l'header data
238
- msg.headerDate = null;
239
- const headerDate = setHeaderDate(this.translationMap, msg.timestamp);
240
- if (headerDate !== this.lastDate) {
241
- this.lastDate = headerDate;
242
- msg.headerDate = headerDate;
243
- }
244
- this.logger.log('[MQTTConversationHandler] adding message:' + JSON.stringify(msg));
245
+ this.logger.log('[MQTTConversationHandlerSERVICE] adding message:' + JSON.stringify(msg));
245
246
  // this.logger.log('childSnapshot.message_id:' + msg.message_id);
246
247
  // this.logger.log('childSnapshot.key:' + msg.key);
247
248
  // this.logger.log('childSnapshot.uid:' + msg.uid);
@@ -250,18 +251,19 @@ export class MQTTConversationHandler extends ConversationHandlerService {
250
251
  this.messageAdded.next(msg);
251
252
  }
252
253
 
254
+
253
255
  /** */
254
256
  private updatedMessageStatus(patch: any) {
255
257
  if(messageType(MESSAGE_TYPE_INFO, patch) ){
256
258
  return;
257
259
  }
258
- this.logger.log('[MQTTConversationHandler] updating message with patch', patch);
260
+ this.logger.log('[MQTTConversationHandlerSERVICE] updating message with patch', patch);
259
261
  const index = searchIndexInArrayForUid(this.messages, patch.message_id);
260
262
  if (index > -1) {
261
263
  const message = this.messages[index];
262
264
  if (message) {
263
265
  message.status = patch.status;
264
- this.logger.log('[MQTTConversationHandler] message found and patched (replacing)', message);
266
+ this.logger.log('[MQTTConversationHandlerSERVICE] message found and patched (replacing)', message);
265
267
  this.addReplaceMessageInArray(message.uid, message);
266
268
  this.messageChanged.next(message);
267
269
  }
@@ -281,9 +283,9 @@ export class MQTTConversationHandler extends ConversationHandlerService {
281
283
  /** */
282
284
  private messageGenerate(childSnapshot: any) {
283
285
  // const msg: MessageModel = childSnapshot.val();
284
- this.logger.log("[MQTTConversationHandler] childSnapshot >" + JSON.stringify(childSnapshot));
286
+ this.logger.log("[MQTTConversationHandlerSERVICE] childSnapshot >" + JSON.stringify(childSnapshot));
285
287
  const msg = childSnapshot;
286
- msg.uid = childSnapshot.key;
288
+ // msg.uid = childSnapshot.key;
287
289
  msg.text = msg.text.trim() //remove black msg with only spaces
288
290
  // controllo fatto per i gruppi da rifattorizzare
289
291
  if (!msg.sender_fullname || msg.sender_fullname === 'undefined') {
@@ -294,7 +296,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
294
296
  // msg.text = htmlEntities(msg.text);
295
297
  // }
296
298
  // verifico che il sender è il logged user
297
- this.logger.log("[MQTTConversationHandler] ****>msg.sender:" + msg.sender);
299
+ this.logger.log("[MQTTConversationHandlerSERVICE] ****>msg.sender:" + msg.sender);
298
300
  msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
299
301
  // traduco messaggi se sono del server
300
302
  if (messageType(MESSAGE_TYPE_INFO, msg)) {
@@ -307,8 +309,6 @@ export class MQTTConversationHandler extends ConversationHandlerService {
307
309
  private addReplaceMessageInArray(uid: string, msg: MessageModel) {
308
310
  const index = searchIndexInArrayForUid(this.messages, uid);
309
311
  if (index > -1) {
310
- // const headerDate = this.messages[index].headerDate;
311
- // msg.headerDate = headerDate;
312
312
  this.messages.splice(index, 1, msg);
313
313
  } else {
314
314
  this.messages.splice(0, 0, msg);
@@ -387,11 +387,11 @@ export class MQTTConversationHandler extends ConversationHandlerService {
387
387
  * @param conversationWith
388
388
  */
389
389
  private updateMessageStatusReceived(msg) {
390
- this.logger.log('[MQTTConversationHandler] updateMessageStatusReceived', msg);
390
+ this.logger.log('[MQTTConversationHandlerSERVICE] updateMessageStatusReceived', msg);
391
391
  if (msg['status'] < MSG_STATUS_RECEIVED) {
392
- this.logger.log('[MQTTConversationHandler] status ', msg['status'], ' < (RECEIVED:200)', MSG_STATUS_RECEIVED);
392
+ this.logger.log('[MQTTConversationHandlerSERVICE] status ', msg['status'], ' < (RECEIVED:200)', MSG_STATUS_RECEIVED);
393
393
  if (msg.sender !== this.loggedUser.uid && msg.status < MSG_STATUS_RECEIVED) {
394
- this.logger.log('[MQTTConversationHandler] updating message with status received');
394
+ this.logger.log('[MQTTConversationHandlerSERVICE] updating message with status received');
395
395
  this.chat21Service.chatClient.updateMessageStatus(msg.message_id, this.conversationWith, MSG_STATUS_RECEIVED, null);
396
396
  }
397
397
  }
@@ -432,15 +432,89 @@ export class MQTTConversationHandler extends ConversationHandlerService {
432
432
  // }
433
433
 
434
434
 
435
- unsubscribe(key: string) {
436
- this.logger.log('[MQTTConversationHandler] unsubscribe: ', key);
437
- this.listSubsriptions.forEach(sub => {
438
- this.logger.log('[MQTTConversationHandler] unsubscribe: ', sub.uid, key);
439
- if (sub.uid === key) {
440
- sub.unsubscribe(key, null);
441
- return;
442
- }
443
- });
444
- }
435
+ unsubscribe(key: string) {
436
+ this.logger.log('[MQTTConversationHandlerSERVICE] unsubscribe: ', key);
437
+ this.listSubsriptions.forEach(sub => {
438
+ this.logger.log('[MQTTConversationHandlerSERVICE] unsubscribe: ', sub.uid, key);
439
+ if (sub.uid === key) {
440
+ sub.unsubscribe(key, null);
441
+ return;
442
+ }
443
+ });
444
+ }
445
+
446
+ private addCommandMessage(msg: MessageModel){
447
+ const that = this;
448
+ const commands = msg.attributes.commands;
449
+ let i=0;
450
+ function execute(command){
451
+ if(command.type === "message"){
452
+ that.logger.debug('[MQTTConversationHandlerSERVICE] addCommandMessage --> type="message"', command, i)
453
+ if (i >= 2) {
454
+
455
+ //check if previus wait message type has time value, otherwize set to 1000ms
456
+ !commands[i-1].time? commands[i-1].time= 1000 : commands[i-1].time
457
+ command.message.timestamp = commands[i-2].message.timestamp + commands[i-1].time;
458
+
459
+ /** CHECK IF MESSAGE IS JUST RECEIVED: IF false, set next message time (if object exist) to 0 -> this allow to show it immediately */
460
+ if(!isJustRecived(that.startTime.getTime(), msg.timestamp)){
461
+ let previewsTimeMsg = msg.timestamp;
462
+ commands[i-2]? previewsTimeMsg = commands[i-2].message.timestamp : null;
463
+ command.message.timestamp = previewsTimeMsg + 100
464
+ commands[i+1]? commands[i+1].time = 0 : null
465
+ }
466
+ } else { /**MANAGE FIRST MESSAGE */
467
+ command.message.timestamp = msg.timestamp;
468
+ if(!isJustRecived(that.startTime.getTime(), msg.timestamp)){
469
+ commands[i+1]? commands[i+1].time = 0 : null
470
+ }
471
+ }
472
+ that.generateMessageObject(msg, command.message, function () {
473
+ i += 1
474
+ if (i < commands.length) {
475
+ execute(commands[i])
476
+ }
477
+ else {
478
+ that.logger.debug('[MQTTConversationHandlerSERVICE] addCommandMessage --> last command executed (wait), exit')
479
+ }
480
+ })
481
+ }else if(command.type === "wait"){
482
+ that.logger.debug('[MQTTConversationHandlerSERVICE] addCommandMessage --> type="wait"', command, i, commands.length)
483
+ //publish waiting event to simulate user typing
484
+ if(isJustRecived(that.startTime.getTime(), msg.timestamp)){
485
+ // console.log('message just received::', command, i, commands)
486
+ that.messageWait.next({uid: that.conversationWith, uidUserTypingNow: msg.sender, nameUserTypingNow: msg.sender_fullname, waitTime: command.time, command: command})
487
+ }
488
+ setTimeout(function() {
489
+ i += 1
490
+ if (i < commands.length) {
491
+ execute(commands[i])
492
+ }
493
+ else {
494
+ that.logger.debug('[MQTTConversationHandlerSERVICE] addCommandMessage --> last command executed (send message), exit')
495
+ }
496
+ },command.time)
497
+ }
498
+ }
499
+ execute(commands[0]) //START render first message
500
+ }
501
+
502
+ private generateMessageObject(message, command_message, callback) {
503
+ let parentUid = message.uid
504
+ command_message.uid = uuidv4();
505
+ if(command_message.text) command_message.text = command_message.text.trim()//remove black msg with only spaces
506
+ command_message.language = message.language;
507
+ command_message.recipient = message.recipient;
508
+ command_message.recipient_fullname = message.recipient_fullname;
509
+ command_message.sender = message.sender;
510
+ command_message.sender_fullname = message.sender_fullname;
511
+ command_message.channel_type = message.channel_type;
512
+ command_message.status = message.status;
513
+ command_message.isSender = message.isSender;
514
+ command_message.attributes? command_message.attributes.commands = true : command_message.attributes = {commands : true}
515
+ command_message.attributes.parentUid = parentUid //added to manage message STATUS UPDATES
516
+ this.addedMessage(command_message)
517
+ callback();
518
+ }
445
519
 
446
520
  }
@@ -156,7 +156,7 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
156
156
  this.changed(conversation);
157
157
  }
158
158
  else {
159
- this.logger.log('[MQTTConversationsHandler]Added conv -> Added!')
159
+ this.logger.log('[MQTTConversationsHandler] Added conv -> Added!')
160
160
  this.added(conversation);
161
161
  }
162
162
  });
@@ -269,10 +269,12 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
269
269
  conversation.conversation_with = conversation.conversWith // conversWith comes from remote
270
270
  }
271
271
  const index = searchIndexInArrayForUid(this.conversations, conversation.conversation_with);
272
+ const oldConversation = this.conversations[index]
272
273
  if (index > -1) {
273
274
  this.updateConversationWithSnapshot(this.conversations[index], conversation);
274
275
  this.logger.debug('[MQTTConversationsHandler] conversationchanged.isnew', JSON.stringify(conversation))
275
276
  this.conversationChanged.next(this.conversations[index]);
277
+ this.conversationChangedDetailed.next({value: this.conversations[index], previousValue: oldConversation})
276
278
  this.conversations.splice(index, 1, this.conversations[index])
277
279
  this.conversations.sort(compareValues('timestamp', 'desc'));
278
280
  }
@@ -58,7 +58,6 @@ export const TYPE_POPUP_DETAIL_MESSAGE = 'DETAIL_MESSAGE';
58
58
  export const MESSAGE_TYPE_INFO = 'INFO';
59
59
  export const MESSAGE_TYPE_MINE = 'MINE';
60
60
  export const MESSAGE_TYPE_OTHERS = 'OTHERS';
61
- export const MESSAGE_TYPE_DATE = 'DATE';
62
61
 
63
62
  export const CHAT_REOPENED = 'CHAT_REOPENED';
64
63
  export const CHAT_CLOSED = 'CHAT_CLOSED';
@@ -66,6 +65,7 @@ export const MEMBER_JOINED_GROUP = 'MEMBER_JOINED_GROUP';
66
65
  export const MEMBER_LEFT_GROUP = "MEMBER_LEFT_GROUP"
67
66
  export const LEAD_UPDATED = "LEAD_UPDATED";
68
67
  export const TOUCHING_OPERATOR = "TOUCHING_OPERATOR";
68
+ export const LIVE_PAGE = "LIVE_PAGE"
69
69
 
70
70
  // URLS
71
71
  // export const URL_SOUND = 'assets/sounds/pling.mp3';
@@ -2,7 +2,6 @@ import {
2
2
  MESSAGE_TYPE_INFO,
3
3
  MESSAGE_TYPE_MINE,
4
4
  MESSAGE_TYPE_OTHERS,
5
- MESSAGE_TYPE_DATE,
6
5
  MAX_WIDTH_IMAGES,
7
6
  CHANNEL_TYPE_GROUP,
8
7
  TYPE_SUPPORT_GROUP
@@ -72,12 +71,7 @@ export function isMine(message: any) {
72
71
 
73
72
  /** */
74
73
  export function messageType(msgType: string, message: any) {
75
- if (msgType === MESSAGE_TYPE_DATE) {
76
- if (message.headerDate && message.headerDate !== '') {
77
- return true;
78
- }
79
- return false;
80
- }
74
+
81
75
  if (msgType === MESSAGE_TYPE_INFO) {
82
76
  return isInfo(message);
83
77
  }
@@ -100,6 +100,9 @@ export function contactsRef(tenant) {
100
100
  // return labelDays;
101
101
  // }
102
102
 
103
+ /**
104
+ * @deprecated
105
+ */
103
106
  export function setHeaderDate(translate, timestamp): string {
104
107
  // const LABEL_TODAY = translate.get('LABEL_TODAY');
105
108
  // const LABEL_TOMORROW = translate.get('LABEL_TOMORROW');
@@ -0,0 +1,27 @@
1
+ {
2
+ "chatEngine": "mqtt",
3
+ "uploadEngine": "native",
4
+ "pushEngine":"mqtt",
5
+ "fileUploadAccept":"*/*",
6
+ "logLevel": "debug",
7
+ "remoteTranslationsUrl": "https://api.tiledesk.com/v3/",
8
+ "firebaseConfig": {
9
+ "apiKey": "AIzaSyDKfdKrlD7AYcbQ-U-xxgV-b3FUQ4xt7NM",
10
+ "authDomain": "tiledesk-prod-v2.firebaseapp.com",
11
+ "databaseURL": "https://tiledesk-prod-v2.firebaseio.com",
12
+ "projectId": "tiledesk-prod-v2",
13
+ "storageBucket": "tiledesk-prod-v2.appspot.com",
14
+ "messagingSenderId": "92907897826",
15
+ "appId": "1:92907897826:web:f255664014a7cc14ee2fbb",
16
+ "tenant": "tilechat"
17
+ },
18
+ "chat21Config": {
19
+ "appId": "tilechat",
20
+ "MQTTendpoint": "wss://eu.rtmv3.tiledesk.com/mqws/ws",
21
+ "APIendpoint": "https://eu.rtmv3.tiledesk.com/chatapi/api",
22
+ "log": true
23
+ },
24
+ "apiUrl": "https://api.tiledesk.com/v3/",
25
+ "baseImageUrl": "https://eu.rtmv3.tiledesk.com/api/",
26
+ "authPersistence": "LOCAL"
27
+ }
@@ -15,7 +15,6 @@ export class MessageModel {
15
15
  public metadata: any,
16
16
  public text: any,
17
17
  public timestamp: any,
18
- public headerDate: string,
19
18
  public type: string,
20
19
  public attributes: any,
21
20
  public channel_type: string,
@@ -34,7 +33,6 @@ export class MessageModel {
34
33
  // metadata: this.metadata,
35
34
  // text: this.text,
36
35
  // timestamp: firebase.database.ServerValue.TIMESTAMP,
37
- // // headerDate: this.headerDate,
38
36
  // type: this.type,
39
37
  // attributes: this.attributes,
40
38
  // channel_type: this.channel_type