@subiz/widget-v4 4.1.191 → 4.1.196

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.
Files changed (120) hide show
  1. package/assets/less/chatbox.less +0 -1
  2. package/assets/less/message.less +71 -4
  3. package/compiled_src/chatbox/Event.js +37 -6
  4. package/compiled_src/chatbox/Events.js +20 -0
  5. package/compiled_src/chatbox/FileAttachments.js +36 -4
  6. package/compiled_src/chatbox/ImageAttachments.js +31 -4
  7. package/compiled_src/chatbox/QuoteMessage.js +99 -0
  8. package/compiled_src/chatbox/Rating.js +4 -0
  9. package/compiled_src/chatbox/TextMessage.js +49 -4
  10. package/compiled_src/chatbox/Widget.js +43 -1
  11. package/compiled_src/store/api.js +2 -0
  12. package/compiled_src/store/store.js +45 -3
  13. package/compiled_src/util/common.js +13 -1
  14. package/dist/127.js +273 -0
  15. package/dist/132.js +2802 -0
  16. package/dist/185.js +1827 -0
  17. package/dist/19b9941db90.127.js +1 -0
  18. package/dist/19b9941db90.132.js +1 -0
  19. package/dist/19b9941db90.185.js +1 -0
  20. package/dist/19b9941db90.27.js +1 -0
  21. package/dist/19b9941db90.278.js +1 -0
  22. package/dist/19b9941db90.339.js +1 -0
  23. package/dist/19b9941db90.459.js +1 -0
  24. package/dist/19b9941db90.490.js +1 -0
  25. package/dist/19b9941db90.74.js +1 -0
  26. package/dist/19b9941db90.997.js +1 -0
  27. package/dist/19b9941db90.app.js +1 -0
  28. package/dist/19b9941db90.chat.html +1 -0
  29. package/dist/19b9941db90.chat.js +1 -0
  30. package/dist/19b9941db90.form.html +1 -0
  31. package/dist/19b9941db90.form.js +1 -0
  32. package/dist/19b9941db90.index.html +72 -0
  33. package/dist/19b9941db90.library.html +72 -0
  34. package/dist/19b9941db90.library.js +1 -0
  35. package/dist/19b9941db90.preview.html +759 -0
  36. package/dist/19b9941db90.preview.js +1 -0
  37. package/dist/19b9941db90.webview.js +1 -0
  38. package/dist/27.js +35 -0
  39. package/dist/459.js +35 -0
  40. package/dist/490.js +305 -0
  41. package/dist/74.js +372 -0
  42. package/dist/997.js +35 -0
  43. package/dist/HASH +1 -0
  44. package/dist/assets/img/Facebook.64607ec.png +0 -0
  45. package/dist/assets/img/Zalo.6845707.png +0 -0
  46. package/dist/assets/img/award1a.1a58e10.png +0 -0
  47. package/dist/assets/img/award3a.3b74423.png +0 -0
  48. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  49. package/dist/assets/img/award5.39eb7ae.png +0 -0
  50. package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
  51. package/dist/assets/img/caret.998eb8f.svg +1 -0
  52. package/dist/assets/img/convos_empty.2353007.svg +72 -0
  53. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  54. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  55. package/dist/assets/img/done_gray.d7e8203.svg +4 -0
  56. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  57. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  58. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  59. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  60. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  61. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  62. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  63. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  64. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  65. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  66. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  67. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  68. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  69. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  70. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  71. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  72. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  73. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  74. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  75. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  76. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  77. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  78. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  79. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  80. package/dist/assets/img/empty.29bed2d.svg +23 -0
  81. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  82. package/dist/assets/img/examplte_logo.f86535f.svg +1 -0
  83. package/dist/assets/img/external-link.90577cc.svg +1 -0
  84. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  85. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  86. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  87. package/dist/assets/img/image_default.be0698b.png +0 -0
  88. package/dist/assets/img/info.ebce7ea.svg +1 -0
  89. package/dist/assets/img/loader.37000a7.svg +1 -0
  90. package/dist/assets/img/loading_static.a27f0ac.svg +10 -0
  91. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  92. package/dist/assets/img/main-service2.9b99549.png +0 -0
  93. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  94. package/dist/assets/img/package.8d37d0f.svg +5 -0
  95. package/dist/assets/img/package_fade.763c001.svg +1 -0
  96. package/dist/assets/img/rating--average.1ea492c.svg +12 -0
  97. package/dist/assets/img/rating--great.e3d712e.svg +16 -0
  98. package/dist/assets/img/rating--poor.2938a25.svg +12 -0
  99. package/dist/assets/img/search.f9705ff.svg +1 -0
  100. package/dist/assets/img/send.6db52a9.svg +3 -0
  101. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  102. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  103. package/dist/assets/img/stars_v2.79cf728.png +0 -0
  104. package/dist/assets/img/subiz-mono.8fbc067.svg +3 -0
  105. package/dist/assets/img/x.26fdfa3.svg +5 -0
  106. package/dist/malicious-app.js +17 -0
  107. package/dist/screenshoot.html +7 -0
  108. package/dist/screenshoot.js +13026 -0
  109. package/package.json +8 -8
  110. package/src/chatbox/Event.js +48 -7
  111. package/src/chatbox/Events.js +21 -1
  112. package/src/chatbox/FileAttachments.js +31 -4
  113. package/src/chatbox/ImageAttachments.js +26 -3
  114. package/src/chatbox/QuoteMessage.js +94 -0
  115. package/src/chatbox/Rating.js +5 -0
  116. package/src/chatbox/TextMessage.js +50 -2
  117. package/src/chatbox/Widget.js +52 -0
  118. package/src/store/api.js +3 -0
  119. package/src/store/store.js +51 -2
  120. package/src/util/common.js +19 -1
@@ -93,7 +93,6 @@ body div#sbz92 {
93
93
 
94
94
  font-family: @font-family-sans-serif;
95
95
  font-size: @font-size-base;
96
- line-height: 1.25;
97
96
 
98
97
  -webkit-box-sizing: border-box; // Safari/Chrome, other WebKit
99
98
  -moz-box-sizing: border-box; // Firefox, other Gecko
@@ -25,6 +25,10 @@
25
25
  justify-content: center;
26
26
  }
27
27
 
28
+ .convo-event {
29
+ position: relative;
30
+ }
31
+
28
32
  .convo-event-time {
29
33
  text-align: center;
30
34
  margin-top: 15px;
@@ -111,10 +115,23 @@
111
115
  //padding: 12px;
112
116
  }
113
117
 
118
+ .message-text--user.just-focused {
119
+ box-shadow: 0 0 0 2px #000;
120
+ }
121
+
122
+ .message-text--agent.just-focused {
123
+ box-shadow: 0 0 0 2px #000;
124
+ }
125
+
114
126
  .message-text--user.message-user--error {
115
127
  background-color: @red;
116
128
  }
117
129
 
130
+ .message-text--agent.message-text--deleted {
131
+ opacity: 0.7;
132
+ font-style: italic;
133
+ }
134
+
118
135
  .message-text--agent {
119
136
  line-height: 1.5;
120
137
  white-space: pre-wrap;
@@ -125,7 +142,7 @@
125
142
  }
126
143
 
127
144
  .message-agent.message-text--agent {
128
- max-width: unset;
145
+ max-width: 100%;
129
146
  margin-top: 0;
130
147
  }
131
148
 
@@ -817,8 +834,7 @@ a.product_attachment__title {
817
834
  }
818
835
 
819
836
  .message-event-actions-static {
820
- visibility: hidden;
821
- display: flex;
837
+ display: none;
822
838
  margin-top: 2px;
823
839
  border: none;
824
840
  padding: 0;
@@ -831,7 +847,11 @@ a.product_attachment__title {
831
847
  }
832
848
 
833
849
  .message-event-actions-static {
834
- visibility: visible;
850
+ display: flex;
851
+ position: absolute;
852
+ bottom: -30px;
853
+ left: 0;
854
+ z-index: 2;
835
855
  }
836
856
 
837
857
  .message-event-action-btn {
@@ -999,3 +1019,50 @@ a.product_attachment__title {
999
1019
  background-color: rgba(255, 255, 255, 0.08);
1000
1020
  }
1001
1021
  }
1022
+
1023
+ .message-quote {
1024
+ padding: 6px 10px;
1025
+ border-left: 3px solid @primary-color;
1026
+ background-color: #dfdfdf;
1027
+ border-top-left-radius: 0;
1028
+ border-bottom-left-radius: 0;
1029
+ margin-bottom: 8px;
1030
+ max-width: 100%;
1031
+ }
1032
+
1033
+ .message-quote-title {
1034
+ font-weight: 600;
1035
+ font-size: 14px;
1036
+ text-overflow: ellipsis;
1037
+ white-space: nowrap;
1038
+ overflow: hidden;
1039
+ }
1040
+
1041
+ .message-quote-content {
1042
+ opacity: 0.7;
1043
+ .color(@secondary-color);
1044
+ font-size: 14px;
1045
+ text-overflow: ellipsis;
1046
+ white-space: nowrap;
1047
+ overflow: hidden;
1048
+ }
1049
+
1050
+ .message-quote-inner-img {
1051
+ width: 36px;
1052
+ height: 36px;
1053
+ object-fit: cover;
1054
+ }
1055
+
1056
+ .message-quote-inner {
1057
+ margin-left: 15px;
1058
+ flex: 1;
1059
+ overflow: hidden;
1060
+ }
1061
+
1062
+ .image-attachment.just-focused {
1063
+ box-shadow: 0 0 0 2px #000;
1064
+ }
1065
+
1066
+ .file-attachment.just-focused {
1067
+ box-shadow: 0 0 0 2px #000;
1068
+ }
@@ -30,6 +30,20 @@ const LoadOrderAttachments = () => Promise.resolve().then(() => _interopRequireW
30
30
  class Event extends _common.Com {
31
31
  constructor(props) {
32
32
  super(props);
33
+ _defineProperty(this, "focusSourceEventFromQuote", ev => {
34
+ let $textMessage = this.textMessageRef.current;
35
+ if ($textMessage && typeof $textMessage.focusSourceEventFromQuote === 'function') {
36
+ $textMessage.focusSourceEventFromQuote(ev);
37
+ }
38
+ let $fileAttachment = this.fileAttachmentRef.current;
39
+ if ($fileAttachment && typeof $fileAttachment.focusSourceEventFromQuote === 'function') {
40
+ $fileAttachment.focusSourceEventFromQuote(ev);
41
+ }
42
+ let $imageAttachment = this.imageAttachmentRef.current;
43
+ if ($imageAttachment && typeof $imageAttachment.focusSourceEventFromQuote === 'function') {
44
+ $imageAttachment.focusSourceEventFromQuote(ev);
45
+ }
46
+ });
33
47
  _defineProperty(this, "resendMessage", () => {
34
48
  let cid = _index.default.convoOfEv(this.props.event.ev);
35
49
  const message = _index.default.get(this.props.event, 'ev.data.message');
@@ -42,6 +56,9 @@ class Event extends _common.Com {
42
56
  this.state = {
43
57
  pongs: _index.default.get(this.props.event, 'ev.data.message.pongs') || []
44
58
  };
59
+ this.textMessageRef = (0, _preact.createRef)();
60
+ this.fileAttachmentRef = (0, _preact.createRef)();
61
+ this.imageAttachmentRef = (0, _preact.createRef)();
45
62
  }
46
63
  render() {
47
64
  var ev = _index.default.get(this.props.event, 'ev', {});
@@ -257,20 +274,26 @@ class Event extends _common.Com {
257
274
  let wrappercls = 'agent-convo-event-wrapper';
258
275
  if (hasForm) wrappercls += ' full';
259
276
  return (0, _preact.h)("div", {
260
- class: "convo-event agent-message"
277
+ class: "convo-event agent-message",
278
+ "data-ev-id": ev.id
261
279
  }, $sender, (0, _preact.h)("div", {
262
280
  class: wrappercls
263
281
  }, (0, _preact.h)("div", {
264
282
  class: innercls
265
283
  }, (0, _preact.h)(_TextMessage.default, {
284
+ ref: this.textMessageRef,
285
+ onFocusSourceEventFromQuote: this.props.onFocusSourceEventFromQuote,
266
286
  showTime: this.props.event.show_time,
267
287
  isLast: this.props.isLast,
268
288
  store: this.props.store,
289
+ t: this.props.t,
269
290
  ev: ev,
270
291
  onLink: this.props.onLink
271
292
  }), (0, _preact.h)(_ImageAttachments.default, {
293
+ ref: this.imageAttachmentRef,
272
294
  store: this.props.store,
273
- ev: ev
295
+ ev: ev,
296
+ focusSourceEventFromQuote: this.props.focusSourceEventFromQuote
274
297
  }), (0, _preact.h)(_AudioAttachments.default, {
275
298
  store: this.props.store,
276
299
  ev: ev
@@ -278,8 +301,10 @@ class Event extends _common.Com {
278
301
  store: this.props.store,
279
302
  ev: ev
280
303
  }), (0, _preact.h)(_FileAttachments.default, {
304
+ ref: this.fileAttachmentRef,
281
305
  store: this.props.store,
282
- ev: ev
306
+ ev: ev,
307
+ focusSourceEventFromQuote: this.props.focusSourceEventFromQuote
283
308
  }), (0, _preact.h)(_ButtonAttachments.default, {
284
309
  store: this.props.store,
285
310
  ev: ev,
@@ -345,17 +370,20 @@ class Event extends _common.Com {
345
370
  }, msg));
346
371
  }
347
372
  return (0, _preact.h)("div", {
348
- class: "convo-event user-message"
373
+ class: "convo-event user-message",
374
+ "data-ev-id": ev.id
349
375
  }, $sender, (0, _preact.h)("div", {
350
376
  class: "message-user__container"
351
377
  }, $dot, (0, _preact.h)(_TextMessage.default, {
378
+ ref: this.textMessageRef,
352
379
  store: this.props.store,
353
380
  ev: ev,
354
381
  refresh: this.state.refresh,
355
382
  onLink: this.props.onLink
356
383
  }), (0, _preact.h)(_ImageAttachments.default, {
357
384
  store: this.props.store,
358
- ev: ev
385
+ ev: ev,
386
+ ref: this.imageAttachmentRef
359
387
  }), (0, _preact.h)(_AudioAttachments.default, {
360
388
  store: this.props.store,
361
389
  ev: ev
@@ -364,7 +392,8 @@ class Event extends _common.Com {
364
392
  ev: ev
365
393
  }), (0, _preact.h)(_FileAttachments.default, {
366
394
  store: this.props.store,
367
- ev: ev
395
+ ev: ev,
396
+ ref: this.fileAttachmentRef
368
397
  }), (0, _preact.h)(_ButtonAttachments.default, {
369
398
  store: this.props.store,
370
399
  ev: ev,
@@ -438,6 +467,8 @@ class Event extends _common.Com {
438
467
  let cid = _index.default.get(this.props.event.ev, 'data.message.conversation_id', '');
439
468
  if (cid.startsWith('cslight')) return null;
440
469
  let ev = _index.default.get(this.props.event, 'ev') || {};
470
+ let isDeleted = _index.default.get(ev, 'data.message.deleted');
471
+ if (isDeleted) return;
441
472
  let pongs = _index.default.get(ev, 'data.message.pongs') || [];
442
473
  let hasLike = this.hasLike();
443
474
  let hasDislike = this.hasDislike();
@@ -11,14 +11,24 @@ var _spinner = _interopRequireDefault(require("./spinner.js"));
11
11
  var _common = require("../common.js");
12
12
  var _preact = require("preact");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
17
  const convoemptyimg = require('../../assets/img/convos_empty.svg');
15
18
  class Events extends _common.Com {
16
19
  constructor(props) {
17
20
  super(props);
21
+ _defineProperty(this, "onFocusSourceEventFromQuote", ev => {
22
+ let ref = this.evRefs[ev.id];
23
+ if (ref) {
24
+ ref.focusSourceEventFromQuote(ev);
25
+ }
26
+ });
18
27
  this.props.store.onUpdate(this, _ => this.forceUpdate());
19
28
  this.props.store.onConvoEvent(this, ev => this.onEvent(ev));
20
29
  this.loadConvo();
21
30
  this.refBody = null;
31
+ this.evRefs = {};
22
32
  this.checkAndSeen = _index.default.throttle(() => {
23
33
  if (this.props.isShow && this.isBottom() && this.props.store.browserVisibility === 'visible' && document.hasFocus()) {
24
34
  this.props.store.seenConvo(this.props.cid);
@@ -60,10 +70,18 @@ class Events extends _common.Com {
60
70
  });
61
71
  }, 5000);
62
72
  });
73
+ this.props.store.onMessageUpdated(this, async ev => {
74
+ if (_index.default.convoOfEv(ev) !== this.props.cid) return;
75
+ await this.props.store.reloadConvoEvents(this.props.cid);
76
+ this.forceUpdate();
77
+ });
63
78
  }
64
79
  componentDidUpdate(prevProps) {
65
80
  if (prevProps.cid !== this.props.cid) this.loadConvo();
66
81
  }
82
+ setEventChildRef(ele, id) {
83
+ this.evRefs[id] = ele;
84
+ }
67
85
  ShowTyping() {
68
86
  this.setState({
69
87
  isShowTyping: true,
@@ -142,6 +160,8 @@ class Events extends _common.Com {
142
160
  onFormSubmit: this.props.onFormSubmit,
143
161
  onSend: this.props.onSend,
144
162
  onPostback: this.props.onPostback,
163
+ onFocusSourceEventFromQuote: this.onFocusSourceEventFromQuote,
164
+ ref: ele => this.setEventChildRef(ele, ev.ev.id),
145
165
  event: ev,
146
166
  t: this.props.t,
147
167
  key: ev.ev.id
@@ -9,23 +9,34 @@ var _common = require("../common.js");
9
9
  var _preact = require("preact");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  class FileAttachments extends _common.Com {
12
+ constructor(props) {
13
+ super(props);
14
+ this.state = {
15
+ focusedIdx: -1
16
+ };
17
+ }
12
18
  render() {
13
19
  var byType = _index.default.get(this.props.ev, 'by.type', 'agent');
14
20
  if (byType !== 'user') byType = 'agent';
15
21
  var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
16
22
  var files = [];
17
- _index.default.each(attachments, att => {
23
+ _index.default.each(attachments, (att, idx) => {
18
24
  if (!att) return;
19
25
  if (!att.url && !att._file) return;
20
26
  if (!_index.default.includes(att.mimetype, 'video') && !_index.default.includes(att.mimetype, 'audio') && !_index.default.includes(att.mimetype, 'image') && att.type !== 'button' && att.type !== 'quick_replies' && att.type !== 'form' && att.type !== 'form_submit') {
21
- files.push(att);
27
+ files.push({
28
+ ...att,
29
+ _true_idx: idx
30
+ });
22
31
  }
23
32
  });
24
33
  if (files.length === 0) return null;
25
- var $files = _index.default.map(files, (file, index) => {
34
+ let $files = _index.default.map(files, (file, index) => {
35
+ let cls = `file-attachment file-attachment--${byType}`;
36
+ if (file._true_idx === this.state.focusedIdx) cls += ` just-focused`;
26
37
  return (0, _preact.h)("div", {
27
38
  key: index,
28
- class: `file-attachment file-attachment--${byType}`
39
+ class: cls
29
40
  }, (0, _preact.h)("a", {
30
41
  class: "file-attachment--link",
31
42
  href: this.props.store.replaceFileUrl(file.url),
@@ -40,5 +51,26 @@ class FileAttachments extends _common.Com {
40
51
  class: `message-${byType}`
41
52
  }, $files);
42
53
  }
54
+ focusSourceEventFromQuote(ev) {
55
+ if (ev.id !== this.props.ev.id) return;
56
+ let fields = _index.default.get(ev, 'data.message.fields') || [];
57
+ let attachmentIndexField = _index.default.find(fields, f => f.key === 'attachment_index');
58
+ let attachmentIndex = _index.default.get(attachmentIndexField, 'value');
59
+ try {
60
+ attachmentIndex = JSON.parse(attachmentIndex);
61
+ } catch (err) {
62
+ attachmentIndex = undefined;
63
+ }
64
+ if (attachmentIndex === undefined) return;
65
+ this.setState({
66
+ focusedIdx: attachmentIndex
67
+ });
68
+ if (this.focusTimeout) clearTimeout(this.focusTimeout);
69
+ this.focusTimeout = setTimeout(() => {
70
+ this.setState({
71
+ focusedIdx: -1
72
+ });
73
+ }, 3000);
74
+ }
43
75
  }
44
76
  exports.default = FileAttachments;
@@ -17,12 +17,34 @@ class ImageAttachment extends _common.Com {
17
17
  _defineProperty(this, "containerRef", (0, _preact.createRef)());
18
18
  this.setState({
19
19
  ready: false,
20
- errorIndecies: []
20
+ errorIndecies: [],
21
+ focusedIdx: -1
21
22
  });
22
23
  }
23
24
  componentDidMount() {
24
25
  this.setImageFrameDimension();
25
26
  }
27
+ focusSourceEventFromQuote(ev) {
28
+ if (ev.id !== this.props.ev.id) return;
29
+ let fields = _index.default.get(ev, 'data.message.fields') || [];
30
+ let attachmentIndexField = _index.default.find(fields, f => f.key === 'attachment_index');
31
+ let attachmentIndex = _index.default.get(attachmentIndexField, 'value');
32
+ try {
33
+ attachmentIndex = JSON.parse(attachmentIndex);
34
+ } catch (err) {
35
+ attachmentIndex = undefined;
36
+ }
37
+ if (attachmentIndex === undefined) return;
38
+ this.setState({
39
+ focusedIdx: attachmentIndex
40
+ });
41
+ if (this.focusTimeout) clearTimeout(this.focusTimeout);
42
+ this.focusTimeout = setTimeout(() => {
43
+ this.setState({
44
+ focusedIdx: -1
45
+ });
46
+ }, 3000);
47
+ }
26
48
  setImageFrameDimension() {
27
49
  const MAX_HEIGHT = 240;
28
50
  const DEFAULT_MAX_WIDTH = 267;
@@ -71,9 +93,11 @@ class ImageAttachment extends _common.Com {
71
93
  }
72
94
  let byType = _index.default.get(this.props.ev, 'by.type');
73
95
  if (byType !== 'user') byType = 'agent';
96
+ let cls = `image-attachment image-attachment--${byType}`;
97
+ if (image._true_idx === this.state.focusedIdx) cls += ' just-focused';
74
98
  if (!image.width || !image.height) {
75
99
  return (0, _preact.h)("div", {
76
- class: `image-attachment image-attachment--${byType}`
100
+ class: cls
77
101
  }, (0, _preact.h)("a", {
78
102
  href: this.props.store.replaceFileUrl(image.url),
79
103
  target: "_blank"
@@ -95,7 +119,7 @@ class ImageAttachment extends _common.Com {
95
119
  trueUrl = url;
96
120
  }
97
121
  return (0, _preact.h)("div", {
98
- class: `image-attachment image-attachment--${byType}`
122
+ class: cls
99
123
  }, (0, _preact.h)("a", {
100
124
  href: trueUrl,
101
125
  target: "_blank"
@@ -126,7 +150,10 @@ class ImageAttachment extends _common.Com {
126
150
  if (!uri.startsWith('https://') && !uri.startsWith('http://') && !uri.startsWith('content://') && !uri.startsWith('data:')) {
127
151
  att.url = this.props.store.FileURL + uri;
128
152
  }
129
- images.push(att);
153
+ images.push({
154
+ ...att,
155
+ _true_idx: i
156
+ });
130
157
  });
131
158
  if (images.length === 0) return null;
132
159
  let $images = _index.default.map(images, (image, index) => this.renderImage(image, index));
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _index = _interopRequireDefault(require("../util/index.js"));
8
+ var _block = _interopRequireDefault(require("./block.js"));
9
+ var _common = require("../common.js");
10
+ var _preact = require("preact");
11
+ var _Emoji = _interopRequireDefault(require("./Emoji.js"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
15
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
+ class QuoteMessage extends _common.Com {
17
+ constructor(...args) {
18
+ super(...args);
19
+ _defineProperty(this, "getSenderName", ev => {
20
+ let bytype = _index.default.get(ev, 'by.type');
21
+ let byid = _index.default.get(ev, 'by.display_id', _index.default.get(ev, 'by.id')) || '';
22
+ if (bytype === 'user') return _index.default.getUserDisplayName(this.props.store.matchUser());
23
+ let acc = this.props.store.matchAccount();
24
+ if (bytype === 'agent') return _index.default.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
25
+ if (byid.startsWith('at')) return _index.default.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
26
+ if (bytype === 'bot') {
27
+ let bot = this.props.store.matchBot()[byid];
28
+ if (!bot) return 'Bot';
29
+ return bot.fullname || 'Bot';
30
+ }
31
+ if (byid === 'system' || bytype === 'dummy' || bytype === 'workflow') return acc.name || 'system';
32
+ return acc.name;
33
+ });
34
+ }
35
+ render() {
36
+ let sendername = '';
37
+ let byType = _index.default.get(this.props.ev, 'by.type');
38
+ let byId = _index.default.get(this.props.ev, 'by.id');
39
+ if (byType === 'user') {
40
+ sendername = this.props.t('you');
41
+ } else {
42
+ sendername = this.getSenderName(this.props.ev);
43
+ let acc = this.props.store.matchAccount() || {};
44
+ if (_index.default.get(this.props, 'chatbox.hide_agent_profile')) sendername = acc.name;
45
+ }
46
+ let att = _index.default.get(this.props.ev, 'data.message.attachments.0');
47
+ if (att) {
48
+ let isImg = _index.default.includes(att.mimetype, 'image');
49
+ if (isImg) {
50
+ let uri = att.url;
51
+ if (!uri.startsWith('https://') && !uri.startsWith('http://') && !uri.startsWith('content://') && !uri.startsWith('data:')) {
52
+ uri = this.props.store.FileURL + uri;
53
+ }
54
+ return (0, _preact.h)("div", {
55
+ class: "message-quote d-flex",
56
+ onClick: () => this.scrollToSourceEvent(this.props.ev)
57
+ }, (0, _preact.h)("img", {
58
+ src: uri,
59
+ class: "message-quote-inner-img"
60
+ }), (0, _preact.h)("div", {
61
+ class: "message-quote-inner"
62
+ }, (0, _preact.h)("div", {
63
+ class: "message-quote-title"
64
+ }, sendername), (0, _preact.h)("div", {
65
+ class: "message-quote-content"
66
+ }, "[", this.props.t('image'), "]")));
67
+ } else {
68
+ return (0, _preact.h)("div", {
69
+ class: "message-quote",
70
+ onClick: () => this.scrollToSourceEvent(this.props.ev)
71
+ }, (0, _preact.h)("div", {
72
+ class: "message-quote-title"
73
+ }, sendername), (0, _preact.h)("div", {
74
+ class: "message-quote-content"
75
+ }, `[File] `, att.name));
76
+ }
77
+ }
78
+ let format = _index.default.get(this.props.ev, 'data.message.format', 'plaintext');
79
+ let block = _index.default.get(this.props.ev, 'data.message.block');
80
+ let text = _index.default.get(this.props.ev, 'data.message.text');
81
+ if (block) text = _index.default.blockToText(block);
82
+ return (0, _preact.h)("div", {
83
+ class: "message-quote",
84
+ onClick: () => this.scrollToSourceEvent(this.props.ev)
85
+ }, (0, _preact.h)("div", {
86
+ class: "message-quote-title"
87
+ }, sendername), (0, _preact.h)("div", {
88
+ class: "message-quote-content"
89
+ }, text));
90
+ }
91
+ scrollToSourceEvent(ev) {
92
+ let $ele = document.querySelector(`.convo-event[data-ev-id=${ev.id}]`);
93
+ if ($ele && typeof $ele.scrollIntoViewIfNeeded === 'function') {
94
+ $ele.scrollIntoViewIfNeeded();
95
+ }
96
+ this.props.onFocusSourceEventFromQuote(ev);
97
+ }
98
+ }
99
+ exports.default = QuoteMessage;
@@ -36,6 +36,10 @@ class Rating extends _common.Com {
36
36
  this.props.store.onConvoEvent(this, ev => {
37
37
  var cid = _index.default.convoOfEv(ev);
38
38
  if (cid !== this.props.cid) return;
39
+ if (!this.state.hide && ev.type === 'conversation_rated') {
40
+ this.close();
41
+ return;
42
+ }
39
43
  if (this.shoudDisplay()) this.open();
40
44
  });
41
45
  this.mouseUp = e => this.onMouseUp(e);
@@ -10,8 +10,15 @@ var _common = require("../common.js");
10
10
  var _preact = require("preact");
11
11
  var _Emoji = _interopRequireDefault(require("./Emoji.js"));
12
12
  var _time = _interopRequireDefault(require("./time.js"));
13
+ var _QuoteMessage = _interopRequireDefault(require("./QuoteMessage.js"));
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  class TextMessage extends _common.Com {
16
+ constructor(props) {
17
+ super(props);
18
+ this.state = {
19
+ focused: false
20
+ };
21
+ }
15
22
  renderTime() {
16
23
  return null;
17
24
  if (!this.props.showTime && !this.props.isLast && !this.props.isFirst) return null;
@@ -21,6 +28,27 @@ class TextMessage extends _common.Com {
21
28
  t: this.props.t
22
29
  }));
23
30
  }
31
+ focusSourceEventFromQuote(ev) {
32
+ if (ev.id !== this.props.ev.id) return;
33
+ let fields = _index.default.get(ev, 'data.message.fields') || [];
34
+ let attachmentIndexField = _index.default.find(fields, f => f.key === 'attachment_index');
35
+ let attachmentIndex = _index.default.get(attachmentIndexField, 'value');
36
+ try {
37
+ attachmentIndex = JSON.parse(attachmentIndex);
38
+ } catch (err) {
39
+ attachmentIndex = undefined;
40
+ }
41
+ if (attachmentIndex !== undefined) return;
42
+ this.setState({
43
+ focused: true
44
+ });
45
+ if (this.focusTimeout) clearTimeout(this.focusTimeout);
46
+ this.focusTimeout = setTimeout(() => {
47
+ this.setState({
48
+ focused: false
49
+ });
50
+ }, 3000);
51
+ }
24
52
  render() {
25
53
  var format = _index.default.get(this.props.ev, 'data.message.format', 'plaintext');
26
54
  let block = _index.default.get(this.props.ev, 'data.message.block');
@@ -62,12 +90,29 @@ class TextMessage extends _common.Com {
62
90
  return tag.text;
63
91
  });
64
92
  if (_index.default.size(tags) === 0) return null;
65
- if (byType === 'agent') return (0, _preact.h)("div", {
66
- class: "message-agent message-text--agent",
67
- title: t
68
- }, tags, this.renderTime());
93
+ let isDeleted = _index.default.get(this.props.ev, 'data.message.deleted');
94
+ let attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
95
+ let quote = _index.default.find(attachments, att => att.type === 'quote');
96
+ if (byType === 'agent') {
97
+ let cls = 'message-agent message-text--agent';
98
+ if (isDeleted) {
99
+ tags = this.props.t('recalled_message');
100
+ cls += ' message-text--deleted';
101
+ }
102
+ if (this.state.focused) cls += ' just-focused';
103
+ return (0, _preact.h)("div", {
104
+ class: cls,
105
+ title: t
106
+ }, quote && (0, _preact.h)(_QuoteMessage.default, {
107
+ ev: _index.default.get(quote, 'quote'),
108
+ t: this.props.t,
109
+ store: this.props.store,
110
+ onFocusSourceEventFromQuote: this.props.onFocusSourceEventFromQuote
111
+ }), tags, this.renderTime());
112
+ }
69
113
  let msgcls = 'message-user message-text--user';
70
114
  if (this.props.ev._error) msgcls += ' message-user--error';
115
+ if (this.state.focused) msgcls += ' just-focused';
71
116
  return (0, _preact.h)("div", {
72
117
  class: msgcls,
73
118
  title: t
@@ -32,6 +32,43 @@ class Widget extends _common.Com {
32
32
  constructor(props) {
33
33
  super(props);
34
34
  _defineProperty(this, "msgInput", (0, _preact.createRef)());
35
+ _defineProperty(this, "findMissingRTMessage", async started => {
36
+ let messageSentDict = this.props.store.listAgentRealtimeMessageSent();
37
+ let res1 = await this.props.store.sbzListConversations();
38
+ let conversions = _index.default.get(res1, 'body.conversations') || [];
39
+ let cids = _index.default.map(conversions, convo => convo.id);
40
+ let promises = _index.default.map(cids, cid => this.props.store.sbzListMessages(cid));
41
+ let msgReses = await Promise.all(promises);
42
+ _index.default.map(msgReses, msgRes => {
43
+ let messages = _index.default.get(msgRes, 'body') || [];
44
+ _index.default.map(messages, ev => {
45
+ if (ev.created < started) return;
46
+ if (ev.type !== 'message_sent') return;
47
+ if (_index.default.get(ev, 'by.type') === 'user') return;
48
+ console.log('check ev pass condition', ev);
49
+ if (!messageSentDict[ev.id]) {
50
+ this.props.store.sendBugReport('[WIDGET ' + accid + '] Missing agent message sent evid ' + ev.id + ', cid ' + _index.default.convoOfEv(ev));
51
+ }
52
+ });
53
+ });
54
+ });
55
+ _defineProperty(this, "debugRTAgentMessageSent", async () => {
56
+ try {
57
+ let debugAccountIds = this.props.store.matchDebugAccountIds();
58
+ let accid = _index.default.get(this.props.store.matchAccount(), 'id');
59
+ if (!debugAccountIds.includes(accid)) return;
60
+ console.log('START check RT agent message with BE source');
61
+ let started = Date.now();
62
+ this.findMissingRTMessage(started);
63
+ for (let i = 0; i < 100_000; i++) {
64
+ await _index.default.sleep(120_000);
65
+ console.log('LOOP check RT agent message with BE source', i);
66
+ this.findMissingRTMessage(started);
67
+ }
68
+ } catch (err) {
69
+ this.props.store.sendBugReport(`debugRTAgentMessageSent ERROR ${err.stack}`);
70
+ }
71
+ });
35
72
  _defineProperty(this, "formMounted", form => {
36
73
  let formData = this.fillForm(form);
37
74
  if (form.question_required || this.state.quickReplyMessage.text) {
@@ -65,6 +102,9 @@ class Widget extends _common.Com {
65
102
  });
66
103
  let botid = cid.split('_')[0].slice(7);
67
104
  let oldconvo = this.props.store.matchConvo(this.props.cid) || {};
105
+ let greeting_msg = _index.default.find(oldconvo.events, ev => {
106
+ return ev.type == 'message_sent' && ev.by && ev.by.type == 'bot';
107
+ });
68
108
  const {
69
109
  convo,
70
110
  error
@@ -78,7 +118,8 @@ class Widget extends _common.Com {
78
118
  bot_version: oldconvo.bot_version
79
119
  }],
80
120
  initial_by: this.props.store.matchUser().id,
81
- is_testing: oldconvo.is_testing
121
+ is_testing: oldconvo.is_testing,
122
+ greeting_message: greeting_msg
82
123
  });
83
124
  if (_creating != this._creating) return;
84
125
  if (error) {
@@ -184,6 +225,7 @@ class Widget extends _common.Com {
184
225
  componentDidMount() {
185
226
  if (!this.props.store.isMobile()) this.focusInput();
186
227
  this.updateFormDataFields();
228
+ this.debugRTAgentMessageSent();
187
229
  }
188
230
  applyMessage(text) {
189
231
  this.focusInput(text);