@product7/product7-js 0.6.4 → 0.6.5
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/package.json
CHANGED
|
@@ -399,7 +399,38 @@ export class LiveChatWidget extends BaseWidget {
|
|
|
399
399
|
});
|
|
400
400
|
|
|
401
401
|
if (response.status && response.data) {
|
|
402
|
-
|
|
402
|
+
// Reconcile the optimistic 'Sending…' message with the server's
|
|
403
|
+
// confirmation as soon as the POST returns. Don't depend on the WS
|
|
404
|
+
// echo alone — when the WebSocket frame is dropped (brief
|
|
405
|
+
// disconnect, slow network, server send-buffer full), the
|
|
406
|
+
// optimistic message stays stuck on 'Sending…' forever because
|
|
407
|
+
// upsertMessage's match window is finite.
|
|
408
|
+
const serverData = response.data;
|
|
409
|
+
let attachments = [];
|
|
410
|
+
if (serverData.attachments) {
|
|
411
|
+
try {
|
|
412
|
+
attachments =
|
|
413
|
+
typeof serverData.attachments === 'string'
|
|
414
|
+
? JSON.parse(serverData.attachments)
|
|
415
|
+
: serverData.attachments;
|
|
416
|
+
} catch (e) {
|
|
417
|
+
attachments = [];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
this.LiveChatState.upsertMessage(
|
|
421
|
+
conversationId,
|
|
422
|
+
{
|
|
423
|
+
id: serverData.id,
|
|
424
|
+
content: serverData.content,
|
|
425
|
+
isOwn: true,
|
|
426
|
+
timestamp: serverData.created_at,
|
|
427
|
+
attachments:
|
|
428
|
+
Array.isArray(attachments) && attachments.length > 0
|
|
429
|
+
? attachments
|
|
430
|
+
: undefined,
|
|
431
|
+
},
|
|
432
|
+
{ reconcileOwnOptimistic: true, optimisticMatchWindowMs: 60000 }
|
|
433
|
+
);
|
|
403
434
|
}
|
|
404
435
|
|
|
405
436
|
if (this.apiService?.mock) {
|
|
@@ -39,12 +39,11 @@
|
|
|
39
39
|
<div class="liveChat-home-logo">
|
|
40
40
|
${this.options.logoUrl ? `<img src="${this.options.logoUrl}" alt="${this.state.teamName}" />` : ''}
|
|
41
41
|
</div>
|
|
42
|
-
<div class="liveChat-home-avatars">${avatarsHtml}</div>
|
|
42
|
+
<div class="liveChat-home-avatars">${avatarsHtml || availabilityHtml}</div>
|
|
43
43
|
</div>
|
|
44
44
|
<div class="liveChat-home-welcome">
|
|
45
45
|
<span class="liveChat-home-greeting">${this.state.greetingMessage}</span>
|
|
46
46
|
<span class="liveChat-home-question">${this.state.welcomeMessage}</span>
|
|
47
|
-
${availabilityHtml}
|
|
48
47
|
</div>
|
|
49
48
|
</div>
|
|
50
49
|
|
|
@@ -107,7 +106,7 @@
|
|
|
107
106
|
return `
|
|
108
107
|
<div class="liveChat-home-availability">
|
|
109
108
|
<span class="liveChat-availability-dot liveChat-availability-away"></span>
|
|
110
|
-
<span class="liveChat-availability-text"
|
|
109
|
+
<span class="liveChat-availability-text">We're currently away</span>
|
|
111
110
|
</div>
|
|
112
111
|
`;
|
|
113
112
|
}
|