@subiz/widget-v4 4.1.70 → 4.1.72

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 (85) hide show
  1. package/app.js +0 -42
  2. package/assets/less/widget.less +6 -5
  3. package/assets/less/widget_header.less +5 -3
  4. package/compiled_src/chatbox/AgentsAvatar.js +102 -108
  5. package/compiled_src/chatbox/AudioAttachments.js +25 -32
  6. package/compiled_src/chatbox/ButtonAttachments.js +16 -23
  7. package/compiled_src/chatbox/Buttons.js +36 -43
  8. package/compiled_src/chatbox/ChatButton.js +5 -1
  9. package/compiled_src/chatbox/Event.js +19 -3
  10. package/compiled_src/chatbox/InfoMessage.js +2 -1
  11. package/compiled_src/chatbox/OrderAttachments.js +102 -6
  12. package/compiled_src/chatbox/PoweredBy.js +20 -27
  13. package/compiled_src/chatbox/Rating.js +1 -1
  14. package/compiled_src/chatbox/TextMessage.js +0 -14
  15. package/compiled_src/chatbox/VideoAttachments.js +1 -0
  16. package/compiled_src/chatbox/Widget.js +21 -21
  17. package/compiled_src/chatbox/time.js +46 -28
  18. package/compiled_src/lib.js +2 -2
  19. package/compiled_src/order/icon.js +2 -2
  20. package/compiled_src/order/index.js +2 -2
  21. package/compiled_src/plugin.js +2 -4
  22. package/compiled_src/store/api.js +1 -16
  23. package/compiled_src/store/store.js +1 -4
  24. package/compiled_src/util/common.js +12 -494
  25. package/compiled_src/util/index.js +0 -2
  26. package/dist/127.js +273 -0
  27. package/dist/132.js +2 -2
  28. package/dist/185.js +1885 -0
  29. package/dist/18eaf7ad0c6.127.js +1 -0
  30. package/dist/{18e74ca84ff.132.js → 18eaf7ad0c6.132.js} +1 -1
  31. package/dist/18eaf7ad0c6.185.js +1 -0
  32. package/dist/18eaf7ad0c6.278.js +1 -0
  33. package/dist/{18e74ca84ff.490.js → 18eaf7ad0c6.490.js} +1 -1
  34. package/dist/{18e74ca84ff.74.js → 18eaf7ad0c6.74.js} +1 -1
  35. package/dist/18eaf7ad0c6.app.js +1 -0
  36. package/dist/{18e74ca84ff.index.html → 18eaf7ad0c6.index.html} +1 -1
  37. package/dist/{18e74ca84ff.library.html → 18eaf7ad0c6.library.html} +1 -1
  38. package/dist/18eaf7ad0c6.library.js +1 -0
  39. package/dist/{18e74ca84ff.preview.html → 18eaf7ad0c6.preview.html} +1 -1
  40. package/dist/18eaf7ad0c6.preview.js +1 -0
  41. package/dist/18eaf7ad0c6.screenshoot.js +1 -0
  42. package/dist/18eaf7ad0c6.webview.js +1 -0
  43. package/dist/278.js +1 -1
  44. package/dist/490.js +1 -1
  45. package/dist/74.js +1 -1
  46. package/dist/HASH +1 -1
  47. package/dist/screenshoot.html +1 -1
  48. package/dist/screenshoot.js +4740 -627
  49. package/inject.js +3 -3
  50. package/package.json +6 -6
  51. package/src/chatbox/AgentsAvatar.js +118 -134
  52. package/src/chatbox/AudioAttachments.js +19 -26
  53. package/src/chatbox/ButtonAttachments.js +13 -20
  54. package/src/chatbox/Buttons.js +29 -37
  55. package/src/chatbox/ChatButton.js +6 -1
  56. package/src/chatbox/Event.js +22 -3
  57. package/src/chatbox/InfoMessage.js +11 -11
  58. package/src/chatbox/OrderAttachments.js +118 -5
  59. package/src/chatbox/PoweredBy.js +14 -22
  60. package/src/chatbox/Rating.js +1 -1
  61. package/src/chatbox/TextMessage.js +0 -14
  62. package/src/chatbox/VideoAttachments.js +1 -1
  63. package/src/chatbox/Widget.js +16 -20
  64. package/src/chatbox/time.js +54 -24
  65. package/src/lib.js +2 -2
  66. package/src/order/icon.js +2 -2
  67. package/src/order/index.js +2 -2
  68. package/src/plugin.js +4 -3
  69. package/src/store/api.js +1 -14
  70. package/src/store/store.js +1 -9
  71. package/src/util/common.js +13 -215
  72. package/src/util/index.js +0 -3
  73. package/compiled_src/util/order.js +0 -112
  74. package/dist/18e74ca84ff.278.js +0 -1
  75. package/dist/18e74ca84ff.497.js +0 -1
  76. package/dist/18e74ca84ff.app.js +0 -1
  77. package/dist/18e74ca84ff.library.js +0 -1
  78. package/dist/18e74ca84ff.preview.js +0 -1
  79. package/dist/18e74ca84ff.screenshoot.js +0 -1
  80. package/dist/18e74ca84ff.webview.js +0 -1
  81. package/dist/497.js +0 -6721
  82. package/src/util/order.js +0 -120
  83. /package/dist/{18e74ca84ff.27.js → 18eaf7ad0c6.27.js} +0 -0
  84. /package/dist/{18e74ca84ff.459.js → 18eaf7ad0c6.459.js} +0 -0
  85. /package/dist/{18e74ca84ff.997.js → 18eaf7ad0c6.997.js} +0 -0
package/app.js CHANGED
@@ -21,19 +21,6 @@ if (!VERSION) throw new Error('subiz cannot detect version')
21
21
 
22
22
  var apiV4 = new ApiV4(config.ApiURL, config.FileURL, config.RealtimeURL)
23
23
 
24
- // isV4 tells whether the website is using widget version 4.1 or not
25
- function isV4_1() {
26
- var scripts = document.getElementsByTagName('script')
27
- if (!(window._sbzq instanceof Array)) return false
28
-
29
- for (var s of scripts) {
30
- if (!s || !s.src) continue
31
- if (s.src.indexOf(config.BaseURL) !== -1) return true
32
- if (s.src.indexOf('https://widgetv4.subiz.com') !== -1) return true // old
33
- }
34
- return false
35
- }
36
-
37
24
  // isV4 tells whether the website is using widget version 4.2 or not
38
25
  function isV4_2() {
39
26
  if (window.sbz_v4) return true
@@ -50,24 +37,11 @@ function isV4_2() {
50
37
  return false
51
38
  }
52
39
 
53
- // isV2 tells whether the website is using widget version 2 or not
54
- function isV2() {
55
- if (!window._sbzq) return false
56
- var scripts = document.getElementsByTagName('script')
57
- for (var s of scripts) {
58
- if (!s || !s.src) continue
59
- if (s.src.indexOf('static.subiz.com') !== -1) return true
60
- }
61
- return false
62
- }
63
-
64
40
  // return widget version
65
41
  function detect() {
66
42
  if (window._sbzaccid) return '4.3'
67
43
  if (isV4_2()) return '4.2'
68
44
  if (window.subiz_account_id && window.subiz_account_id > 0) return '1'
69
- if (isV4_1()) return '4.1'
70
- if (isV2()) return '2'
71
45
  return undefined
72
46
  }
73
47
 
@@ -139,20 +113,6 @@ function loopTitle(laststate) {
139
113
  loopTitle()
140
114
 
141
115
  function init() {
142
- // backward compatible api
143
- if (VERSION === '1' || VERSION === '2') {
144
- console.error('DETECTED SUBIZ OUTDATED V3 EMBEDED CODE', v3accid, '. Please visit https://subiz.com.vn for support')
145
- return
146
- }
147
-
148
- if (VERSION === '1') apiV4._setAccount(window.subiz_account_id)
149
- if (VERSION === '2' || VERSION === '4.1') {
150
- let queue = window._sbzq || []
151
- if (!Array.isArray(queue)) queue = []
152
- window._sbzq = {push: callV2}
153
- queue.forEach(callV2)
154
- }
155
-
156
116
  if (VERSION === '4.2' || VERSION === '4.3') {
157
117
  let queue = (window.subiz && window.subiz.q) || []
158
118
  window.subiz = function () {
@@ -169,5 +129,3 @@ function init() {
169
129
  }
170
130
 
171
131
  init()
172
-
173
- // TODO: should print example v4_1, v4_2, v4_3, ...
@@ -451,20 +451,21 @@
451
451
  .widget-preview--btn-close {
452
452
  display: block;
453
453
  cursor: pointer;
454
+ opacity: 0.5;
454
455
  align-self: flex-start;
455
456
  background-color: #e5e5e5;
456
457
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMzMzMiIHN0cm9rZS13aWR0aD0iMi4yIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXIteCI+PGxpbmUgeDE9IjE4IiB5MT0iNiIgeDI9IjYiIHkyPSIxOCI+PC9saW5lPjxsaW5lIHgxPSI2IiB5MT0iNiIgeDI9IjE4IiB5Mj0iMTgiPjwvbGluZT48L3N2Zz4K');
457
458
  background-size: 16px 16px;
458
459
  background-repeat: no-repeat;
459
460
  background-position: center;
460
- width: 22px;
461
- height: 22px;
461
+ width: 24px;
462
+ height: 24px;
462
463
  display: block;
463
464
  border-radius: 100%;
464
465
  transition: background-color 0.2s;
465
466
 
466
467
  &:hover {
467
- background-color: #c4c4c4;
468
+ opacity: 1;
468
469
  }
469
470
  }
470
471
 
@@ -481,14 +482,14 @@
481
482
  .widget-preview--body {
482
483
  display: flex;
483
484
  padding: 15px;
484
- align-items: center;
485
485
  }
486
486
 
487
487
  .widget-preview--title {
488
488
  display: block;
489
489
  font-size: 15px;
490
- .color(gray);
490
+ .color(black);
491
491
  margin-bottom: 5px;
492
+ opacity: 0.7;
492
493
  }
493
494
 
494
495
  .widget-preview--content {
@@ -36,15 +36,16 @@
36
36
  .widget-header--title {
37
37
  white-space: nowrap;
38
38
  overflow: hidden;
39
+ font-weight: 500;
39
40
  text-overflow: ellipsis;
40
41
  font-size: 16px;
41
42
  .color(@text-color);
42
43
  }
43
44
 
44
45
  .widget-header--description {
45
- font-size: 14px;
46
+ font-size: 15px;
46
47
  white-space: pre-wrap;
47
- opacity: 0.8;
48
+ opacity: 0.7;
48
49
  flex: 1;
49
50
  .color(@text-color);
50
51
  margin-top: 2.5px;
@@ -76,6 +77,7 @@
76
77
  .widget-header--title {
77
78
  white-space: nowrap;
78
79
  overflow: hidden;
80
+ font-weight: 500;
79
81
  text-overflow: ellipsis;
80
82
  flex: 1;
81
83
  font-size: 16px;
@@ -121,7 +123,7 @@
121
123
  flex: 1;
122
124
  display: flex;
123
125
  flex-direction: column;
124
- margin-left: 7.5px;
126
+ margin-left: 10px;
125
127
  z-index: 1;
126
128
  }
127
129
 
@@ -3,142 +3,136 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = AgentsAvatar;
7
7
  var _index = _interopRequireDefault(require("../util/index.js"));
8
8
  var _common = require("../common.js");
9
9
  var _preact = require("preact");
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- class AgentsAvatar extends _common.Com {
12
- constructor(props) {
13
- super(props);
11
+ function AgentsAvatar(props) {
12
+ let accountSetting = props.plugin.chatbox;
13
+ let acc = props.store.matchAccount() || {};
14
+ var tooltippos = props.tooltipPos || 'bottom';
15
+ var mode = props.mode || 'primary';
16
+ if (accountSetting && accountSetting.hide_agent_profile) {
17
+ return (0, _preact.h)("div", {
18
+ class: `group-avatar group-avatar--${mode}`
19
+ }, (0, _preact.h)("div", {
20
+ class: "d-inline-block pos-relative",
21
+ "data-tooltip": acc.name,
22
+ "data-tooltip-position": tooltippos
23
+ }, (0, _preact.h)("img", {
24
+ width: 35,
25
+ height: 35,
26
+ alt: "agent avatar left",
27
+ class: "avatar group-avatar--agent-left",
28
+ src: props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
29
+ })));
14
30
  }
15
- render() {
16
- let accountSetting = this.props.plugin.chatbox;
17
- let acc = this.props.store.matchAccount() || {};
18
- var tooltippos = this.props.tooltipPos || 'bottom';
19
- var mode = this.props.mode || 'primary';
20
- if (accountSetting && accountSetting.hide_agent_profile) {
21
- return (0, _preact.h)("div", {
22
- class: `group-avatar group-avatar--${mode}`
23
- }, (0, _preact.h)("div", {
24
- class: "d-inline-block pos-relative",
25
- "data-tooltip": acc.name,
26
- "data-tooltip-position": tooltippos
27
- }, (0, _preact.h)("img", {
28
- width: 35,
29
- height: 35,
30
- alt: "agent avatar left",
31
- class: "avatar group-avatar--agent-left",
32
- src: this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
33
- })));
34
- }
35
- let agentM = this.props.store.matchAgent('*');
36
- var agents = _index.default.map(this.props.agent_ids, id => agentM[id]);
37
- if (this.props.agent_ids === undefined || _index.default.size(this.props.agent_ids) === 0) {
38
- var agids = _index.default.get(accountSetting, 'header.agent_ids', []);
39
- agids = _index.default.filter(agids, id => !!agentM[id]);
40
- if (agids.length !== 0) {
41
- agents = _index.default.map(agids, id => agentM[id]);
42
- } else {
43
- agents = _index.default.filter(agentM, agent => agent.type === 'agent');
44
- }
45
- }
46
- agents = _index.default.filter(agents, ag => !!ag);
47
- if (agents.length === 0) {
48
- return (0, _preact.h)("div", {
49
- class: `group-avatar group-avatar--${mode}`
50
- }, (0, _preact.h)("div", {
51
- class: "d-inline-block pos-relative",
52
- "data-tooltip": acc.name,
53
- "data-tooltip-position": tooltippos
54
- }, (0, _preact.h)("img", {
55
- width: 35,
56
- height: 35,
57
- alt: "agent avatar left",
58
- class: "avatar group-avatar--agent-left",
59
- src: this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
60
- })));
61
- }
62
- if (agents.length === 1) {
63
- var agent = agents[0];
64
- var groupClass = mode === 'primary' ? 'group-avatar--agent-middle' : 'group-avatar--agent-left';
65
- return (0, _preact.h)("div", {
66
- class: `group-avatar group-avatar--${mode}`
67
- }, (0, _preact.h)("div", {
68
- class: "d-inline-block pos-relative",
69
- "data-tooltip": agent.fullname || acc.name,
70
- "data-tooltip-position": tooltippos
71
- }, (0, _preact.h)("img", {
72
- width: 35,
73
- height: 35,
74
- class: `avatar ${groupClass}`,
75
- alt: "agent avatar",
76
- src: this.props.store.replaceFileUrl(agent.avatar_url) || require('../../assets/img/default_avatar.png')
77
- })));
78
- }
79
- if (agents.length === 2) {
80
- let leftAgent = agents[0];
81
- let rightAgent = agents[1];
82
- return (0, _preact.h)("div", {
83
- class: `group-avatar group-avatar--${mode}`
84
- }, (0, _preact.h)("div", {
85
- class: "d-inline-block pos-relative",
86
- "data-tooltip": leftAgent.fullname || acc.name,
87
- "data-tooltip-position": tooltippos
88
- }, (0, _preact.h)("img", {
89
- width: 35,
90
- height: 35,
91
- alt: "agent avatar left",
92
- class: "avatar group-avatar--agent-left",
93
- src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
94
- })), (0, _preact.h)("div", {
95
- class: "d-inline-block pos-relative",
96
- "data-tooltip": rightAgent.fullname || acc.name,
97
- "data-tooltip-position": tooltippos
98
- }, (0, _preact.h)("img", {
99
- alt: "agent avatar right",
100
- width: 35,
101
- height: 35,
102
- class: "avatar group-avatar--agent-right",
103
- src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
104
- })));
31
+ let agentM = props.store.matchAgent('*');
32
+ var agents = _index.default.map(props.agent_ids, id => agentM[id]);
33
+ if (props.agent_ids === undefined || _index.default.size(props.agent_ids) === 0) {
34
+ var agids = _index.default.get(accountSetting, 'header.agent_ids', []);
35
+ agids = _index.default.filter(agids, id => !!agentM[id]);
36
+ if (agids.length !== 0) {
37
+ agents = _index.default.map(agids, id => agentM[id]);
38
+ } else {
39
+ agents = _index.default.filter(agentM, agent => agent.type === 'agent');
105
40
  }
106
- let leftAgent = agents[0];
107
- let middleAgent = agents[1];
108
- let rightAgent = agents[2];
41
+ }
42
+ agents = _index.default.filter(agents, ag => !!ag);
43
+ if (agents.length === 0) {
109
44
  return (0, _preact.h)("div", {
110
45
  class: `group-avatar group-avatar--${mode}`
111
46
  }, (0, _preact.h)("div", {
112
47
  class: "d-inline-block pos-relative",
113
- "data-tooltip": leftAgent.fullname || acc.name,
48
+ "data-tooltip": acc.name,
114
49
  "data-tooltip-position": tooltippos
115
50
  }, (0, _preact.h)("img", {
116
51
  width: 35,
117
52
  height: 35,
118
53
  alt: "agent avatar left",
119
54
  class: "avatar group-avatar--agent-left",
120
- src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
121
- })), (0, _preact.h)("div", {
55
+ src: props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
56
+ })));
57
+ }
58
+ if (agents.length === 1) {
59
+ var agent = agents[0];
60
+ var groupClass = mode === 'primary' ? 'group-avatar--agent-middle' : 'group-avatar--agent-left';
61
+ return (0, _preact.h)("div", {
62
+ class: `group-avatar group-avatar--${mode}`
63
+ }, (0, _preact.h)("div", {
64
+ class: "d-inline-block pos-relative",
65
+ "data-tooltip": agent.fullname || acc.name,
66
+ "data-tooltip-position": tooltippos
67
+ }, (0, _preact.h)("img", {
68
+ width: 35,
69
+ height: 35,
70
+ class: `avatar ${groupClass}`,
71
+ alt: "agent avatar",
72
+ src: props.store.replaceFileUrl(agent.avatar_url) || require('../../assets/img/default_avatar.png')
73
+ })));
74
+ }
75
+ if (agents.length === 2) {
76
+ let leftAgent = agents[0];
77
+ let rightAgent = agents[1];
78
+ return (0, _preact.h)("div", {
79
+ class: `group-avatar group-avatar--${mode}`
80
+ }, (0, _preact.h)("div", {
122
81
  class: "d-inline-block pos-relative",
123
- "data-tooltip": middleAgent.fullname || acc.name,
82
+ "data-tooltip": leftAgent.fullname || acc.name,
124
83
  "data-tooltip-position": tooltippos
125
84
  }, (0, _preact.h)("img", {
126
- alt: "agent avatar middle",
127
85
  width: 35,
128
86
  height: 35,
129
- class: "avatar group-avatar--agent-middle",
130
- src: this.props.store.replaceFileUrl(middleAgent.avatar_url) || require('../../assets/img/default_avatar.png')
87
+ alt: "agent avatar left",
88
+ class: "avatar group-avatar--agent-left",
89
+ src: props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
131
90
  })), (0, _preact.h)("div", {
132
91
  class: "d-inline-block pos-relative",
133
92
  "data-tooltip": rightAgent.fullname || acc.name,
134
93
  "data-tooltip-position": tooltippos
135
94
  }, (0, _preact.h)("img", {
95
+ alt: "agent avatar right",
136
96
  width: 35,
137
97
  height: 35,
138
- alt: "agent avatar right",
139
98
  class: "avatar group-avatar--agent-right",
140
- src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
99
+ src: props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
141
100
  })));
142
101
  }
143
- }
144
- exports.default = AgentsAvatar;
102
+ let leftAgent = agents[0];
103
+ let middleAgent = agents[1];
104
+ let rightAgent = agents[2];
105
+ return (0, _preact.h)("div", {
106
+ class: `group-avatar group-avatar--${mode}`
107
+ }, (0, _preact.h)("div", {
108
+ class: "d-inline-block pos-relative",
109
+ "data-tooltip": leftAgent.fullname || acc.name,
110
+ "data-tooltip-position": tooltippos
111
+ }, (0, _preact.h)("img", {
112
+ width: 35,
113
+ height: 35,
114
+ alt: "agent avatar left",
115
+ class: "avatar group-avatar--agent-left",
116
+ src: props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
117
+ })), (0, _preact.h)("div", {
118
+ class: "d-inline-block pos-relative",
119
+ "data-tooltip": middleAgent.fullname || acc.name,
120
+ "data-tooltip-position": tooltippos
121
+ }, (0, _preact.h)("img", {
122
+ alt: "agent avatar middle",
123
+ width: 35,
124
+ height: 35,
125
+ class: "avatar group-avatar--agent-middle",
126
+ src: props.store.replaceFileUrl(middleAgent.avatar_url) || require('../../assets/img/default_avatar.png')
127
+ })), (0, _preact.h)("div", {
128
+ class: "d-inline-block pos-relative",
129
+ "data-tooltip": rightAgent.fullname || acc.name,
130
+ "data-tooltip-position": tooltippos
131
+ }, (0, _preact.h)("img", {
132
+ width: 35,
133
+ height: 35,
134
+ alt: "agent avatar right",
135
+ class: "avatar group-avatar--agent-right",
136
+ src: props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
137
+ })));
138
+ }
@@ -3,39 +3,32 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = AudioAttachments;
7
7
  var _index = _interopRequireDefault(require("../util/index.js"));
8
- var _common = require("../common.js");
9
8
  var _preact = require("preact");
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- class AudioAttachments extends _common.Com {
12
- constructor(props) {
13
- super(props);
14
- }
15
- render() {
16
- let byType = _index.default.get(this.props.ev, 'by.type');
17
- var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
18
- var audios = [];
19
- _index.default.each(attachments, (att, i) => {
20
- if (!att) return;
21
- if (_index.default.includes(att.mimetype, 'audio')) audios.push(att);
22
- });
23
- if (audios.length === 0) return null;
24
- var $audios = _index.default.map(audios, (audio, index) => {
25
- return (0, _preact.h)("div", {
26
- key: index,
27
- class: `audio-attachment audio-attachment--${byType}`
28
- }, (0, _preact.h)("audio", {
29
- class: "audio-attachment__audio",
30
- controls: true
31
- }, (0, _preact.h)("source", {
32
- src: this.props.store.replaceFileUrl(audio.url),
33
- type: audio.mimetype
34
- })));
35
- });
10
+ function AudioAttachments(props) {
11
+ let byType = _index.default.get(props.ev, 'by.type');
12
+ var attachments = _index.default.get(props.ev, 'data.message.attachments', []);
13
+ var audios = [];
14
+ _index.default.each(attachments, (att, i) => {
15
+ if (!att) return;
16
+ if (_index.default.includes(att.mimetype, 'audio')) audios.push(att);
17
+ });
18
+ if (audios.length === 0) return null;
19
+ var $audios = _index.default.map(audios, (audio, index) => {
36
20
  return (0, _preact.h)("div", {
37
- class: `message-${byType} message-${byType}-audio`
38
- }, $audios);
39
- }
40
- }
41
- exports.default = AudioAttachments;
21
+ key: index,
22
+ class: `audio-attachment audio-attachment--${byType}`
23
+ }, (0, _preact.h)("audio", {
24
+ class: "audio-attachment__audio",
25
+ controls: true
26
+ }, (0, _preact.h)("source", {
27
+ src: props.store.replaceFileUrl(audio.url),
28
+ type: audio.mimetype
29
+ })));
30
+ });
31
+ return (0, _preact.h)("div", {
32
+ class: `message-${byType} message-${byType}-audio`
33
+ }, $audios);
34
+ }
@@ -3,30 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = ButtonAttachments;
7
7
  var _Buttons = _interopRequireDefault(require("./Buttons.js"));
8
8
  var _index = _interopRequireDefault(require("../util/index.js"));
9
- var _common = require("../common.js");
10
9
  var _preact = require("preact");
11
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- class ButtonAttachments extends _common.Com {
13
- constructor(props) {
14
- super(props);
15
- }
16
- render() {
17
- let byType = _index.default.get(this.props.ev, 'by.type');
18
- if (byType === 'user') return null;
19
- let buttons = [];
20
- let attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
21
- _index.default.each(attachments, (att, i) => {
22
- if (!att || _index.default.get(att, 'type') !== 'button') return;
23
- _index.default.each(_index.default.get(att, 'buttons') || [], btn => buttons.push(btn));
24
- });
25
- return (0, _preact.h)(_Buttons.default, {
26
- store: this.props.store,
27
- buttons: buttons,
28
- t: this.props.t
29
- });
30
- }
31
- }
32
- exports.default = ButtonAttachments;
11
+ function ButtonAttachments(props) {
12
+ let byType = _index.default.get(props.ev, 'by.type');
13
+ if (byType === 'user') return null;
14
+ let buttons = [];
15
+ let attachments = _index.default.get(props.ev, 'data.message.attachments', []);
16
+ _index.default.each(attachments, (att, i) => {
17
+ if (!att || _index.default.get(att, 'type') !== 'button') return;
18
+ _index.default.each(_index.default.get(att, 'buttons') || [], btn => buttons.push(btn));
19
+ });
20
+ return (0, _preact.h)(_Buttons.default, {
21
+ store: props.store,
22
+ buttons: buttons,
23
+ t: props.t
24
+ });
25
+ }
@@ -3,49 +3,42 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = Buttons;
7
7
  var _index = _interopRequireDefault(require("../util/index.js"));
8
- var _common = require("../common.js");
9
8
  var _preact = require("preact");
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- class Buttons extends _common.Com {
12
- constructor(props) {
13
- super(props);
14
- }
15
- render() {
16
- if (_index.default.size(this.props.buttons) === 0) return null;
17
- var $buttons = _index.default.map(this.props.buttons, (button, index) => {
18
- if (button.type === 'call_button') {
19
- return (0, _preact.h)("a", {
20
- class: "url-button-attachment",
21
- href: 'tel:' + button.phone_number,
22
- key: index,
23
- title: button.title
24
- }, this.props.t.i18n(button.i18n_title) || button.title);
25
- }
26
- if (button.type === 'url_button') {
27
- return (0, _preact.h)("a", {
28
- class: "url-button-attachment",
29
- href: button.url,
30
- target: "_blank",
31
- key: index,
32
- title: button.title
33
- }, this.props.t.i18n(button.i18n_title) || button.title || button.url);
34
- }
35
- if (button.type === 'postback_button') {
36
- return (0, _preact.h)("a", {
37
- class: "url-button-attachment",
38
- href: "javascript:;",
39
- onClick: _ => this.props.onSelect(button)
40
- }, this.props.t.i18n(button.i18n_title) || button.title);
41
- }
42
- if (button.type === 'widget_ask_desktop_notify_button') return null;
43
- if (button.type === 'widget_ask_contact_info_button') return null;
44
- return null;
45
- });
46
- return (0, _preact.h)("div", {
47
- class: "button-attachments"
48
- }, $buttons);
49
- }
50
- }
51
- exports.default = Buttons;
10
+ function Buttons(props) {
11
+ if (_index.default.size(props.buttons) === 0) return null;
12
+ var $buttons = _index.default.map(props.buttons, (button, index) => {
13
+ if (button.type === 'call_button') {
14
+ return (0, _preact.h)("a", {
15
+ class: "url-button-attachment",
16
+ href: 'tel:' + button.phone_number,
17
+ key: index,
18
+ title: button.title
19
+ }, props.t.i18n(button.i18n_title) || button.title);
20
+ }
21
+ if (button.type === 'url_button') {
22
+ return (0, _preact.h)("a", {
23
+ class: "url-button-attachment",
24
+ href: button.url,
25
+ target: "_blank",
26
+ key: index,
27
+ title: button.title
28
+ }, props.t.i18n(button.i18n_title) || button.title || button.url);
29
+ }
30
+ if (button.type === 'postback_button') {
31
+ return (0, _preact.h)("a", {
32
+ class: "url-button-attachment",
33
+ href: "javascript:;",
34
+ onClick: _ => props.onSelect(button)
35
+ }, props.t.i18n(button.i18n_title) || button.title);
36
+ }
37
+ if (button.type === 'widget_ask_desktop_notify_button') return null;
38
+ if (button.type === 'widget_ask_contact_info_button') return null;
39
+ return null;
40
+ });
41
+ return (0, _preact.h)("div", {
42
+ class: "button-attachments"
43
+ }, $buttons);
44
+ }
@@ -117,7 +117,11 @@ class ChatButton extends _common.Com {
117
117
  if (new _index.default.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
118
118
  let greeting = _index.default.get(accountSetting, 'greeting', {});
119
119
  let text = this.props.t.i18n(_index.default.get(greeting, 'greeting', {})) || greeting.message;
120
- if (!text || !greeting.enabled) {
120
+ let enabled = greeting.enabled;
121
+ if (this.props.store.isMobile()) {
122
+ enabled = enabled && !_index.default.get(greeting, 'mobile_disabled');
123
+ }
124
+ if (!text || !enabled) {
121
125
  this.setState({
122
126
  previewEvent: {}
123
127
  });
@@ -13,7 +13,6 @@ var _FormAttachments = _interopRequireDefault(require("./FormAttachments.js"));
13
13
  var _FormSubmitAttachments = _interopRequireDefault(require("./FormSubmitAttachments.js"));
14
14
  var _GenericTemplateAttachments = _interopRequireDefault(require("./GenericTemplateAttachments.js"));
15
15
  var _ProductAttachments = _interopRequireDefault(require("./ProductAttachments.js"));
16
- var _OrderAttachments = _interopRequireDefault(require("./OrderAttachments.js"));
17
16
  var _VideoAttachments = _interopRequireDefault(require("./VideoAttachments.js"));
18
17
  var _TextMessage = _interopRequireDefault(require("./TextMessage.js"));
19
18
  var _InfoMessage = _interopRequireDefault(require("./InfoMessage.js"));
@@ -22,6 +21,10 @@ var _time = _interopRequireDefault(require("./time.js"));
22
21
  var _common = require("../common.js");
23
22
  var _preact = require("preact");
24
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
25
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
26
+ let OrderAttachments = false;
27
+ const LoadOrderAttachments = () => Promise.resolve().then(() => _interopRequireWildcard(require('./OrderAttachments.js')));
25
28
  class Event extends _common.Com {
26
29
  constructor(props) {
27
30
  super(props);
@@ -115,14 +118,27 @@ class Event extends _common.Com {
115
118
  class: "message-sender-name"
116
119
  }, senderName));
117
120
  }
121
+ tryLoadOrder(ev) {
122
+ let byType = _index.default.get(ev, 'by.type');
123
+ if (byType === 'user') return;
124
+ let acc = this.props.store.matchAccount();
125
+ var attachments = _index.default.get(ev, 'data.message.attachments', []);
126
+ let orders = _index.default.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
127
+ if (orders.length === 0) return;
128
+ if (!OrderAttachments) _index.default.setTimeout(async () => {
129
+ OrderAttachments = (await LoadOrderAttachments()).default;
130
+ });
131
+ }
118
132
  renderMessageSent() {
119
133
  let ev = this.props.event.ev;
134
+ this.tryLoadOrder(ev);
120
135
  var $time = null;
121
136
  if (this.props.event.show_time) {
122
137
  $time = (0, _preact.h)("div", {
123
138
  class: "convo-event-time"
124
139
  }, (0, _preact.h)(_time.default, {
125
- time: ev.created
140
+ time: ev.created,
141
+ t: this.props.t
126
142
  }));
127
143
  }
128
144
  let t = new _index.default.Date(ev.created).toLocaleString();
@@ -172,7 +188,7 @@ class Event extends _common.Com {
172
188
  onPostback: e => this.choosePostbackBtn(e),
173
189
  store: this.props.store,
174
190
  ev: ev
175
- }), (0, _preact.h)(_OrderAttachments.default, {
191
+ }), (0, _preact.h)(OrderAttachments, {
176
192
  t: this.props.t,
177
193
  store: this.props.store,
178
194
  ev: ev