@subiz/widget-v4 4.0.86 → 4.0.87
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/.prettierrc.js +1 -1
- package/compiled_src/chatbox/AgentsAvatar.js +20 -3
- package/compiled_src/chatbox/ChatButton.js +7 -0
- package/compiled_src/chatbox/Event.js +12 -0
- package/compiled_src/chatbox/Events.js +1 -0
- package/compiled_src/chatbox/MessageInput.js +6 -0
- package/compiled_src/chatbox/Widget.js +41 -37
- package/compiled_src/chatbox/main.js +10 -0
- package/compiled_src/popup/popup.js +14 -2
- package/compiled_src/store/store.js +20 -34
- package/compiled_src/util/common.js +10 -10
- package/dist/{18224b3b0f8.132.js → 182ed9b853b.132.js} +0 -0
- package/dist/{18224b3b0f8.178.js → 182ed9b853b.178.js} +0 -0
- package/dist/{18224b3b0f8.213.js → 182ed9b853b.213.js} +1 -1
- package/dist/{18224b3b0f8.335.js → 182ed9b853b.335.js} +0 -0
- package/dist/{18224b3b0f8.362.js → 182ed9b853b.362.js} +1 -1
- package/dist/{18224b3b0f8.441.js → 182ed9b853b.441.js} +1 -1
- package/dist/{18224b3b0f8.605.js → 182ed9b853b.605.js} +0 -0
- package/dist/{18224b3b0f8.678.js → 182ed9b853b.678.js} +0 -0
- package/dist/{18224b3b0f8.782.js → 182ed9b853b.782.js} +1 -1
- package/dist/182ed9b853b.app.js +1 -0
- package/dist/{18224b3b0f8.index.html → 182ed9b853b.index.html} +1 -1
- package/dist/{18224b3b0f8.library.html → 182ed9b853b.library.html} +1 -1
- package/dist/182ed9b853b.library.js +1 -0
- package/dist/{18224b3b0f8.preview.html → 182ed9b853b.preview.html} +1 -1
- package/dist/182ed9b853b.preview.js +1 -0
- package/dist/182ed9b853b.screenshoot.js +1 -0
- package/dist/213.js +12 -1
- package/dist/362.js +1 -1
- package/dist/441.js +2 -1
- package/dist/782.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +26 -44
- package/index.html +1 -1
- package/package.json +11 -11
- package/src/chatbox/AgentsAvatar.js +32 -10
- package/src/chatbox/ChatButton.js +7 -0
- package/src/chatbox/Event.js +23 -4
- package/src/chatbox/Events.js +3 -1
- package/src/chatbox/MessageInput.js +14 -5
- package/src/chatbox/Widget.js +10 -9
- package/src/chatbox/main.js +8 -1
- package/src/popup/popup.js +14 -1
- package/src/store/store.js +21 -32
- package/src/util/common.js +16 -19
- package/dist/18224b3b0f8.app.js +0 -1
- package/dist/18224b3b0f8.library.js +0 -1
- package/dist/18224b3b0f8.preview.js +0 -1
- package/dist/18224b3b0f8.screenshoot.js +0 -1
package/dist/screenshoot.js
CHANGED
|
@@ -2150,10 +2150,9 @@ function osName() {
|
|
|
2150
2150
|
function check_frequently(freq, lastrun, store) {
|
|
2151
2151
|
if (!lastrun) return true;
|
|
2152
2152
|
if (op.get(freq, 'once_per_user')) return false;
|
|
2153
|
-
var session = store.matchSession() || {};
|
|
2154
2153
|
|
|
2155
2154
|
if (op.get(freq, 'once_per_session')) {
|
|
2156
|
-
if (lastrun.
|
|
2155
|
+
if (sameDay(lastrun.created, Date.now())) return false;
|
|
2157
2156
|
}
|
|
2158
2157
|
|
|
2159
2158
|
if (op.get(freq, 'interval_sec')) {
|
|
@@ -2166,7 +2165,7 @@ function check_frequently(freq, lastrun, store) {
|
|
|
2166
2165
|
|
|
2167
2166
|
function checkRunConditions(freq, conds, lastrun, store) {
|
|
2168
2167
|
var acc = store.matchAccount() || {};
|
|
2169
|
-
var
|
|
2168
|
+
var location = store.matchLocation() || {};
|
|
2170
2169
|
if (!check_frequently(freq, lastrun, store)) return false;
|
|
2171
2170
|
|
|
2172
2171
|
for (var i = 0; i < size(conds); i++) {
|
|
@@ -2206,15 +2205,15 @@ function checkRunConditions(freq, conds, lastrun, store) {
|
|
|
2206
2205
|
if (size(cond.exclude_locations) > 0) {
|
|
2207
2206
|
let found = find(cond.exclude_locations, loc => {
|
|
2208
2207
|
if (loc.city_name && loc.country_code) {
|
|
2209
|
-
if (loc.city_name ===
|
|
2208
|
+
if (loc.city_name === location.city_name && loc.country_code === location.country_code) return true;
|
|
2210
2209
|
}
|
|
2211
2210
|
|
|
2212
2211
|
if (loc.city_name && !loc.country_code) {
|
|
2213
|
-
if (loc.city_name ===
|
|
2212
|
+
if (loc.city_name === location.city_name) return true;
|
|
2214
2213
|
}
|
|
2215
2214
|
|
|
2216
2215
|
if (!loc.city_name && loc.country_code) {
|
|
2217
|
-
if (loc.country_code ===
|
|
2216
|
+
if (loc.country_code === location.country_code) return true;
|
|
2218
2217
|
}
|
|
2219
2218
|
});
|
|
2220
2219
|
if (found) return false;
|
|
@@ -2223,15 +2222,15 @@ function checkRunConditions(freq, conds, lastrun, store) {
|
|
|
2223
2222
|
if (size(cond.locations) > 0) {
|
|
2224
2223
|
let found = find(cond.locations, loc => {
|
|
2225
2224
|
if (loc.city_name && loc.country_code) {
|
|
2226
|
-
if (loc.city_name ===
|
|
2225
|
+
if (loc.city_name === location.city_name && loc.country_code === location.country_code) return true;
|
|
2227
2226
|
}
|
|
2228
2227
|
|
|
2229
2228
|
if (loc.city_name && !loc.country_code) {
|
|
2230
|
-
if (loc.city_name ===
|
|
2229
|
+
if (loc.city_name === location.city_name) return true;
|
|
2231
2230
|
}
|
|
2232
2231
|
|
|
2233
2232
|
if (!loc.city_name && loc.country_code) {
|
|
2234
|
-
if (loc.country_code ===
|
|
2233
|
+
if (loc.country_code === location.country_code) return true;
|
|
2235
2234
|
}
|
|
2236
2235
|
});
|
|
2237
2236
|
if (!found) return false;
|
|
@@ -2295,7 +2294,8 @@ function checkRunConditions(freq, conds, lastrun, store) {
|
|
|
2295
2294
|
|
|
2296
2295
|
case 'source':
|
|
2297
2296
|
if (size(cond.sources) > 0) {
|
|
2298
|
-
|
|
2297
|
+
let source = store.matchTrafficSource();
|
|
2298
|
+
if (!find(cond.sources, src => norm(src) === norm(source))) return false;
|
|
2299
2299
|
}
|
|
2300
2300
|
|
|
2301
2301
|
break;
|
|
@@ -4184,8 +4184,6 @@ class Store {
|
|
|
4184
4184
|
|
|
4185
4185
|
store_defineProperty(this, "suggest_addresses", keyword => this.api.suggest_address(keyword));
|
|
4186
4186
|
|
|
4187
|
-
store_defineProperty(this, "matchSession", () => this.kv.match('session') || {});
|
|
4188
|
-
|
|
4189
4187
|
store_defineProperty(this, "matchAccount", () => this.cache.match('account'));
|
|
4190
4188
|
|
|
4191
4189
|
store_defineProperty(this, "matchPaymentMethods", () => this.cache.match('payment_methods'));
|
|
@@ -4277,6 +4275,8 @@ class Store {
|
|
|
4277
4275
|
};
|
|
4278
4276
|
});
|
|
4279
4277
|
|
|
4278
|
+
store_defineProperty(this, "matchLocation", () => this.cache.match('location') || {});
|
|
4279
|
+
|
|
4280
4280
|
store_defineProperty(this, "matchBot", () => this.cache.match('bot') || {});
|
|
4281
4281
|
|
|
4282
4282
|
store_defineProperty(this, "readyGate", new util/* default.Gate */.Z.Gate());
|
|
@@ -4304,6 +4304,8 @@ class Store {
|
|
|
4304
4304
|
|
|
4305
4305
|
store_defineProperty(this, "seenQueue", []);
|
|
4306
4306
|
|
|
4307
|
+
store_defineProperty(this, "matchTrafficSource", () => this.kv.match('traffic_source'));
|
|
4308
|
+
|
|
4307
4309
|
store_defineProperty(this, "_typing", util/* default.throttle */.Z.throttle(convoid => this.api.sendTyping(convoid), 3000, {
|
|
4308
4310
|
trailing: false
|
|
4309
4311
|
}));
|
|
@@ -4411,7 +4413,7 @@ class Store {
|
|
|
4411
4413
|
}
|
|
4412
4414
|
|
|
4413
4415
|
isInsync(key) {
|
|
4414
|
-
return util/* default.Date.now */.Z.Date.now() - (this.g_sync[key] || 0) <
|
|
4416
|
+
return util/* default.Date.now */.Z.Date.now() - (this.g_sync[key] || 0) < 600000;
|
|
4415
4417
|
}
|
|
4416
4418
|
|
|
4417
4419
|
async fetchShippingAddresses() {
|
|
@@ -4682,24 +4684,6 @@ class Store {
|
|
|
4682
4684
|
|
|
4683
4685
|
if (setting.user) {
|
|
4684
4686
|
setting.user.account_id = setting.account.id;
|
|
4685
|
-
let oldsession = this.matchSession();
|
|
4686
|
-
let session = setting.user.session;
|
|
4687
|
-
|
|
4688
|
-
if (session) {
|
|
4689
|
-
if (session.id === oldsession.id) {
|
|
4690
|
-
session._urls = oldsession._urls;
|
|
4691
|
-
} else {}
|
|
4692
|
-
} else {
|
|
4693
|
-
session = oldsession;
|
|
4694
|
-
}
|
|
4695
|
-
|
|
4696
|
-
session._urls = session._urls || [];
|
|
4697
|
-
|
|
4698
|
-
session._urls.push(location.href);
|
|
4699
|
-
|
|
4700
|
-
while (session._urls.length > 1000) session._urls.shift();
|
|
4701
|
-
|
|
4702
|
-
this.kv.put('session', session);
|
|
4703
4687
|
delete setting.user.session;
|
|
4704
4688
|
|
|
4705
4689
|
this._setUser(setting.user);
|
|
@@ -4712,6 +4696,8 @@ class Store {
|
|
|
4712
4696
|
delete setting.account;
|
|
4713
4697
|
}
|
|
4714
4698
|
|
|
4699
|
+
let location = util/* default.get */.Z.get(setting, 'location', []);
|
|
4700
|
+
this.cache.put('location', location);
|
|
4715
4701
|
let bots = util/* default.get */.Z.get(setting, 'bots', []);
|
|
4716
4702
|
let botM = {};
|
|
4717
4703
|
util/* default.map */.Z.map(bots, bot => {
|
|
@@ -4746,7 +4732,9 @@ class Store {
|
|
|
4746
4732
|
|
|
4747
4733
|
async track() {
|
|
4748
4734
|
let user = this.kv.match('user') || {};
|
|
4749
|
-
await this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
|
|
4735
|
+
let out = await this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
|
|
4736
|
+
let traffic_source = util/* default.get */.Z.get(out, 'body.by.device.source', '');
|
|
4737
|
+
if (traffic_source) this.kv.put('traffic_source', traffic_source);
|
|
4750
4738
|
this.sendPresence();
|
|
4751
4739
|
}
|
|
4752
4740
|
|
|
@@ -5059,12 +5047,10 @@ class Store {
|
|
|
5059
5047
|
}
|
|
5060
5048
|
|
|
5061
5049
|
logBotRun(botid) {
|
|
5062
|
-
let session = this.matchSession();
|
|
5063
5050
|
let log = this.kv.match('bot_run_logs') || {};
|
|
5064
5051
|
log[botid] = {
|
|
5065
5052
|
bot_id: botid,
|
|
5066
|
-
created: this.now()
|
|
5067
|
-
session_id: session.id
|
|
5053
|
+
created: this.now()
|
|
5068
5054
|
};
|
|
5069
5055
|
this.kv.put('bot_run_logs', log);
|
|
5070
5056
|
}
|
|
@@ -5072,11 +5058,9 @@ class Store {
|
|
|
5072
5058
|
sendImpression(id) {
|
|
5073
5059
|
let user = this.kv.match('user') || {};
|
|
5074
5060
|
let log = this.kv.match('plugin_run_logs') || {};
|
|
5075
|
-
let session = this.matchSession();
|
|
5076
5061
|
log[id] = {
|
|
5077
5062
|
web_plugin_id: id,
|
|
5078
|
-
created: this.now()
|
|
5079
|
-
session_id: session.id
|
|
5063
|
+
created: this.now()
|
|
5080
5064
|
};
|
|
5081
5065
|
this.kv.put('plugin_run_logs', log);
|
|
5082
5066
|
return this.api.sendImpression({
|
|
@@ -5085,8 +5069,7 @@ class Store {
|
|
|
5085
5069
|
web_plugin_id: id,
|
|
5086
5070
|
user_id: user.id,
|
|
5087
5071
|
url: window.location.href,
|
|
5088
|
-
device: this.device
|
|
5089
|
-
session_id: session.id
|
|
5072
|
+
device: this.device
|
|
5090
5073
|
});
|
|
5091
5074
|
}
|
|
5092
5075
|
|
|
@@ -5108,8 +5091,7 @@ class Store {
|
|
|
5108
5091
|
url: window.location.href,
|
|
5109
5092
|
device: this.device,
|
|
5110
5093
|
submission,
|
|
5111
|
-
impression_token: impressionToken
|
|
5112
|
-
session_id: this.matchSession().id
|
|
5094
|
+
impression_token: impressionToken
|
|
5113
5095
|
});
|
|
5114
5096
|
}
|
|
5115
5097
|
|
|
@@ -5152,7 +5134,7 @@ class Store {
|
|
|
5152
5134
|
|
|
5153
5135
|
async loopTime() {
|
|
5154
5136
|
let startms = util/* default.Date.now */.Z.Date.now();
|
|
5155
|
-
if (!util/* default.get */.Z.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(),
|
|
5137
|
+
if (!util/* default.get */.Z.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(), 240000);
|
|
5156
5138
|
let {
|
|
5157
5139
|
body: t,
|
|
5158
5140
|
error
|
|
@@ -5162,7 +5144,7 @@ class Store {
|
|
|
5162
5144
|
var serverMs = new util/* default.Date */.Z.Date(t).getTime() + latences;
|
|
5163
5145
|
var localMs = util/* default.Date.now */.Z.Date.now();
|
|
5164
5146
|
this.timeDiff = Math.floor(serverMs - localMs);
|
|
5165
|
-
setTimeout(() => this.loopTime(),
|
|
5147
|
+
setTimeout(() => this.loopTime(), 240000);
|
|
5166
5148
|
}
|
|
5167
5149
|
|
|
5168
5150
|
replaceFileUrl(src) {
|
package/index.html
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
window.subiz.q = []
|
|
34
34
|
// set account it in the very first call
|
|
35
35
|
window.subiz('setAccount', accid)
|
|
36
|
-
window.subiz('expandWidget')
|
|
36
|
+
// window.subiz('expandWidget')
|
|
37
37
|
|
|
38
38
|
if (accid == 'acpxkgumifuoofoosble') {
|
|
39
39
|
window.subiz('setViewingProduct', {id: '220170', sku: 'ipx', source_id: 'IPHONE10'})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.87",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -14,28 +14,28 @@
|
|
|
14
14
|
"@subiz/storage": "0.0.8",
|
|
15
15
|
"@subiz/wsclient": "^3.1.7",
|
|
16
16
|
"cookie_js": "1.4.2",
|
|
17
|
-
"core-js": "^3.
|
|
17
|
+
"core-js": "^3.25.0",
|
|
18
18
|
"css-loader": "5.2.7",
|
|
19
19
|
"file-loader": "^6.2.0",
|
|
20
20
|
"less": "^4.1.3",
|
|
21
21
|
"less-loader": "^11.0.0",
|
|
22
|
-
"marked": "^4.0.
|
|
23
|
-
"preact": "^10.10.
|
|
22
|
+
"marked": "^4.0.19",
|
|
23
|
+
"preact": "^10.10.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@babel/cli": "^7.18.
|
|
27
|
-
"@babel/core": "^7.18.
|
|
26
|
+
"@babel/cli": "^7.18.10",
|
|
27
|
+
"@babel/core": "^7.18.13",
|
|
28
28
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
29
|
-
"@babel/plugin-transform-react-jsx": "^7.18.
|
|
30
|
-
"@babel/preset-env": "^7.18.
|
|
29
|
+
"@babel/plugin-transform-react-jsx": "^7.18.10",
|
|
30
|
+
"@babel/preset-env": "^7.18.10",
|
|
31
31
|
"babel-loader": "^8.2.5",
|
|
32
32
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
33
33
|
"html-webpack-plugin": "^5.5.0",
|
|
34
34
|
"prettier": "^2.7.1",
|
|
35
35
|
"puppeteer": "^15.4.0",
|
|
36
|
-
"webpack": "^5.
|
|
37
|
-
"webpack-bundle-analyzer": "^4.
|
|
36
|
+
"webpack": "^5.74.0",
|
|
37
|
+
"webpack-bundle-analyzer": "^4.6.1",
|
|
38
38
|
"webpack-cli": "^4.10.0",
|
|
39
|
-
"webpack-dev-server": "^4.
|
|
39
|
+
"webpack-dev-server": "^4.10.1"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -10,6 +10,26 @@ export default class AgentsAvatar extends Com {
|
|
|
10
10
|
|
|
11
11
|
render() {
|
|
12
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
|
+
|
|
13
33
|
let agentM = this.props.store.matchAgent('*')
|
|
14
34
|
var agents = sb.map(this.props.agent_ids, (id) => agentM[id])
|
|
15
35
|
if (this.props.agent_ids === undefined || sb.size(this.props.agent_ids) === 0) {
|
|
@@ -23,10 +43,6 @@ export default class AgentsAvatar extends Com {
|
|
|
23
43
|
}
|
|
24
44
|
|
|
25
45
|
agents = sb.filter(agents, (ag) => !!ag)
|
|
26
|
-
let acc = this.props.store.matchAccount()
|
|
27
|
-
|
|
28
|
-
var tooltippos = this.props.tooltipPos || 'bottom'
|
|
29
|
-
var mode = this.props.mode || 'primary'
|
|
30
46
|
if (agents.length === 0) {
|
|
31
47
|
// use account avatar
|
|
32
48
|
return (
|
|
@@ -53,7 +69,8 @@ export default class AgentsAvatar extends Com {
|
|
|
53
69
|
<div
|
|
54
70
|
class='d-inline-block pos-relative'
|
|
55
71
|
data-tooltip={agent.fullname || acc.name}
|
|
56
|
-
data-tooltip-position={tooltippos}
|
|
72
|
+
data-tooltip-position={tooltippos}
|
|
73
|
+
>
|
|
57
74
|
<img
|
|
58
75
|
width={35}
|
|
59
76
|
height={35}
|
|
@@ -75,7 +92,8 @@ export default class AgentsAvatar extends Com {
|
|
|
75
92
|
<div
|
|
76
93
|
class='d-inline-block pos-relative'
|
|
77
94
|
data-tooltip={leftAgent.fullname || acc.name}
|
|
78
|
-
data-tooltip-position={tooltippos}
|
|
95
|
+
data-tooltip-position={tooltippos}
|
|
96
|
+
>
|
|
79
97
|
<img
|
|
80
98
|
width={35}
|
|
81
99
|
height={35}
|
|
@@ -89,7 +107,8 @@ export default class AgentsAvatar extends Com {
|
|
|
89
107
|
<div
|
|
90
108
|
class='d-inline-block pos-relative'
|
|
91
109
|
data-tooltip={rightAgent.fullname || acc.name}
|
|
92
|
-
data-tooltip-position={tooltippos}
|
|
110
|
+
data-tooltip-position={tooltippos}
|
|
111
|
+
>
|
|
93
112
|
<img
|
|
94
113
|
alt='agent avatar right'
|
|
95
114
|
width={35}
|
|
@@ -114,7 +133,8 @@ export default class AgentsAvatar extends Com {
|
|
|
114
133
|
<div
|
|
115
134
|
class='d-inline-block pos-relative'
|
|
116
135
|
data-tooltip={leftAgent.fullname || acc.name}
|
|
117
|
-
data-tooltip-position={tooltippos}
|
|
136
|
+
data-tooltip-position={tooltippos}
|
|
137
|
+
>
|
|
118
138
|
<img
|
|
119
139
|
width={35}
|
|
120
140
|
height={35}
|
|
@@ -128,7 +148,8 @@ export default class AgentsAvatar extends Com {
|
|
|
128
148
|
<div
|
|
129
149
|
class='d-inline-block pos-relative'
|
|
130
150
|
data-tooltip={middleAgent.fullname || acc.name}
|
|
131
|
-
data-tooltip-position={tooltippos}
|
|
151
|
+
data-tooltip-position={tooltippos}
|
|
152
|
+
>
|
|
132
153
|
<img
|
|
133
154
|
alt='agent avatar middle'
|
|
134
155
|
width={35}
|
|
@@ -142,7 +163,8 @@ export default class AgentsAvatar extends Com {
|
|
|
142
163
|
<div
|
|
143
164
|
class='d-inline-block pos-relative'
|
|
144
165
|
data-tooltip={rightAgent.fullname || acc.name}
|
|
145
|
-
data-tooltip-position={tooltippos}
|
|
166
|
+
data-tooltip-position={tooltippos}
|
|
167
|
+
>
|
|
146
168
|
<img
|
|
147
169
|
width={35}
|
|
148
170
|
height={35}
|
|
@@ -175,6 +175,13 @@ export default class ChatButton extends Com {
|
|
|
175
175
|
position = sb.get(accountSetting, 'mobile_button.position') || position
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
179
|
+
agent = Object.assign({}, account, {
|
|
180
|
+
avatar_url: account.logo_url || require('../../assets/img/image_default.png'),
|
|
181
|
+
fullname: account.name || this.props.t('agent'),
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
178
185
|
let cls = 'widget-preview widget-preview--' + position
|
|
179
186
|
if (!this.state.displayPreview) cls += ' widget-preview--hidden'
|
|
180
187
|
|
package/src/chatbox/Event.js
CHANGED
|
@@ -90,6 +90,15 @@ export default class Event extends Com {
|
|
|
90
90
|
let acc = this.props.store.matchAccount()
|
|
91
91
|
var uri = acc.logo_url || require('../../assets/img/image_default.png')
|
|
92
92
|
|
|
93
|
+
if (true || sb.get(this.props, 'chatbox.hide_agent_profile')) {
|
|
94
|
+
return (
|
|
95
|
+
<div class='message-sender'>
|
|
96
|
+
<img alt='sender' class='message-sender-avatar' src={this.props.store.replaceFileUrl(uri)} />
|
|
97
|
+
<p class='message-sender-name'>{acc.name}</p>
|
|
98
|
+
</div>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
let agentM = this.props.store.matchAgent('*')
|
|
94
103
|
// should replace with subiz logo
|
|
95
104
|
if (byid !== 'system' || bytype !== 'dummy') {
|
|
@@ -130,7 +139,7 @@ export default class Event extends Com {
|
|
|
130
139
|
<AudioAttachments store={this.props.store} ev={ev} />
|
|
131
140
|
<VideoAttachments store={this.props.store} ev={ev} />
|
|
132
141
|
<FileAttachments store={this.props.store} ev={ev} />
|
|
133
|
-
<ButtonAttachments store={this.props.store} ev={ev} t={this.props.t}/>
|
|
142
|
+
<ButtonAttachments store={this.props.store} ev={ev} t={this.props.t} />
|
|
134
143
|
<FormAttachments
|
|
135
144
|
store={this.props.store}
|
|
136
145
|
onSubmit={this.props.onFormSubmit}
|
|
@@ -139,8 +148,18 @@ export default class Event extends Com {
|
|
|
139
148
|
t={this.props.t}
|
|
140
149
|
/>
|
|
141
150
|
<FormSubmitAttachments store={this.props.store} ev={ev} t={this.props.t} />
|
|
142
|
-
<GenericTemplateAttachments
|
|
143
|
-
|
|
151
|
+
<GenericTemplateAttachments
|
|
152
|
+
store={this.props.store}
|
|
153
|
+
ev={ev}
|
|
154
|
+
onSelect={(e) => this.choosePostbackBtn(e)}
|
|
155
|
+
t={this.props.t}
|
|
156
|
+
/>
|
|
157
|
+
<ProductAttachments
|
|
158
|
+
t={this.props.t}
|
|
159
|
+
onPostback={(e) => this.choosePostbackBtn(e)}
|
|
160
|
+
store={this.props.store}
|
|
161
|
+
ev={ev}
|
|
162
|
+
/>
|
|
144
163
|
<OrderAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
145
164
|
<QuickReplies store={this.props.store} ev={ev} onSelect={(e) => this.chooseQuickReply(e)} />
|
|
146
165
|
</div>
|
|
@@ -182,7 +201,7 @@ export default class Event extends Com {
|
|
|
182
201
|
<AudioAttachments store={this.props.store} ev={ev} />
|
|
183
202
|
<VideoAttachments store={this.props.store} ev={ev} />
|
|
184
203
|
<FileAttachments store={this.props.store} ev={ev} />
|
|
185
|
-
<ButtonAttachments store={this.props.store} ev={ev} t={this.props.t}/>
|
|
204
|
+
<ButtonAttachments store={this.props.store} ev={ev} t={this.props.t} />
|
|
186
205
|
<FormAttachments store={this.props.store} onSubmit={this.props.onFormSubmit} ref={this.refForm} ev={ev} />
|
|
187
206
|
<ProductAttachments t={this.props.t} store={this.props.store} ev={ev} />
|
|
188
207
|
<FormSubmitAttachments store={this.props.store} ev={ev} />
|
package/src/chatbox/Events.js
CHANGED
|
@@ -57,6 +57,7 @@ export default class Events extends Com {
|
|
|
57
57
|
|
|
58
58
|
let $events = sb.map(events, (ev) => (
|
|
59
59
|
<Event
|
|
60
|
+
chatbox={this.props.chatbox}
|
|
60
61
|
onLink={this.props.onLink}
|
|
61
62
|
store={this.props.store}
|
|
62
63
|
onFormSubmit={this.props.onFormSubmit}
|
|
@@ -82,7 +83,8 @@ export default class Events extends Com {
|
|
|
82
83
|
style={style}
|
|
83
84
|
ref={(ref) => (this.refBody = ref)}
|
|
84
85
|
class='widget-body--events-container'
|
|
85
|
-
onMouseOver={this.checkAndSeen}
|
|
86
|
+
onMouseOver={this.checkAndSeen}
|
|
87
|
+
>
|
|
86
88
|
<div class='widget-body--events'>{$events}</div>
|
|
87
89
|
<PoweredBy store={this.props.store} />
|
|
88
90
|
</div>
|
|
@@ -21,7 +21,7 @@ export default class MessageInput extends Com {
|
|
|
21
21
|
this.forceUpdate()
|
|
22
22
|
}, 500)
|
|
23
23
|
|
|
24
|
-
this.resizeInput = sb.throttle(function() {
|
|
24
|
+
this.resizeInput = sb.throttle(function () {
|
|
25
25
|
// TODO: ctrl+A then press backspace dont reset size rightaway
|
|
26
26
|
const input = this.refMessageInput.current
|
|
27
27
|
input.style.setProperty('height', '1em', 'important')
|
|
@@ -30,6 +30,12 @@ export default class MessageInput extends Com {
|
|
|
30
30
|
}, 5)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
blur() {
|
|
34
|
+
const $input = this.refMessageInput.current
|
|
35
|
+
if (!$input) return
|
|
36
|
+
$input.blur()
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
render() {
|
|
34
40
|
var buttons = (
|
|
35
41
|
<div class='d-flex flex-row align-self-end'>
|
|
@@ -37,7 +43,8 @@ export default class MessageInput extends Com {
|
|
|
37
43
|
<div
|
|
38
44
|
data-tooltip-poasition='top-left'
|
|
39
45
|
class='message-input--button message-input--attachment-button'
|
|
40
|
-
onClick={(e) => this.selectFile(e)}
|
|
46
|
+
onClick={(e) => this.selectFile(e)}
|
|
47
|
+
></div>
|
|
41
48
|
</div>
|
|
42
49
|
)
|
|
43
50
|
var msg = sb.trim(this.refMessageInput.current && this.refMessageInput.current.value)
|
|
@@ -48,7 +55,8 @@ export default class MessageInput extends Com {
|
|
|
48
55
|
<div
|
|
49
56
|
data-tooltip-position='top-left'
|
|
50
57
|
class='message-input--button message-input--send-button'
|
|
51
|
-
onClick={() => this.submitMessage()}
|
|
58
|
+
onClick={() => this.submitMessage()}
|
|
59
|
+
></div>
|
|
52
60
|
</div>
|
|
53
61
|
)
|
|
54
62
|
}
|
|
@@ -62,7 +70,8 @@ export default class MessageInput extends Com {
|
|
|
62
70
|
class={`message-input ${containercls}`}
|
|
63
71
|
onClick={(e) => {
|
|
64
72
|
this.refMessageInput.current && this.refMessageInput.current.focus()
|
|
65
|
-
}}
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
66
75
|
<input class='d-none' ref={this.refFileInput} type='file' onChange={(e) => this.sendFile(e)} multiple />
|
|
67
76
|
<textarea
|
|
68
77
|
disabled={disabled}
|
|
@@ -258,7 +267,7 @@ export default class MessageInput extends Com {
|
|
|
258
267
|
input.focus()
|
|
259
268
|
}
|
|
260
269
|
|
|
261
|
-
onEnter = sb.throttle(function() {
|
|
270
|
+
onEnter = sb.throttle(function () {
|
|
262
271
|
this.submitMessage()
|
|
263
272
|
}, 50)
|
|
264
273
|
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -18,7 +18,7 @@ const defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_defaul
|
|
|
18
18
|
import Spinner from './spinner.js'
|
|
19
19
|
import Time from './time.js'
|
|
20
20
|
import {Com} from '../common.js'
|
|
21
|
-
import {h} from 'preact'
|
|
21
|
+
import {h, createRef} from 'preact'
|
|
22
22
|
|
|
23
23
|
// ['cid', 'view', 'isShow'], // view: chat, list
|
|
24
24
|
export default class Widget extends Com {
|
|
@@ -36,6 +36,7 @@ export default class Widget extends Com {
|
|
|
36
36
|
this.props.store.onUpdate(this, (_) => this.forceUpdate())
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
msgInput = createRef()
|
|
39
40
|
componentDidMount() {
|
|
40
41
|
if (!this.props.store.isMobile()) this.focusInput()
|
|
41
42
|
}
|
|
@@ -484,7 +485,7 @@ export default class Widget extends Com {
|
|
|
484
485
|
|
|
485
486
|
blur() {
|
|
486
487
|
if (this.props.store.isPreview) return
|
|
487
|
-
var $input = this.msgInput
|
|
488
|
+
var $input = this.msgInput.current
|
|
488
489
|
if (!$input) return
|
|
489
490
|
setTimeout(() => $input && $input.blur())
|
|
490
491
|
setTimeout(() => $input && $input.blur(), 300) // force lose focus
|
|
@@ -512,7 +513,7 @@ export default class Widget extends Com {
|
|
|
512
513
|
return
|
|
513
514
|
}
|
|
514
515
|
|
|
515
|
-
var $input = this.msgInput
|
|
516
|
+
var $input = this.msgInput.current
|
|
516
517
|
if (!$input) return
|
|
517
518
|
setTimeout(() => $input.focus())
|
|
518
519
|
setTimeout(() => $input.focus(), 300) // force focus
|
|
@@ -524,7 +525,7 @@ export default class Widget extends Com {
|
|
|
524
525
|
this.focusInput()
|
|
525
526
|
}
|
|
526
527
|
|
|
527
|
-
async
|
|
528
|
+
sendMessage = async (message) => {
|
|
528
529
|
let text = message.text
|
|
529
530
|
if (!this.props.cid) {
|
|
530
531
|
this.creating = true
|
|
@@ -554,9 +555,9 @@ export default class Widget extends Com {
|
|
|
554
555
|
let $input = (
|
|
555
556
|
<MessageInput
|
|
556
557
|
store={this.props.store}
|
|
557
|
-
ref={
|
|
558
|
+
ref={this.msgInput}
|
|
558
559
|
cid={this.props.cid}
|
|
559
|
-
onSend={
|
|
560
|
+
onSend={this.sendMessage}
|
|
560
561
|
t={this.props.t}
|
|
561
562
|
/>
|
|
562
563
|
)
|
|
@@ -578,6 +579,7 @@ export default class Widget extends Com {
|
|
|
578
579
|
isShow={this.props.isShow}
|
|
579
580
|
onLink={this.onLink}
|
|
580
581
|
store={this.props.store}
|
|
582
|
+
chatbox={this.props.plugin.chatbox || {}}
|
|
581
583
|
onFormSubmit={(e) => this.onEventFormSubmit(e)}
|
|
582
584
|
ref={(ref) => (this.events = ref)}
|
|
583
585
|
cid={this.props.cid}
|
|
@@ -679,6 +681,7 @@ export default class Widget extends Com {
|
|
|
679
681
|
}
|
|
680
682
|
|
|
681
683
|
renderConvoSummary(convo) {
|
|
684
|
+
let accountSetting = this.props.plugin.chatbox || {}
|
|
682
685
|
let agentM = this.props.store.matchAgent('*')
|
|
683
686
|
|
|
684
687
|
let ags = sb.filter(convo.members, (m) => {
|
|
@@ -688,9 +691,8 @@ export default class Widget extends Com {
|
|
|
688
691
|
agentids = agentids || sb.agentsOfConvo(convo)[0]
|
|
689
692
|
|
|
690
693
|
let agents = sb.map(agentids, (id) => agentM[id] || {avatar_url: defaultAvatar, fullname: 'Offline Agent'})
|
|
691
|
-
|
|
692
694
|
var name = sb.each(agents, (ag) => ag.fullname).join(', ')
|
|
693
|
-
if (!name) name = this.props.store.matchAccount().name
|
|
695
|
+
if (accountSetting.hide_agent_profile || !name) name = this.props.store.matchAccount().name
|
|
694
696
|
if (!name) name = this.props.t('agent')
|
|
695
697
|
|
|
696
698
|
var $you = null
|
|
@@ -699,7 +701,6 @@ export default class Widget extends Com {
|
|
|
699
701
|
}
|
|
700
702
|
|
|
701
703
|
let seen = sb.isConvoSeen(convo, this.props.store.matchUser().id)
|
|
702
|
-
|
|
703
704
|
var lastmsg = this.renderMessagePreview(convo.last_message_sent || {data: {message: sb.get(convo, 'last_message')}})
|
|
704
705
|
|
|
705
706
|
var time =
|
package/src/chatbox/main.js
CHANGED
|
@@ -125,8 +125,15 @@ export default class Main extends Com {
|
|
|
125
125
|
}
|
|
126
126
|
p = p || {}
|
|
127
127
|
|
|
128
|
-
if (
|
|
128
|
+
if (!p.view && !p.cid) {
|
|
129
|
+
let convoM = this.props.store.matchConvo('*')
|
|
130
|
+
let redconvo = sb.find(convoM, (convo) => !sb.isConvoSeen(convo, this.props.store.matchUser().id))
|
|
131
|
+
// try to show first convo
|
|
132
|
+
p.cid = sb.get(redconvo, 'id', sb.get(convoM, '0.id'))
|
|
133
|
+
p.view = 'chat'
|
|
134
|
+
}
|
|
129
135
|
|
|
136
|
+
if (this.props.store.isMobile()) modifyViewport()
|
|
130
137
|
this.setState({widgetConvoId: p.cid, widgetView: p.view})
|
|
131
138
|
this.props.store.setIsOpen(true)
|
|
132
139
|
|
package/src/popup/popup.js
CHANGED
|
@@ -215,12 +215,25 @@ export default class Popup extends Com {
|
|
|
215
215
|
|
|
216
216
|
let user = sb.cloneDeep(this.props.store.matchUser())
|
|
217
217
|
let is_lead = false
|
|
218
|
+
|
|
219
|
+
// modified pairs to convert data of multiple-choice value ['khu_vuc', '1'], ['khu_vuc', '2'] => ['khu_vuc', '1,2']
|
|
220
|
+
let modifiedPairs = {}
|
|
218
221
|
for (var pair of formData.entries()) {
|
|
222
|
+
if (modifiedPairs[pair[0]]) {
|
|
223
|
+
let currentValue = sb.get(modifiedPairs, `${pair[0]}.1`, '')
|
|
224
|
+
currentValue += `,${pair[1]}`
|
|
225
|
+
sb.set(modifiedPairs, `${pair[0]}.1`, currentValue)
|
|
226
|
+
} else {
|
|
227
|
+
modifiedPairs[pair[0]] = [pair[0], pair[1]]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
for (const [_, pair] of Object.entries(modifiedPairs)) {
|
|
219
232
|
let page = sb.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`)
|
|
220
233
|
let form = sb.find(page.components, (com) => com.type === 'form')
|
|
221
234
|
let fields = sb.get(form, 'form.fields', [])
|
|
222
235
|
|
|
223
|
-
let field = sb.find(fields, (field) => field.key === pair[0])
|
|
236
|
+
let field = sb.find(fields, (field) => field.key === pair[0]) || {}
|
|
224
237
|
if (!field.type) return
|
|
225
238
|
|
|
226
239
|
summitFields.push({key: pair[0], type: field.type, value: sb.stringify(pair[1])})
|