@subiz/widget-v4 4.1.179 → 4.1.185
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/assets/less/widget.less +40 -6
- package/assets/less/widget_header.less +2 -1
- package/chat.js +0 -1
- package/compiled_src/chatbox/ChatButton.js +107 -54
- package/compiled_src/chatbox/Widget.js +2 -1
- package/compiled_src/chatbox/main.js +9 -5
- package/compiled_src/store/store.js +38 -10
- package/package.json +1 -1
- package/src/chatbox/ChatButton.js +111 -58
- package/src/chatbox/Widget.js +4 -1
- package/src/chatbox/main.js +5 -5
- package/src/store/store.js +49 -18
- package/dist/127.js +0 -273
- package/dist/132.js +0 -2802
- package/dist/185.js +0 -1827
- package/dist/1991cfb4656.127.js +0 -1
- package/dist/1991cfb4656.132.js +0 -1
- package/dist/1991cfb4656.185.js +0 -1
- package/dist/1991cfb4656.27.js +0 -1
- package/dist/1991cfb4656.278.js +0 -1
- package/dist/1991cfb4656.339.js +0 -1
- package/dist/1991cfb4656.459.js +0 -1
- package/dist/1991cfb4656.490.js +0 -1
- package/dist/1991cfb4656.74.js +0 -1
- package/dist/1991cfb4656.997.js +0 -1
- package/dist/1991cfb4656.app.js +0 -1
- package/dist/1991cfb4656.chat.html +0 -1
- package/dist/1991cfb4656.chat.js +0 -1
- package/dist/1991cfb4656.form.html +0 -1
- package/dist/1991cfb4656.form.js +0 -1
- package/dist/1991cfb4656.index.html +0 -72
- package/dist/1991cfb4656.library.html +0 -72
- package/dist/1991cfb4656.library.js +0 -1
- package/dist/1991cfb4656.preview.html +0 -759
- package/dist/1991cfb4656.preview.js +0 -1
- package/dist/1991cfb4656.webview.js +0 -1
- package/dist/27.js +0 -107
- package/dist/278.js +0 -417
- package/dist/459.js +0 -107
- package/dist/490.js +0 -305
- package/dist/74.js +0 -372
- package/dist/997.js +0 -107
- package/dist/HASH +0 -1
- package/dist/assets/img/Facebook.64607ec.png +0 -0
- package/dist/assets/img/Zalo.6845707.png +0 -0
- package/dist/assets/img/award1a.1a58e10.png +0 -0
- package/dist/assets/img/award3a.3b74423.png +0 -0
- package/dist/assets/img/award4a.ed6ccd4.png +0 -0
- package/dist/assets/img/award5.39eb7ae.png +0 -0
- package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
- package/dist/assets/img/caret.998eb8f.svg +0 -1
- package/dist/assets/img/convos_empty.2353007.svg +0 -72
- package/dist/assets/img/default.06e6ee0.jpg +0 -0
- package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
- package/dist/assets/img/done_gray.d7e8203.svg +0 -4
- package/dist/assets/img/done_green.b817fd4.svg +0 -4
- package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
- package/dist/assets/img/empty.29bed2d.svg +0 -23
- package/dist/assets/img/empty_1.0b98af0.svg +0 -11
- package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
- package/dist/assets/img/external-link.90577cc.svg +0 -1
- package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
- package/dist/assets/img/ghn.070f8e3.svg +0 -17
- package/dist/assets/img/ghtk.326eac1.svg +0 -18
- package/dist/assets/img/image_default.be0698b.png +0 -0
- package/dist/assets/img/info.ebce7ea.svg +0 -1
- package/dist/assets/img/loader.37000a7.svg +0 -1
- package/dist/assets/img/loading_static.a27f0ac.svg +0 -10
- package/dist/assets/img/main-service1.d536cc2.png +0 -0
- package/dist/assets/img/main-service2.9b99549.png +0 -0
- package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
- package/dist/assets/img/package.8d37d0f.svg +0 -5
- package/dist/assets/img/package_fade.763c001.svg +0 -1
- package/dist/assets/img/rating--average.1ea492c.svg +0 -12
- package/dist/assets/img/rating--great.e3d712e.svg +0 -16
- package/dist/assets/img/rating--poor.2938a25.svg +0 -12
- package/dist/assets/img/search.f9705ff.svg +0 -1
- package/dist/assets/img/send.6db52a9.svg +0 -3
- package/dist/assets/img/shop.f7dc7d8.svg +0 -1
- package/dist/assets/img/shop_faded.df7845a.svg +0 -1
- package/dist/assets/img/stars_v2.79cf728.png +0 -0
- package/dist/assets/img/subiz-mono.8fbc067.svg +0 -3
- package/dist/assets/img/x.26fdfa3.svg +0 -5
- package/dist/malicious-app.js +0 -17
- package/dist/screenshoot.html +0 -7
- package/dist/screenshoot.js +0 -11988
package/assets/less/widget.less
CHANGED
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
position: relative;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
.
|
|
294
|
+
.embed-chat {
|
|
295
295
|
.widget-body--events {
|
|
296
296
|
width: 600px;
|
|
297
297
|
margin: 0 auto;
|
|
@@ -302,6 +302,23 @@
|
|
|
302
302
|
max-width: 600px;
|
|
303
303
|
margin: 20px auto;
|
|
304
304
|
}
|
|
305
|
+
|
|
306
|
+
.widget-header--inner {
|
|
307
|
+
max-width: 100%;
|
|
308
|
+
width: 600px;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.widget-body--content {
|
|
312
|
+
width: 600px;
|
|
313
|
+
margin: 0 auto;
|
|
314
|
+
max-width: 100%;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.convo-list {
|
|
318
|
+
width: 600px;
|
|
319
|
+
margin: 0 auto;
|
|
320
|
+
max-width: 100%;
|
|
321
|
+
}
|
|
305
322
|
}
|
|
306
323
|
|
|
307
324
|
.widget-body--content {
|
|
@@ -402,9 +419,13 @@
|
|
|
402
419
|
scale: 1;
|
|
403
420
|
transition:
|
|
404
421
|
filter 250ms ease,
|
|
405
|
-
opacity 0.
|
|
422
|
+
opacity 0.15s ease-in,
|
|
406
423
|
scale 0.125s ease-in-out,
|
|
407
424
|
transform 0.2s ease-in-out;
|
|
425
|
+
|
|
426
|
+
&.hidden {
|
|
427
|
+
opacity: 0;
|
|
428
|
+
}
|
|
408
429
|
}
|
|
409
430
|
|
|
410
431
|
.chat-button:hover {
|
|
@@ -585,7 +606,7 @@
|
|
|
585
606
|
width: 24px;
|
|
586
607
|
height: 24px;
|
|
587
608
|
flex-shrink: 0;
|
|
588
|
-
|
|
609
|
+
margin-right: 10px;
|
|
589
610
|
}
|
|
590
611
|
}
|
|
591
612
|
|
|
@@ -594,20 +615,23 @@
|
|
|
594
615
|
overflow: hidden;
|
|
595
616
|
display: flex;
|
|
596
617
|
align-items: center;
|
|
618
|
+
|
|
619
|
+
.badge {
|
|
620
|
+
margin-left: 10px;
|
|
621
|
+
}
|
|
597
622
|
}
|
|
598
623
|
|
|
599
624
|
.widget-preview-text-message--author-text {
|
|
600
625
|
text-overflow: ellipsis;
|
|
601
626
|
white-space: nowrap;
|
|
602
627
|
overflow: hidden;
|
|
603
|
-
margin-right: 10px;
|
|
604
628
|
line-height: 1.5;
|
|
605
629
|
.color(@secondary-color);
|
|
606
630
|
}
|
|
607
631
|
|
|
608
632
|
.widget-preview-text-message--content {
|
|
609
633
|
margin-top: 10px;
|
|
610
|
-
|
|
634
|
+
white-space: pre-wrap;
|
|
611
635
|
}
|
|
612
636
|
|
|
613
637
|
.widget-preview-quick-reply-wrapper {
|
|
@@ -680,6 +704,7 @@
|
|
|
680
704
|
border: 1px solid @border;
|
|
681
705
|
border-radius: 15px;
|
|
682
706
|
max-width: 100%;
|
|
707
|
+
min-width: 210px;
|
|
683
708
|
margin-bottom: 15px;
|
|
684
709
|
padding: 15px 20px;
|
|
685
710
|
positive: relative;
|
|
@@ -696,9 +721,18 @@
|
|
|
696
721
|
.widget-preview-new-wrapper {
|
|
697
722
|
max-width: 340px;
|
|
698
723
|
position: relative;
|
|
724
|
+
opacity: 1;
|
|
725
|
+
transition:
|
|
726
|
+
opacity 0.15s ease-in,
|
|
727
|
+
transform 0.15s ease-in;
|
|
728
|
+
transform: translateY(0);
|
|
699
729
|
|
|
700
730
|
&.hidden {
|
|
701
|
-
|
|
731
|
+
transform: translateY(20px);
|
|
732
|
+
transition:
|
|
733
|
+
opacity 0.15s ease-out,
|
|
734
|
+
transform 0.15s ease-out;
|
|
735
|
+
opacity: 0;
|
|
702
736
|
}
|
|
703
737
|
|
|
704
738
|
&:hover {
|
package/chat.js
CHANGED
|
@@ -15,10 +15,14 @@ let defaultAvatar = require('../../assets/img/default_avatar.png');
|
|
|
15
15
|
class ChatButton extends _common.Com {
|
|
16
16
|
constructor(props) {
|
|
17
17
|
super(props);
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
this.state = {
|
|
19
|
+
hasPreviewDom: false,
|
|
20
|
+
previewExtraCls: 'hidden',
|
|
21
|
+
previewEvent: {},
|
|
22
|
+
ready: false
|
|
23
|
+
};
|
|
24
|
+
this.readyGate = new _index.default.Gate();
|
|
25
|
+
this.prepareButtonImage();
|
|
22
26
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
23
27
|
this.props.store.onConvoEvent(this, ev => {
|
|
24
28
|
if (_index.default.get(ev, 'type') !== 'message_sent') return;
|
|
@@ -56,6 +60,17 @@ class ChatButton extends _common.Com {
|
|
|
56
60
|
});
|
|
57
61
|
this.forceUpdate();
|
|
58
62
|
});
|
|
63
|
+
this.props.store.onLastview(this, () => {
|
|
64
|
+
let screen = _index.default.get(this.props.store.matchLastview(), 'screen');
|
|
65
|
+
let previewEvent = _index.default.get(this.props.store.matchLastview(), 'previewEvent') || {};
|
|
66
|
+
let isOpen = screen === 'preview' && _index.default.size(previewEvent) > 0;
|
|
67
|
+
if (isOpen) {
|
|
68
|
+
this.makeAnimateShowPreview(previewEvent);
|
|
69
|
+
} else {
|
|
70
|
+
this.makeAnimateHidePreview();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this.loadGreeting();
|
|
59
74
|
}
|
|
60
75
|
fixMissingSetting(chatbox) {
|
|
61
76
|
chatbox = _index.default.cloneDeep(chatbox);
|
|
@@ -84,14 +99,11 @@ class ChatButton extends _common.Com {
|
|
|
84
99
|
let hiddenButtonDesktop = _index.default.get(accountSetting, 'desktop_button.hidden');
|
|
85
100
|
if (hiddenButtonDesktop) return null;
|
|
86
101
|
let cls = 'widget-layout widget-layout--' + position;
|
|
87
|
-
let opacity = this.state.opacity;
|
|
88
102
|
if (!this.props.isShow) {
|
|
89
103
|
cls += ' widget-layout--hidden';
|
|
90
|
-
opacity = 0;
|
|
91
104
|
}
|
|
92
105
|
return (0, _preact.h)("div", {
|
|
93
|
-
class: cls
|
|
94
|
-
style: 'opacity: ' + opacity + ' !important'
|
|
106
|
+
class: cls
|
|
95
107
|
}, this.renderPreview(), this.renderButton());
|
|
96
108
|
}
|
|
97
109
|
pickBestGreeting() {
|
|
@@ -125,12 +137,57 @@ class ChatButton extends _common.Com {
|
|
|
125
137
|
}
|
|
126
138
|
return unseenConvo[0].last_message_sent;
|
|
127
139
|
}
|
|
128
|
-
|
|
140
|
+
showPreview(ev) {
|
|
129
141
|
this.props.store.updateLastview({
|
|
130
142
|
screen: 'preview',
|
|
131
|
-
previewEvent:
|
|
143
|
+
previewEvent: ev
|
|
132
144
|
});
|
|
133
|
-
|
|
145
|
+
}
|
|
146
|
+
async makeAnimateShowPreview(ev) {
|
|
147
|
+
await this.readyGate.entry();
|
|
148
|
+
let agent = this.getAgentOfPreviewEvent(ev);
|
|
149
|
+
await _index.default.preloadImg(agent.avatar_url);
|
|
150
|
+
if (this.state.hasPreviewDom) {
|
|
151
|
+
this.setState({
|
|
152
|
+
previewExtraCls: 'hidden'
|
|
153
|
+
});
|
|
154
|
+
if (this._animateTimeout) clearTimeout(this._animateTimeout);
|
|
155
|
+
this._animateTimeout = setTimeout(() => {
|
|
156
|
+
this.setState({
|
|
157
|
+
previewExtraCls: '',
|
|
158
|
+
previewEvent: ev
|
|
159
|
+
});
|
|
160
|
+
}, 200);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.setState({
|
|
164
|
+
hasPreviewDom: true,
|
|
165
|
+
previewExtraCls: 'hidden',
|
|
166
|
+
previewEvent: {}
|
|
167
|
+
});
|
|
168
|
+
if (this._animateTimeout) clearTimeout(this._animateTimeout);
|
|
169
|
+
this._animateTimeout = setTimeout(() => {
|
|
170
|
+
this.setState({
|
|
171
|
+
previewExtraCls: '',
|
|
172
|
+
previewEvent: ev
|
|
173
|
+
});
|
|
174
|
+
}, 200);
|
|
175
|
+
}
|
|
176
|
+
makeAnimateHidePreview() {
|
|
177
|
+
if (this._animateTimeout) clearTimeout(this._animateTimeout);
|
|
178
|
+
this.setState({
|
|
179
|
+
previewExtraCls: 'hidden'
|
|
180
|
+
});
|
|
181
|
+
this._animateTimeout = setTimeout(() => {
|
|
182
|
+
this.setState({
|
|
183
|
+
hasPreviewDom: false,
|
|
184
|
+
previewEvent: {}
|
|
185
|
+
});
|
|
186
|
+
}, 200);
|
|
187
|
+
}
|
|
188
|
+
ShowGreeting() {
|
|
189
|
+
let ev = this.pickBestGreeting();
|
|
190
|
+
this.showPreview(ev);
|
|
134
191
|
}
|
|
135
192
|
HideGreeting() {
|
|
136
193
|
this.props.store.updateLastview({
|
|
@@ -138,35 +195,24 @@ class ChatButton extends _common.Com {
|
|
|
138
195
|
minimized: Date.now(),
|
|
139
196
|
previewEvent: {}
|
|
140
197
|
});
|
|
141
|
-
this.forceUpdate();
|
|
142
198
|
}
|
|
143
199
|
loadGreeting() {
|
|
144
200
|
let minimized = _index.default.get(this.props.store.matchLastview(), 'minimized');
|
|
145
201
|
let screen = _index.default.get(this.props.store.matchLastview(), 'screen');
|
|
146
|
-
|
|
147
|
-
if (screen === 'widget') return;
|
|
202
|
+
if (screen !== 'preview') return;
|
|
148
203
|
if (minimized && Date.now() - minimized < Ms30Mins) return;
|
|
204
|
+
let previewEvent = _index.default.get(this.props.store.matchLastview(), 'previewEvent') || {};
|
|
205
|
+
if (_index.default.size(previewEvent) > 0) {
|
|
206
|
+
this.showPreview(previewEvent);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
149
209
|
let accountSetting = this.props.plugin.chatbox;
|
|
150
210
|
let greeting = _index.default.get(accountSetting, 'greeting', {});
|
|
151
211
|
let text = this.props.t.i18n(_index.default.get(greeting, 'greeting', {})) || greeting.message;
|
|
152
212
|
let enabled = greeting.enabled;
|
|
153
|
-
if (this.props.store.isMobile()) {
|
|
154
|
-
enabled = enabled && !_index.default.get(greeting, 'mobile_disabled');
|
|
155
|
-
this.props.store.updateLastview({
|
|
156
|
-
screen: 'button',
|
|
157
|
-
previewEvent: {}
|
|
158
|
-
});
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
213
|
if (!text || !enabled) {
|
|
162
|
-
this.props.store.updateLastview({
|
|
163
|
-
screen: 'button',
|
|
164
|
-
previewEvent: {}
|
|
165
|
-
});
|
|
166
|
-
this.forceUpdate();
|
|
167
214
|
return;
|
|
168
215
|
}
|
|
169
|
-
console.log('loadGreeting pickBestGreeting', this.pickBestGreeting());
|
|
170
216
|
this.ShowGreeting();
|
|
171
217
|
}
|
|
172
218
|
onClick() {
|
|
@@ -204,27 +250,35 @@ class ChatButton extends _common.Com {
|
|
|
204
250
|
class: "chat-button--unread"
|
|
205
251
|
}, unreadcount);
|
|
206
252
|
}
|
|
207
|
-
|
|
253
|
+
getAgentOfPreviewEvent(ev) {
|
|
208
254
|
let account = this.props.store.matchAccount();
|
|
209
|
-
if (!account) return null;
|
|
210
255
|
let accountSetting = this.props.plugin.chatbox;
|
|
211
|
-
let previewEvent =
|
|
256
|
+
let previewEvent = ev;
|
|
212
257
|
let byid = _index.default.get(previewEvent, 'by.display_id', _index.default.get(previewEvent, 'by.id'));
|
|
213
258
|
let agent = this.props.store.matchAgent(byid);
|
|
214
259
|
if (!agent) agent = this.props.store.matchAgent('*')[byid] || {};
|
|
215
260
|
agent = _index.default.cloneDeep(agent);
|
|
216
261
|
agent.fullname = agent.fullname || _index.default.get(account, 'name') || this.props.t('agent');
|
|
217
262
|
agent.avatar_url = agent.avatar_url || account.logo_url || require('../../assets/img/image_default.png');
|
|
218
|
-
let position = _index.default.get(accountSetting, 'desktop_button.position') || 'right';
|
|
219
|
-
if (this.props.store.isMobile()) {
|
|
220
|
-
position = _index.default.get(accountSetting, 'mobile_button.position') || position;
|
|
221
|
-
}
|
|
222
263
|
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
223
264
|
agent = Object.assign({}, account, {
|
|
224
265
|
avatar_url: account.logo_url || require('../../assets/img/image_default.png'),
|
|
225
266
|
fullname: account.name || this.props.t('agent')
|
|
226
267
|
});
|
|
227
268
|
}
|
|
269
|
+
return agent;
|
|
270
|
+
}
|
|
271
|
+
renderPreview() {
|
|
272
|
+
if (this.props.store.isMobile()) return;
|
|
273
|
+
if (!this.state.hasPreviewDom) return;
|
|
274
|
+
let previewEvent = this.state.previewEvent;
|
|
275
|
+
let agent = this.getAgentOfPreviewEvent(previewEvent);
|
|
276
|
+
let account = this.props.store.matchAccount();
|
|
277
|
+
let accountSetting = this.props.plugin.chatbox;
|
|
278
|
+
let position = _index.default.get(accountSetting, 'desktop_button.position') || 'right';
|
|
279
|
+
if (this.props.store.isMobile()) {
|
|
280
|
+
position = _index.default.get(accountSetting, 'mobile_button.position') || position;
|
|
281
|
+
}
|
|
228
282
|
let tags = this.renderMessagePreview(previewEvent);
|
|
229
283
|
let attachments = _index.default.get(previewEvent, 'data.message.attachments') || [];
|
|
230
284
|
let quickReplies = _index.default.find(attachments, att => att.type === 'quick_replies');
|
|
@@ -234,9 +288,8 @@ class ChatButton extends _common.Com {
|
|
|
234
288
|
if (uri && !uri.startsWith('https://') && !uri.startsWith('http://') && !uri.startsWith('content://') && !uri.startsWith('data:')) {
|
|
235
289
|
uri = this.props.store.FileURL + uri;
|
|
236
290
|
}
|
|
237
|
-
let isShowPreview = _index.default.get(this.props.store.matchLastview(), 'screen') === 'preview';
|
|
238
291
|
return (0, _preact.h)("div", {
|
|
239
|
-
class: `widget-preview-new-wrapper ${
|
|
292
|
+
class: `widget-preview-new-wrapper ${this.state.previewExtraCls}`
|
|
240
293
|
}, (0, _preact.h)("div", {
|
|
241
294
|
class: `widget-preview-x-wrapper ${position}`
|
|
242
295
|
}, (0, _preact.h)("div", {
|
|
@@ -250,14 +303,12 @@ class ChatButton extends _common.Com {
|
|
|
250
303
|
}, (0, _preact.h)("img", {
|
|
251
304
|
alt: "widget avatar",
|
|
252
305
|
class: "widget-preview--avatar",
|
|
253
|
-
src: this.props.store.replaceFileUrl(agent.avatar_url)
|
|
254
|
-
onError: ev => this.onProfileError(ev),
|
|
255
|
-
onload: _ => this.onProfileReady()
|
|
306
|
+
src: this.props.store.replaceFileUrl(agent.avatar_url)
|
|
256
307
|
}), (0, _preact.h)("div", {
|
|
257
308
|
class: "widget-preview-text-message--author"
|
|
258
309
|
}, (0, _preact.h)("div", {
|
|
259
310
|
class: "widget-preview-text-message--author-text"
|
|
260
|
-
}, agent.fullname), (0, _preact.h)("div", {
|
|
311
|
+
}, agent.fullname), accountSetting.is_online && (0, _preact.h)("div", {
|
|
261
312
|
class: "badge badge--success"
|
|
262
313
|
}, (0, _preact.h)("div", {
|
|
263
314
|
class: "dot dot--success mr-1"
|
|
@@ -273,6 +324,7 @@ class ChatButton extends _common.Com {
|
|
|
273
324
|
}))), _index.default.size(quickReplies) > 0 && (0, _preact.h)("div", {
|
|
274
325
|
class: `widget-preview-quick-reply-wrapper ${position}`
|
|
275
326
|
}, _index.default.map(quickReplies, reply => {
|
|
327
|
+
if (!(reply.title || '').trim()) return;
|
|
276
328
|
return (0, _preact.h)("div", {
|
|
277
329
|
class: "widget-preview-quick-reply-item",
|
|
278
330
|
onClick: () => {
|
|
@@ -292,17 +344,19 @@ class ChatButton extends _common.Com {
|
|
|
292
344
|
}, reply.title);
|
|
293
345
|
})));
|
|
294
346
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
this.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
347
|
+
async prepareButtonImage() {
|
|
348
|
+
let accountSetting = this.props.plugin.chatbox;
|
|
349
|
+
accountSetting = this.fixMissingSetting(accountSetting);
|
|
350
|
+
let imgsrc = _index.default.get(accountSetting, 'desktop_button.background_image_url') || _index.default.get(accountSetting, 'desktop_button.background_mask_url') || defaultBubble;
|
|
351
|
+
if (this.props.store.isMobile()) {
|
|
352
|
+
imgsrc = _index.default.get(accountSetting, 'mobile_button.background_image_url') || _index.default.get(accountSetting, 'mobile_button.background_mask_url') || imgsrc;
|
|
353
|
+
}
|
|
354
|
+
imgsrc = this.props.store.replaceFileUrl(imgsrc);
|
|
355
|
+
await _index.default.preloadImg(imgsrc);
|
|
356
|
+
this.setState({
|
|
357
|
+
ready: true
|
|
304
358
|
});
|
|
305
|
-
this.
|
|
359
|
+
this.readyGate.open();
|
|
306
360
|
}
|
|
307
361
|
renderButton() {
|
|
308
362
|
if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_button = _index.default.Date.now();
|
|
@@ -392,6 +446,7 @@ class ChatButton extends _common.Com {
|
|
|
392
446
|
height: ${imgheight - 4}px !important;
|
|
393
447
|
|
|
394
448
|
`;
|
|
449
|
+
if (!this.state.ready) cls += ' hidden';
|
|
395
450
|
return (0, _preact.h)("div", {
|
|
396
451
|
class: cls,
|
|
397
452
|
onClick: e => this.onClick(e)
|
|
@@ -406,9 +461,7 @@ class ChatButton extends _common.Com {
|
|
|
406
461
|
height: "70",
|
|
407
462
|
alt: "chat button",
|
|
408
463
|
class: "chat-button--img",
|
|
409
|
-
|
|
410
|
-
src: imgsrc,
|
|
411
|
-
onError: (e, a) => this.onChatButtonError(e, a)
|
|
464
|
+
src: imgsrc
|
|
412
465
|
})), this.renderUnread());
|
|
413
466
|
}
|
|
414
467
|
onProfileError(ev) {
|
|
@@ -250,8 +250,9 @@ class Widget extends _common.Com {
|
|
|
250
250
|
let $body = null;
|
|
251
251
|
if (this.props.view === 'list') $body = this.renderConvoList();else if (showform) $body = this.renderForm(form, submitLabel, formName);else $body = this.renderChat();
|
|
252
252
|
let position = _index.default.get(accountSetting, 'desktop_button.position') || 'right';
|
|
253
|
-
if (this.props.store.isMobile()) position = _index.default.get(accountSetting, 'mobile_button.position', position);
|
|
253
|
+
if (this.props.store.isMobile() || this.props.store.isEmbededChatMode()) position = _index.default.get(accountSetting, 'mobile_button.position', position);
|
|
254
254
|
let cls = 'widget-container widget-container--' + position;
|
|
255
|
+
if (this.props.store.isEmbededChatMode()) cls += ' embed-chat';
|
|
255
256
|
if (!this.props.store.isMobile() && _index.default.get(accountSetting, 'window_mode') === 'full') cls += ' widget-container--full';
|
|
256
257
|
if (!this.props.isShow) cls += ' widget-container--hide';
|
|
257
258
|
let hideheader = _index.default.get(accountSetting, 'header.hidden', false);
|
|
@@ -76,7 +76,7 @@ class Main extends _common.Com {
|
|
|
76
76
|
let widgetView = lastview.view;
|
|
77
77
|
let widgetConvoId = _index.default.get(lastview, 'opts.cid');
|
|
78
78
|
return (0, _preact.h)("div", {
|
|
79
|
-
class: this.props.store.isMobile() ? 'mobile' : 'desktop'
|
|
79
|
+
class: this.props.store.isMobile() || this.props.store.isEmbededChatMode() ? 'mobile' : 'desktop'
|
|
80
80
|
}, (0, _preact.h)(_ChatButton.default, {
|
|
81
81
|
plugin: this.props.plugin,
|
|
82
82
|
store: this.props.store,
|
|
@@ -146,17 +146,21 @@ class Main extends _common.Com {
|
|
|
146
146
|
let newView = {
|
|
147
147
|
screen: 'widget',
|
|
148
148
|
minimized: 0,
|
|
149
|
-
view: p.view
|
|
149
|
+
view: p.view,
|
|
150
|
+
previewEvent: {},
|
|
151
|
+
opts: {
|
|
152
|
+
cid
|
|
153
|
+
}
|
|
150
154
|
};
|
|
151
155
|
if (!p.view && !p.cid) {
|
|
152
156
|
let convoM = this.props.store.matchConvo('*');
|
|
153
157
|
let redconvo = _index.default.find(convoM, convo => !_index.default.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
154
158
|
cid = _index.default.get(redconvo, 'id', _index.default.get(convoM, '0.id'));
|
|
155
159
|
newView.view = 'chat';
|
|
160
|
+
newView.opts = {
|
|
161
|
+
cid
|
|
162
|
+
};
|
|
156
163
|
}
|
|
157
|
-
if (cid) newView.opts = {
|
|
158
|
-
cid
|
|
159
|
-
};
|
|
160
164
|
if (this.props.store.isMobile()) modifyViewport();
|
|
161
165
|
this.props.store.updateLastview(newView);
|
|
162
166
|
this.forceUpdate();
|
|
@@ -50,6 +50,24 @@ class Store {
|
|
|
50
50
|
return unreadcount;
|
|
51
51
|
});
|
|
52
52
|
_defineProperty(this, "matchPlugin", () => {
|
|
53
|
+
if (this.is_embed_chat_mode) {
|
|
54
|
+
let pluginM = this.cache.match('plugin');
|
|
55
|
+
if (_index.default.size(this.forcePlugins) > 0) pluginM = this.forcePlugins;
|
|
56
|
+
let chatboxs = _index.default.filter(pluginM, (plugin, id) => plugin && plugin.type === 'chatbox');
|
|
57
|
+
if (_index.default.size(chatboxs) === 0) {
|
|
58
|
+
console.error('no chatbox found.');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let chatbox = _index.default.find(chatboxs, chatbox => !!chatbox);
|
|
62
|
+
if (!chatbox) {
|
|
63
|
+
chatbox = chatboxs[0];
|
|
64
|
+
}
|
|
65
|
+
chatbox = _index.default.cloneDeep(chatbox);
|
|
66
|
+
chatbox.triggers = undefined;
|
|
67
|
+
return {
|
|
68
|
+
[chatbox.id]: chatbox
|
|
69
|
+
};
|
|
70
|
+
}
|
|
53
71
|
if (_index.default.size(this.forcePlugins) > 0) return _index.default.cloneDeep(this.forcePlugins);
|
|
54
72
|
return _index.default.cloneDeep(this.cache.match('plugin')) || {};
|
|
55
73
|
});
|
|
@@ -135,14 +153,7 @@ class Store {
|
|
|
135
153
|
_defineProperty(this, "reconnectGate", new _index.default.Gate(true));
|
|
136
154
|
_defineProperty(this, "wsGate", new _index.default.Gate(true));
|
|
137
155
|
_defineProperty(this, "matchLastview", () => {
|
|
138
|
-
|
|
139
|
-
let user = this.cache.match('user') || {};
|
|
140
|
-
if (!user.id) return {};
|
|
141
|
-
if (lastView.user_id != user.id) return {};
|
|
142
|
-
if (lastView.view && !lastView.screen) {
|
|
143
|
-
lastView.screen = 'widget';
|
|
144
|
-
}
|
|
145
|
-
return lastView;
|
|
156
|
+
return this.kv.match('lastview') || {};
|
|
146
157
|
});
|
|
147
158
|
_defineProperty(this, "matchIsOpen", () => !!this.kv.match('isopen'));
|
|
148
159
|
_defineProperty(this, "matchClosePreviewAt", () => this.kv.match('close_preview_at') || 0);
|
|
@@ -183,13 +194,15 @@ class Store {
|
|
|
183
194
|
let user = this.cache.match('user') || {};
|
|
184
195
|
if (!user.id) return;
|
|
185
196
|
let lastview = this.matchLastview() || {};
|
|
186
|
-
|
|
197
|
+
let newview = {
|
|
187
198
|
...lastview,
|
|
188
199
|
...obj,
|
|
189
200
|
user_id: user.id
|
|
190
201
|
};
|
|
191
|
-
this.kv.put('lastview',
|
|
202
|
+
this.kv.put('lastview', newview);
|
|
203
|
+
this.pubsub.publish('lastview', newview, lastview);
|
|
192
204
|
});
|
|
205
|
+
_defineProperty(this, "onLastview", (o, cb) => this.pubsub.on2(o, 'lastview', cb));
|
|
193
206
|
_defineProperty(this, "timeDiff", 0);
|
|
194
207
|
this.connectionStatus = 'active';
|
|
195
208
|
this.CONNECTION_CHECK_INTERVAL = 3000;
|
|
@@ -497,6 +510,20 @@ class Store {
|
|
|
497
510
|
user_mask: mask
|
|
498
511
|
});
|
|
499
512
|
}
|
|
513
|
+
standardlizeLastview() {
|
|
514
|
+
let lastView = this.kv.match('lastview') || {};
|
|
515
|
+
let user = this.cache.match('user') || {};
|
|
516
|
+
if (!user.id) lastView = {};
|
|
517
|
+
if (lastView.user_id != user.id) lastView = {};
|
|
518
|
+
if (!lastView.screen) {
|
|
519
|
+
lastView.screen = 'preview';
|
|
520
|
+
if (lastView.view === 'list' || lastView.view === 'chat') {
|
|
521
|
+
lastView.screen = 'widget';
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (this.isMobile()) lastView.screen = 'button';
|
|
525
|
+
this.kv.put('lastview', lastView);
|
|
526
|
+
}
|
|
500
527
|
async _initResource(accid, auth, realtimep) {
|
|
501
528
|
this.g_sync = {};
|
|
502
529
|
let user = await this.api.setAuth(auth);
|
|
@@ -522,6 +549,7 @@ class Store {
|
|
|
522
549
|
await this.reconnect({
|
|
523
550
|
user: user
|
|
524
551
|
});
|
|
552
|
+
this.standardlizeLastview();
|
|
525
553
|
if (typeof sbz_info != 'undefined') sbz_info.store_10 = true;
|
|
526
554
|
this.readyGate.open();
|
|
527
555
|
this.reconnectWs(accid, user.id);
|