@aslaluroba/help-center-react 2.0.0 → 2.0.1

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/dist/index.js CHANGED
@@ -38,6 +38,8 @@ class ClientSignalRService {
38
38
  this.hubUrl = hubUrl;
39
39
  }
40
40
  static async startConnection(sessionId, apiKey, onMessageReceived) {
41
+ console.log('🚀 ~ ClientSignalRService ~ startConnection ~ apiKey:', apiKey);
42
+ console.log('🚀 ~ ClientSignalRService ~ startConnection ~ sessionId:', sessionId);
41
43
  // Prevent multiple connections
42
44
  if (this.isConnected)
43
45
  return;
@@ -54,6 +56,7 @@ class ClientSignalRService {
54
56
  .build();
55
57
  // Define callback function for receiving messages
56
58
  this.connection.on('ReceiveMessage', (message, senderType, needsAgent) => {
59
+ console.log('🚀 ~ ClientSignalRService ~ this.connection.on ~ message:', message);
57
60
  onMessageReceived(message, senderType, needsAgent);
58
61
  });
59
62
  try {
@@ -25662,7 +25665,7 @@ function HelpPopup({ onClose, helpScreen, status, error, onStartChat, onSendMess
25662
25665
  }
25663
25666
  };
25664
25667
  const handleSendMessage = (message) => {
25665
- if (message.trim() && isSignalRConnected && !isChatClosed) {
25668
+ if (message.trim()) {
25666
25669
  onSendMessage(message.trim());
25667
25670
  }
25668
25671
  };
@@ -25776,6 +25779,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
25776
25779
  setShowArrowAnimation(false);
25777
25780
  };
25778
25781
  const handleReceiveMessage = (message, senderType, needsAgent) => {
25782
+ console.log('🚀 ~ handleReceiveMessage ~ message:', message);
25779
25783
  // Update agent status if needed
25780
25784
  if (needsAgent) {
25781
25785
  setNeedsAgent(true);
@@ -25817,6 +25821,8 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
25817
25821
  catch (error) {
25818
25822
  console.error('Error ending chat:', error);
25819
25823
  setError('Failed to end chat session');
25824
+ // If ending chat fails, the chat is not considered closed.
25825
+ setIsChatClosed(false);
25820
25826
  }
25821
25827
  };
25822
25828
  const handleStartChat = async (option) => {
@@ -25871,7 +25877,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
25871
25877
  ]);
25872
25878
  }
25873
25879
  // Connect to SignalR
25874
- await ClientSignalRService.startConnection(createdSession.id, tokenResponse, handleReceiveMessage);
25880
+ ClientSignalRService.startConnection(createdSession.id, tokenResponse, handleReceiveMessage);
25875
25881
  setIsSignalRConnected(true);
25876
25882
  setIsChatClosed(false);
25877
25883
  setStatus('succeeded');
@@ -25880,6 +25886,8 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
25880
25886
  console.error('Chat start error:', error);
25881
25887
  setError(error instanceof Error ? error.message : 'Failed to start chat session');
25882
25888
  setStatus('failed');
25889
+ // If starting chat fails, SignalR is not connected.
25890
+ setIsSignalRConnected(false);
25883
25891
  }
25884
25892
  };
25885
25893
  const handleSendMessage = async (message) => {