@chat21/chat21-web-widget 5.0.51 → 5.0.52-rc.1

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.51",
4
+ "version": "5.0.52-rc.1",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -108,6 +108,7 @@
108
108
  background-position: inherit;
109
109
  background-attachment: fixed;
110
110
  background-size: cover;
111
+ opacity: 0.4;
111
112
  }
112
113
 
113
114
  .row {
@@ -101,12 +101,13 @@ export class MQTTConversationHandler extends ConversationHandlerService {
101
101
  }
102
102
  this.chat21Service.chatClient.lastMessages(this.conversationWith, (err, messages) => {
103
103
  if (!err) {
104
+ this.logger.log('[MQTTConversationHandlerSERVICE] message lastMessages:', messages);
104
105
  messages.forEach(message => {
105
106
  // this.addedMessage(msg);
106
107
  const msg: MessageModel = message;
107
108
  msg.uid = message.message_id;
108
- if (msg.attributes && msg.attributes.commands) {
109
- // this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', msg)
109
+ if (msg.attributes && msg.attributes.commands ) {
110
+ this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', this.messages)
110
111
  this.addCommandMessage(msg)
111
112
  } else {
112
113
  // this.logger.debug('[MQTTConversationHandlerSERVICE] NOT splitted message::::', msg)
@@ -117,11 +118,16 @@ export class MQTTConversationHandler extends ConversationHandlerService {
117
118
  });
118
119
  const handler_message_added = this.chat21Service.chatClient.onMessageAddedInConversation(
119
120
  this.conversationWith, (message, topic) => {
120
- this.logger.log('[MQTTConversationHandlerSERVICE] message added:', message, 'on topic:', topic);
121
+ this.logger.log('[MQTTConversationHandlerSERVICE] message added:', message, 'on topic:', topic, this.messages);
121
122
  // this.addedMessage(msg);
122
123
  const msg: MessageModel = message;
123
124
  msg.uid = message.message_id;
124
125
 
126
+ //escape command message is already is in list checking by parendUid
127
+ if(this.messages.filter(message=> message.attributes['parentUid'] === msg.uid).length > 0){
128
+ return;
129
+ }
130
+
125
131
  if (msg.attributes && msg.attributes.commands) {
126
132
  this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', msg)
127
133
  this.addCommandMessage(msg)
@@ -133,7 +139,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
133
139
  const handler_message_updated = this.chat21Service.chatClient.onMessageUpdatedInConversation(
134
140
  this.conversationWith, (message, topic) => {
135
141
  this.logger.log('[MQTTConversationHandlerSERVICE] message updated:', message, 'on topic:', topic);
136
- this.updatedMessageStatus(message);
142
+ this.changed(message);
137
143
  });
138
144
  }
139
145
 
@@ -225,7 +231,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
225
231
  /** */
226
232
  private addedMessage(messageSnapshot: MessageModel) {
227
233
  const msg = this.messageGenerate(messageSnapshot);
228
-
234
+ console.log('messageeee', msg)
229
235
  let isInfoMessage = messageType(MESSAGE_TYPE_INFO, msg)
230
236
  if(isInfoMessage){
231
237
  this.messageInfo.next(msg)
@@ -253,7 +259,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
253
259
 
254
260
 
255
261
  /** */
256
- private updatedMessageStatus(patch: any) {
262
+ private changed(patch: any) {
257
263
  if(messageType(MESSAGE_TYPE_INFO, patch) ){
258
264
  return;
259
265
  }
@@ -400,18 +406,13 @@ export class MQTTConversationHandler extends ConversationHandlerService {
400
406
  this.logger.log('[MQTTConversationHandlerSERVICE] updateMessageStatusReceived', msg);
401
407
  if (msg['status'] < MSG_STATUS_RECEIVED) {
402
408
  this.logger.log('[MQTTConversationHandlerSERVICE] status ', msg['status'], ' < (RECEIVED:200)', MSG_STATUS_RECEIVED);
409
+ let uid = msg.uid
410
+ msg.attributes.commands? uid = msg.attributes.parentUid: null
403
411
  if (msg.sender !== this.loggedUser.uid && msg.status < MSG_STATUS_RECEIVED) {
404
412
  this.logger.log('[MQTTConversationHandlerSERVICE] updating message with status received');
405
- this.chat21Service.chatClient.updateMessageStatus(msg.message_id, this.conversationWith, MSG_STATUS_RECEIVED, null);
413
+ this.chat21Service.chatClient.updateMessageStatus(uid, this.conversationWith, MSG_STATUS_RECEIVED, null);
406
414
  }
407
415
  }
408
- // if (msg.status < MSG_STATUS_RECEIVED) {
409
- // if (msg.sender !== this.loggedUser.uid && msg.status < MSG_STATUS_RECEIVED) {
410
- // const urlNodeMessagesUpdate = this.urlNodeFirebase + '/' + msg.uid;
411
- // this.logger.log('AGGIORNO STATO MESSAGGIO', urlNodeMessagesUpdate);
412
- // firebase.database().ref(urlNodeMessagesUpdate).update({ status: MSG_STATUS_RECEIVED });
413
- // }
414
- // }
415
416
  }
416
417
 
417
418
  /**
package/src/launch.js CHANGED
@@ -161,14 +161,73 @@ function loadIframe(tiledeskScriptBaseLocation) {
161
161
  });
162
162
  /**** END EVENST ****/
163
163
 
164
- // ifrm.srcdoc = srcTileDesk
165
164
  iDiv.appendChild(ifrm);
165
+
166
+ // buildIframeDOM(ifrm)
167
+ // ifrm.contentWindow.document.open();
168
+ // ifrm.document.srcdoc = srcTileDesk;
169
+ // ifrm.srcdoc = srcTileDesk
166
170
  ifrm.contentWindow.document.open();
167
171
  ifrm.contentWindow.document.write(srcTileDesk);
168
172
  ifrm.contentWindow.document.close();
169
173
 
170
174
  }
171
175
 
176
+ function buildIframeDOM(iframe){
177
+
178
+ var meta = document.createElement('meta');
179
+ meta.setAttribute('charset', 'utf-8')
180
+ var meta_2 = document.createElement('meta')
181
+ meta_2.setAttribute('name', 'viewport')
182
+ meta_2.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0')
183
+ var title = document.createElement('title')
184
+ title.title = 'Tilechat Widget'
185
+ var base = document.createElement('base')
186
+ base.setAttribute('href', './')
187
+ var link_1 = document.createElement('link')
188
+ link_1.setAttribute('rel', 'icon')
189
+ link_1.setAttribute('type', 'image/x-icon')
190
+ link_1.setAttribute('href', 'favicon.ico')
191
+ var link_2 = document.createElement('link')
192
+ link_2.setAttribute('rel', 'stylesheet')
193
+ link_2.setAttribute('type', 'text/css')
194
+ link_2.setAttribute('href', tiledeskScriptBaseLocation + '/assets/styles/tiledesk_v1.scss')
195
+ link_2.setAttribute('media','all')
196
+
197
+
198
+ let head = iframe.contentWindow.document.getElementsByTagName('head')[0]
199
+ head.appendChild(meta)
200
+ head.appendChild(meta_2)
201
+ head.appendChild(title)
202
+ head.appendChild(base)
203
+ head.appendChild(link_1)
204
+ head.appendChild(link_2)
205
+
206
+ var script_1 = document.createElement('script')
207
+ script_1.setAttribute('type','text/javascript')
208
+ script_1.setAttribute('src',tiledeskScriptBaseLocation + '/runtime.js')
209
+ var script_2 = document.createElement('script')
210
+ script_2.setAttribute('type','text/javascript')
211
+ script_2.setAttribute('src',tiledeskScriptBaseLocation + '/polyfills.js')
212
+ var script_3 = document.createElement('script')
213
+ script_3.setAttribute('type','text/javascript')
214
+ script_3.setAttribute('src',tiledeskScriptBaseLocation + '/styles.css')
215
+ var script_4 = document.createElement('script')
216
+ script_4.setAttribute('type','text/javascript')
217
+ script_4.setAttribute('src',tiledeskScriptBaseLocation + '/vendor.js')
218
+ var script_5 = document.createElement('script')
219
+ script_5.setAttribute('type','text/javascript')
220
+ script_5.setAttribute('src',tiledeskScriptBaseLocation + '/main.js')
221
+
222
+ let body= iframe.contentWindow.document.getElementsByTagName('body')[0]
223
+ body.appendChild(document.createElement('chat-root'))
224
+ body.appendChild(script_1)
225
+ body.appendChild(script_2)
226
+ body.appendChild(script_3)
227
+ body.appendChild(script_4)
228
+ body.appendChild(script_5)
229
+ }
230
+
172
231
 
173
232
  function initAysncEvents() {
174
233
  console.log('INIT ASYNC EVENTS')