@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/inject.js CHANGED
@@ -38,7 +38,7 @@ function runChatbox(subiz) {
38
38
  show_close_button: true,
39
39
  overlay: true,
40
40
  text_color: 'rgba(0,0,0,1)',
41
- font_family: 'Roboto',
41
+ font_family: 'Inter',
42
42
  font_size: '14px',
43
43
  background: 'white',
44
44
  spacer: '10',
@@ -410,7 +410,7 @@ function runPopup(subiz) {
410
410
  overlay: true,
411
411
  primary_color: '#FDAD15',
412
412
  text_color: '#333',
413
- font_family: 'Roboto',
413
+ font_family: 'Inter',
414
414
  font_size: '14px',
415
415
  background: 'white',
416
416
  spacer: '10',
@@ -636,7 +636,7 @@ function runPopup2(subiz) {
636
636
  overlay: true,
637
637
  primary_color: '#E36539',
638
638
  text_color: '#333',
639
- font_family: 'Roboto',
639
+ font_family: 'Inter',
640
640
  font_size: '14px',
641
641
  background: 'white',
642
642
  spacer: '10',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.70",
3
+ "version": "4.1.72",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -9,10 +9,10 @@
9
9
  "lib": "rm -rf compiled_src && npx babel --out-dir=compiled_src src"
10
10
  },
11
11
  "dependencies": {
12
- "@subiz/ajax": "^3.0.12",
12
+ "@subiz/ajax": "^3.0.14",
13
13
  "@subiz/flow": "^1.1.0",
14
14
  "@subiz/storage": "0.0.8",
15
- "@subiz/wsclient": "^4.0.21",
15
+ "@subiz/wsclient": "^4.0.24",
16
16
  "cookie_js": "1.4.2",
17
17
  "core-js": "^3.36.1",
18
18
  "css-loader": "5.2.7",
@@ -23,14 +23,14 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@babel/cli": "^7.24.1",
26
- "@babel/core": "^7.24.3",
26
+ "@babel/core": "^7.24.4",
27
27
  "@babel/plugin-proposal-class-properties": "^7.18.6",
28
28
  "@babel/plugin-transform-react-jsx": "^7.23.4",
29
- "@babel/preset-env": "^7.24.3",
29
+ "@babel/preset-env": "^7.24.4",
30
30
  "babel-loader": "^9.1.3",
31
31
  "babel-plugin-syntax-jsx": "^6.18.0",
32
32
  "html-webpack-plugin": "^5.6.0",
33
- "puppeteer": "^22.6.0",
33
+ "puppeteer": "^22.6.3",
34
34
  "webpack": "^5.91.0",
35
35
  "webpack-bundle-analyzer": "^4.10.1",
36
36
  "webpack-cli": "^5.1.4",
@@ -3,161 +3,98 @@ import {Com} from '../common.js'
3
3
  import {h} from 'preact'
4
4
 
5
5
  // ['mode', 'tooltipPos', 'agent_ids', 'border'],
6
- export default class AgentsAvatar extends Com {
7
- constructor(props) {
8
- super(props)
9
- }
10
-
11
- render() {
12
- let accountSetting = this.props.plugin.chatbox
13
- let acc = this.props.store.matchAccount() || {}
14
- var tooltippos = this.props.tooltipPos || 'bottom'
15
- var mode = this.props.mode || 'primary'
16
-
17
- if (accountSetting && accountSetting.hide_agent_profile) {
18
- return (
19
- <div class={`group-avatar group-avatar--${mode}`}>
20
- <div class='d-inline-block pos-relative' data-tooltip={acc.name} data-tooltip-position={tooltippos}>
21
- <img
22
- width={35}
23
- height={35}
24
- alt='agent avatar left'
25
- class='avatar group-avatar--agent-left'
26
- src={this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
27
- />
28
- </div>
29
- </div>
30
- )
31
- }
32
-
33
- let agentM = this.props.store.matchAgent('*')
34
- var agents = sb.map(this.props.agent_ids, (id) => agentM[id])
35
- if (this.props.agent_ids === undefined || sb.size(this.props.agent_ids) === 0) {
36
- var agids = sb.get(accountSetting, 'header.agent_ids', [])
37
- agids = sb.filter(agids, (id) => !!agentM[id])
38
- if (agids.length !== 0) {
39
- agents = sb.map(agids, (id) => agentM[id])
40
- } else {
41
- agents = sb.filter(agentM, (agent) => agent.type === 'agent')
42
- }
43
- }
6
+ export default function AgentsAvatar(props) {
7
+ let accountSetting = props.plugin.chatbox
8
+ let acc = props.store.matchAccount() || {}
9
+ var tooltippos = props.tooltipPos || 'bottom'
10
+ var mode = props.mode || 'primary'
44
11
 
45
- agents = sb.filter(agents, (ag) => !!ag)
46
- if (agents.length === 0) {
47
- // use account avatar
48
- return (
49
- <div class={`group-avatar group-avatar--${mode}`}>
50
- <div class='d-inline-block pos-relative' data-tooltip={acc.name} data-tooltip-position={tooltippos}>
51
- <img
52
- width={35}
53
- height={35}
54
- alt='agent avatar left'
55
- class='avatar group-avatar--agent-left'
56
- src={this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
57
- />
58
- </div>
12
+ if (accountSetting && accountSetting.hide_agent_profile) {
13
+ return (
14
+ <div class={`group-avatar group-avatar--${mode}`}>
15
+ <div class='d-inline-block pos-relative' data-tooltip={acc.name} data-tooltip-position={tooltippos}>
16
+ <img
17
+ width={35}
18
+ height={35}
19
+ alt='agent avatar left'
20
+ class='avatar group-avatar--agent-left'
21
+ src={props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
22
+ />
59
23
  </div>
60
- )
61
- }
24
+ </div>
25
+ )
26
+ }
62
27
 
63
- // 1 agent
64
- if (agents.length === 1) {
65
- var agent = agents[0]
66
- var groupClass = mode === 'primary' ? 'group-avatar--agent-middle' : 'group-avatar--agent-left'
67
- return (
68
- <div class={`group-avatar group-avatar--${mode}`}>
69
- <div
70
- class='d-inline-block pos-relative'
71
- data-tooltip={agent.fullname || acc.name}
72
- data-tooltip-position={tooltippos}
73
- >
74
- <img
75
- width={35}
76
- height={35}
77
- class={`avatar ${groupClass}`}
78
- alt='agent avatar'
79
- src={this.props.store.replaceFileUrl(agent.avatar_url) || require('../../assets/img/default_avatar.png')}
80
- />
81
- </div>
82
- </div>
83
- )
28
+ let agentM = props.store.matchAgent('*')
29
+ var agents = sb.map(props.agent_ids, (id) => agentM[id])
30
+ if (props.agent_ids === undefined || sb.size(props.agent_ids) === 0) {
31
+ var agids = sb.get(accountSetting, 'header.agent_ids', [])
32
+ agids = sb.filter(agids, (id) => !!agentM[id])
33
+ if (agids.length !== 0) {
34
+ agents = sb.map(agids, (id) => agentM[id])
35
+ } else {
36
+ agents = sb.filter(agentM, (agent) => agent.type === 'agent')
84
37
  }
38
+ }
85
39
 
86
- // 2 agent
87
- if (agents.length === 2) {
88
- let leftAgent = agents[0]
89
- let rightAgent = agents[1]
90
- return (
91
- <div class={`group-avatar group-avatar--${mode}`}>
92
- <div
93
- class='d-inline-block pos-relative'
94
- data-tooltip={leftAgent.fullname || acc.name}
95
- data-tooltip-position={tooltippos}
96
- >
97
- <img
98
- width={35}
99
- height={35}
100
- alt='agent avatar left'
101
- class='avatar group-avatar--agent-left'
102
- src={
103
- this.props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
104
- }
105
- />
106
- </div>
107
- <div
108
- class='d-inline-block pos-relative'
109
- data-tooltip={rightAgent.fullname || acc.name}
110
- data-tooltip-position={tooltippos}
111
- >
112
- <img
113
- alt='agent avatar right'
114
- width={35}
115
- height={35}
116
- class='avatar group-avatar--agent-right'
117
- src={
118
- this.props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
119
- }
120
- />
121
- </div>
40
+ agents = sb.filter(agents, (ag) => !!ag)
41
+ if (agents.length === 0) {
42
+ // use account avatar
43
+ return (
44
+ <div class={`group-avatar group-avatar--${mode}`}>
45
+ <div class='d-inline-block pos-relative' data-tooltip={acc.name} data-tooltip-position={tooltippos}>
46
+ <img
47
+ width={35}
48
+ height={35}
49
+ alt='agent avatar left'
50
+ class='avatar group-avatar--agent-left'
51
+ src={props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
52
+ />
122
53
  </div>
123
- )
124
- }
125
-
126
- // >=3 agent
54
+ </div>
55
+ )
56
+ }
127
57
 
128
- let leftAgent = agents[0]
129
- let middleAgent = agents[1]
130
- let rightAgent = agents[2]
58
+ // 1 agent
59
+ if (agents.length === 1) {
60
+ var agent = agents[0]
61
+ var groupClass = mode === 'primary' ? 'group-avatar--agent-middle' : 'group-avatar--agent-left'
131
62
  return (
132
63
  <div class={`group-avatar group-avatar--${mode}`}>
133
64
  <div
134
65
  class='d-inline-block pos-relative'
135
- data-tooltip={leftAgent.fullname || acc.name}
66
+ data-tooltip={agent.fullname || acc.name}
136
67
  data-tooltip-position={tooltippos}
137
68
  >
138
69
  <img
139
70
  width={35}
140
71
  height={35}
141
- alt='agent avatar left'
142
- class='avatar group-avatar--agent-left'
143
- src={
144
- this.props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
145
- }
72
+ class={`avatar ${groupClass}`}
73
+ alt='agent avatar'
74
+ src={props.store.replaceFileUrl(agent.avatar_url) || require('../../assets/img/default_avatar.png')}
146
75
  />
147
76
  </div>
77
+ </div>
78
+ )
79
+ }
80
+
81
+ // 2 agent
82
+ if (agents.length === 2) {
83
+ let leftAgent = agents[0]
84
+ let rightAgent = agents[1]
85
+ return (
86
+ <div class={`group-avatar group-avatar--${mode}`}>
148
87
  <div
149
88
  class='d-inline-block pos-relative'
150
- data-tooltip={middleAgent.fullname || acc.name}
89
+ data-tooltip={leftAgent.fullname || acc.name}
151
90
  data-tooltip-position={tooltippos}
152
91
  >
153
92
  <img
154
- alt='agent avatar middle'
155
93
  width={35}
156
94
  height={35}
157
- class='avatar group-avatar--agent-middle'
158
- src={
159
- this.props.store.replaceFileUrl(middleAgent.avatar_url) || require('../../assets/img/default_avatar.png')
160
- }
95
+ alt='agent avatar left'
96
+ class='avatar group-avatar--agent-left'
97
+ src={props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
161
98
  />
162
99
  </div>
163
100
  <div
@@ -166,16 +103,63 @@ export default class AgentsAvatar extends Com {
166
103
  data-tooltip-position={tooltippos}
167
104
  >
168
105
  <img
106
+ alt='agent avatar right'
169
107
  width={35}
170
108
  height={35}
171
- alt='agent avatar right'
172
109
  class='avatar group-avatar--agent-right'
173
- src={
174
- this.props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
175
- }
110
+ src={props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
176
111
  />
177
112
  </div>
178
113
  </div>
179
114
  )
180
115
  }
116
+
117
+ // >=3 agent
118
+
119
+ let leftAgent = agents[0]
120
+ let middleAgent = agents[1]
121
+ let rightAgent = agents[2]
122
+ return (
123
+ <div class={`group-avatar group-avatar--${mode}`}>
124
+ <div
125
+ class='d-inline-block pos-relative'
126
+ data-tooltip={leftAgent.fullname || acc.name}
127
+ data-tooltip-position={tooltippos}
128
+ >
129
+ <img
130
+ width={35}
131
+ height={35}
132
+ alt='agent avatar left'
133
+ class='avatar group-avatar--agent-left'
134
+ src={props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
135
+ />
136
+ </div>
137
+ <div
138
+ class='d-inline-block pos-relative'
139
+ data-tooltip={middleAgent.fullname || acc.name}
140
+ data-tooltip-position={tooltippos}
141
+ >
142
+ <img
143
+ alt='agent avatar middle'
144
+ width={35}
145
+ height={35}
146
+ class='avatar group-avatar--agent-middle'
147
+ src={props.store.replaceFileUrl(middleAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
148
+ />
149
+ </div>
150
+ <div
151
+ class='d-inline-block pos-relative'
152
+ data-tooltip={rightAgent.fullname || acc.name}
153
+ data-tooltip-position={tooltippos}
154
+ >
155
+ <img
156
+ width={35}
157
+ height={35}
158
+ alt='agent avatar right'
159
+ class='avatar group-avatar--agent-right'
160
+ src={props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
161
+ />
162
+ </div>
163
+ </div>
164
+ )
181
165
  }
@@ -1,31 +1,24 @@
1
1
  import sb from '../util/index.js'
2
- import {Com} from '../common.js'
3
2
  import {h} from 'preact'
4
3
 
5
- export default class AudioAttachments extends Com {
6
- constructor(props) {
7
- super(props)
8
- }
4
+ export default function AudioAttachments(props) {
5
+ let byType = sb.get(props.ev, 'by.type')
6
+ var attachments = sb.get(props.ev, 'data.message.attachments', [])
7
+ var audios = []
8
+ sb.each(attachments, (att, i) => {
9
+ if (!att) return
10
+ if (sb.includes(att.mimetype, 'audio')) audios.push(att)
11
+ })
12
+ if (audios.length === 0) return null
9
13
 
10
- render() {
11
- let byType = sb.get(this.props.ev, 'by.type')
12
- var attachments = sb.get(this.props.ev, 'data.message.attachments', [])
13
- var audios = []
14
- sb.each(attachments, (att, i) => {
15
- if (!att) return
16
- if (sb.includes(att.mimetype, 'audio')) audios.push(att)
17
- })
18
- if (audios.length === 0) return null
19
-
20
- var $audios = sb.map(audios, (audio, index) => {
21
- return (
22
- <div key={index} class={`audio-attachment audio-attachment--${byType}`}>
23
- <audio class='audio-attachment__audio' controls>
24
- <source src={this.props.store.replaceFileUrl(audio.url)} type={audio.mimetype} />
25
- </audio>
26
- </div>
27
- )
28
- })
29
- return <div class={`message-${byType} message-${byType}-audio`}>{$audios}</div>
30
- }
14
+ var $audios = sb.map(audios, (audio, index) => {
15
+ return (
16
+ <div key={index} class={`audio-attachment audio-attachment--${byType}`}>
17
+ <audio class='audio-attachment__audio' controls>
18
+ <source src={props.store.replaceFileUrl(audio.url)} type={audio.mimetype} />
19
+ </audio>
20
+ </div>
21
+ )
22
+ })
23
+ return <div class={`message-${byType} message-${byType}-audio`}>{$audios}</div>
31
24
  }
@@ -1,26 +1,19 @@
1
1
  import Buttons from './Buttons.js'
2
2
  import sb from '../util/index.js'
3
- import { Com } from '../common.js'
4
- import { h } from 'preact'
3
+ import {h} from 'preact'
5
4
 
6
- export default class ButtonAttachments extends Com {
7
- constructor (props) {
8
- super(props)
9
- }
5
+ export default function ButtonAttachments(props) {
6
+ // dont support user sent button yet
7
+ let byType = sb.get(props.ev, 'by.type')
8
+ if (byType === 'user') return null
10
9
 
11
- render () {
12
- // dont support user sent button yet
13
- let byType = sb.get(this.props.ev, 'by.type')
14
- if (byType === 'user') return null
10
+ // filter out all button
11
+ let buttons = []
12
+ let attachments = sb.get(props.ev, 'data.message.attachments', [])
13
+ sb.each(attachments, (att, i) => {
14
+ if (!att || sb.get(att, 'type') !== 'button') return
15
+ sb.each(sb.get(att, 'buttons') || [], (btn) => buttons.push(btn))
16
+ })
15
17
 
16
- // filter out all button
17
- let buttons = []
18
- let attachments = sb.get(this.props.ev, 'data.message.attachments', [])
19
- sb.each(attachments, (att, i) => {
20
- if (!att || sb.get(att, 'type') !== 'button') return
21
- sb.each(sb.get(att, 'buttons') || [], btn => buttons.push(btn))
22
- })
23
-
24
- return <Buttons store={this.props.store} buttons={buttons} t={this.props.t}/>
25
- }
18
+ return <Buttons store={props.store} buttons={buttons} t={props.t} />
26
19
  }
@@ -1,44 +1,36 @@
1
1
  import sb from '../util/index.js'
2
- import {Com} from '../common.js'
3
2
  import {h} from 'preact'
4
3
 
5
- export default class Buttons extends Com {
6
- constructor(props) {
7
- super(props)
8
- }
4
+ export default function Buttons(props) {
5
+ if (sb.size(props.buttons) === 0) return null
6
+ var $buttons = sb.map(props.buttons, (button, index) => {
7
+ if (button.type === 'call_button') {
8
+ return (
9
+ <a class='url-button-attachment' href={'tel:' + button.phone_number} key={index} title={button.title}>
10
+ {props.t.i18n(button.i18n_title) || button.title}
11
+ </a>
12
+ )
13
+ }
9
14
 
10
- render() {
11
- if (sb.size(this.props.buttons) === 0) return null
12
- var $buttons = sb.map(this.props.buttons, (button, index) => {
13
- if (button.type === 'call_button') {
14
- return (
15
- <a class='url-button-attachment' href={'tel:' + button.phone_number} key={index} title={button.title}>
16
- {this.props.t.i18n(button.i18n_title) || button.title}
17
- </a>
18
- )
19
- }
15
+ if (button.type === 'url_button') {
16
+ return (
17
+ <a class='url-button-attachment' href={button.url} target='_blank' key={index} title={button.title}>
18
+ {props.t.i18n(button.i18n_title) || button.title || button.url}
19
+ </a>
20
+ )
21
+ }
20
22
 
21
- if (button.type === 'url_button') {
22
- return (
23
- <a class='url-button-attachment' href={button.url} target='_blank' key={index} title={button.title}>
24
- {this.props.t.i18n(button.i18n_title) || button.title || button.url}
25
- </a>
26
- )
27
- }
23
+ if (button.type === 'postback_button') {
24
+ return (
25
+ <a class='url-button-attachment' href='javascript:;' onClick={(_) => props.onSelect(button)}>
26
+ {props.t.i18n(button.i18n_title) || button.title}
27
+ </a>
28
+ )
29
+ }
28
30
 
29
- if (button.type === 'postback_button') {
30
- return (
31
- <a class='url-button-attachment' href='javascript:;' onClick={(_) => this.props.onSelect(button)}>
32
- {this.props.t.i18n(button.i18n_title) || button.title}
33
- </a>
34
- )
35
- }
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
-
42
- return <div class='button-attachments'>{$buttons}</div>
43
- }
31
+ if (button.type === 'widget_ask_desktop_notify_button') return null
32
+ if (button.type === 'widget_ask_contact_info_button') return null
33
+ return null
34
+ })
35
+ return <div class='button-attachments'>{$buttons}</div>
44
36
  }
@@ -128,7 +128,12 @@ export default class ChatButton extends Com {
128
128
 
129
129
  let greeting = sb.get(accountSetting, 'greeting', {})
130
130
  let text = this.props.t.i18n(sb.get(greeting, 'greeting', {})) || greeting.message
131
- if (!text || !greeting.enabled) {
131
+
132
+ let enabled = greeting.enabled
133
+ if (this.props.store.isMobile()) {
134
+ enabled = enabled && !sb.get(greeting, 'mobile_disabled')
135
+ }
136
+ if (!text || !enabled) {
132
137
  this.setState({previewEvent: {}})
133
138
  return
134
139
  }
@@ -7,7 +7,10 @@ import FormAttachments from './FormAttachments.js'
7
7
  import FormSubmitAttachments from './FormSubmitAttachments.js'
8
8
  import GenericTemplateAttachments from './GenericTemplateAttachments.js'
9
9
  import ProductAttachments from './ProductAttachments.js'
10
- import OrderAttachments from './OrderAttachments.js'
10
+ let OrderAttachments = false
11
+
12
+ const LoadOrderAttachments = () => import(/*webpackChunkName: "OrderAttachment" */ './OrderAttachments.js')
13
+
11
14
  //import FormSubmitAttachment from './formSubmitAttachment.js'
12
15
  import VideoAttachments from './VideoAttachments.js'
13
16
  import TextMessage from './TextMessage.js'
@@ -113,14 +116,30 @@ export default class Event extends Com {
113
116
  )
114
117
  }
115
118
 
119
+ tryLoadOrder(ev) {
120
+ let byType = sb.get(ev, 'by.type')
121
+ if (byType === 'user') return
122
+ // filter out all generic
123
+
124
+ let acc = this.props.store.matchAccount()
125
+ var attachments = sb.get(ev, 'data.message.attachments', [])
126
+ let orders = sb.filter(attachments, (att) => att.type === 'order' && att.order).map((att) => att.order)
127
+
128
+ if (orders.length === 0) return
129
+ if (!OrderAttachments)
130
+ sb.setTimeout(async () => {
131
+ OrderAttachments = (await LoadOrderAttachments()).default
132
+ })
133
+ }
134
+
116
135
  renderMessageSent() {
117
136
  let ev = this.props.event.ev
118
-
137
+ this.tryLoadOrder(ev)
119
138
  var $time = null
120
139
  if (this.props.event.show_time) {
121
140
  $time = (
122
141
  <div class='convo-event-time'>
123
- <Time time={ev.created} />
142
+ <Time time={ev.created} t={this.props.t} />
124
143
  </div>
125
144
  )
126
145
  }
@@ -1,6 +1,6 @@
1
1
  import sb from '../util/index.js'
2
2
 
3
- function getRateLang (rating) {
3
+ function getRateLang(rating) {
4
4
  if (!rating) return 'poor'
5
5
  if (rating < 2) return 'poor'
6
6
  if (rating < 4) return 'average'
@@ -8,29 +8,29 @@ function getRateLang (rating) {
8
8
  }
9
9
 
10
10
  import Time from './time.js'
11
- import { Com } from '../common.js'
12
- import { h } from 'preact'
11
+ import {Com} from '../common.js'
12
+ import {h} from 'preact'
13
13
  // [ 'ev'],
14
14
  export default class InfoMessage extends Com {
15
- render () {
15
+ render() {
16
16
  let ev = this.props.ev.ev
17
17
  var $time = null
18
18
  if (this.props.ev.show_time) {
19
19
  $time = (
20
- <div class="convo-event-time">
21
- <Time time={ev.created} />
20
+ <div class='convo-event-time'>
21
+ <Time time={ev.created} t={this.props.t} />
22
22
  </div>
23
23
  )
24
24
  }
25
25
 
26
26
  // if (this.ev.type === 'conversation_rating_requested') return <div class="info-message"></div>
27
27
  if (ev.type === 'conversation_rated') {
28
- var rating = sb.get(ev, 'data.conversation.ratings.0', { no_rating: true, rating: 0 })
28
+ var rating = sb.get(ev, 'data.conversation.ratings.0', {no_rating: true, rating: 0})
29
29
  if (rating.no_rating) return null
30
30
  return (
31
- <div class="convo-event">
31
+ <div class='convo-event'>
32
32
  {$time}
33
- <div class="info-message">
33
+ <div class='info-message'>
34
34
  {this.props.t('rated_as') + ' ' + this.props.t(getRateLang(rating.rating)).toLowerCase()}
35
35
  </div>
36
36
  </div>
@@ -38,9 +38,9 @@ export default class InfoMessage extends Com {
38
38
  }
39
39
  if (ev.type === 'conversation_state_updated' && sb.get(ev, 'data.conversation.state') === 'ended') {
40
40
  return (
41
- <div class="convo-event">
41
+ <div class='convo-event'>
42
42
  {$time}
43
- <div class="info-message">{this.props.t('conversation_ended')}</div>
43
+ <div class='info-message'>{this.props.t('conversation_ended')}</div>
44
44
  </div>
45
45
  )
46
46
  }