@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.
@@ -11076,12 +11076,11 @@
11076
11076
  <div class="liveChat-home-logo">
11077
11077
  ${this.options.logoUrl ? `<img src="${this.options.logoUrl}" alt="${this.state.teamName}" />` : ''}
11078
11078
  </div>
11079
- <div class="liveChat-home-avatars">${avatarsHtml}</div>
11079
+ <div class="liveChat-home-avatars">${avatarsHtml || availabilityHtml}</div>
11080
11080
  </div>
11081
11081
  <div class="liveChat-home-welcome">
11082
11082
  <span class="liveChat-home-greeting">${this.state.greetingMessage}</span>
11083
11083
  <span class="liveChat-home-question">${this.state.welcomeMessage}</span>
11084
- ${availabilityHtml}
11085
11084
  </div>
11086
11085
  </div>
11087
11086
 
@@ -11144,7 +11143,7 @@
11144
11143
  return `
11145
11144
  <div class="liveChat-home-availability">
11146
11145
  <span class="liveChat-availability-dot liveChat-availability-away"></span>
11147
- <span class="liveChat-availability-text">${this.state.responseTime}</span>
11146
+ <span class="liveChat-availability-text">We're currently away</span>
11148
11147
  </div>
11149
11148
  `;
11150
11149
  }
@@ -11918,7 +11917,38 @@
11918
11917
  });
11919
11918
 
11920
11919
  if (response.status && response.data) {
11921
- console.log('[LiveChatWidget] Message sent:', response.data.id);
11920
+ // Reconcile the optimistic 'Sending…' message with the server's
11921
+ // confirmation as soon as the POST returns. Don't depend on the WS
11922
+ // echo alone — when the WebSocket frame is dropped (brief
11923
+ // disconnect, slow network, server send-buffer full), the
11924
+ // optimistic message stays stuck on 'Sending…' forever because
11925
+ // upsertMessage's match window is finite.
11926
+ const serverData = response.data;
11927
+ let attachments = [];
11928
+ if (serverData.attachments) {
11929
+ try {
11930
+ attachments =
11931
+ typeof serverData.attachments === 'string'
11932
+ ? JSON.parse(serverData.attachments)
11933
+ : serverData.attachments;
11934
+ } catch (e) {
11935
+ attachments = [];
11936
+ }
11937
+ }
11938
+ this.LiveChatState.upsertMessage(
11939
+ conversationId,
11940
+ {
11941
+ id: serverData.id,
11942
+ content: serverData.content,
11943
+ isOwn: true,
11944
+ timestamp: serverData.created_at,
11945
+ attachments:
11946
+ Array.isArray(attachments) && attachments.length > 0
11947
+ ? attachments
11948
+ : undefined,
11949
+ },
11950
+ { reconcileOwnOptimistic: true, optimisticMatchWindowMs: 60000 }
11951
+ );
11922
11952
  }
11923
11953
 
11924
11954
  if (this.apiService?.mock) {