@aslaluroba/help-center-react 1.0.4 → 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.esm.js CHANGED
@@ -9,6 +9,8 @@ class ClientSignalRService {
9
9
  this.hubUrl = hubUrl;
10
10
  }
11
11
  static async startConnection(sessionId, apiKey, onMessageReceived) {
12
+ console.log('🚀 ~ ClientSignalRService ~ startConnection ~ apiKey:', apiKey);
13
+ console.log('🚀 ~ ClientSignalRService ~ startConnection ~ sessionId:', sessionId);
12
14
  // Prevent multiple connections
13
15
  if (this.isConnected)
14
16
  return;
@@ -25,6 +27,7 @@ class ClientSignalRService {
25
27
  .build();
26
28
  // Define callback function for receiving messages
27
29
  this.connection.on('ReceiveMessage', (message, senderType, needsAgent) => {
30
+ console.log('🚀 ~ ClientSignalRService ~ this.connection.on ~ message:', message);
28
31
  onMessageReceived(message, senderType, needsAgent);
29
32
  });
30
33
  try {
@@ -25633,7 +25636,7 @@ function HelpPopup({ onClose, helpScreen, status, error, onStartChat, onSendMess
25633
25636
  }
25634
25637
  };
25635
25638
  const handleSendMessage = (message) => {
25636
- if (message.trim() && isSignalRConnected && !isChatClosed) {
25639
+ if (message.trim()) {
25637
25640
  onSendMessage(message.trim());
25638
25641
  }
25639
25642
  };
@@ -25747,6 +25750,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
25747
25750
  setShowArrowAnimation(false);
25748
25751
  };
25749
25752
  const handleReceiveMessage = (message, senderType, needsAgent) => {
25753
+ console.log('🚀 ~ handleReceiveMessage ~ message:', message);
25750
25754
  // Update agent status if needed
25751
25755
  if (needsAgent) {
25752
25756
  setNeedsAgent(true);
@@ -25788,6 +25792,8 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
25788
25792
  catch (error) {
25789
25793
  console.error('Error ending chat:', error);
25790
25794
  setError('Failed to end chat session');
25795
+ // If ending chat fails, the chat is not considered closed.
25796
+ setIsChatClosed(false);
25791
25797
  }
25792
25798
  };
25793
25799
  const handleStartChat = async (option) => {
@@ -25842,7 +25848,7 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
25842
25848
  ]);
25843
25849
  }
25844
25850
  // Connect to SignalR
25845
- await ClientSignalRService.startConnection(createdSession.id, tokenResponse, handleReceiveMessage);
25851
+ ClientSignalRService.startConnection(createdSession.id, tokenResponse, handleReceiveMessage);
25846
25852
  setIsSignalRConnected(true);
25847
25853
  setIsChatClosed(false);
25848
25854
  setStatus('succeeded');
@@ -25851,6 +25857,8 @@ function HelpCenter({ helpScreenId, user, showArrow = true, language = 'en', mes
25851
25857
  console.error('Chat start error:', error);
25852
25858
  setError(error instanceof Error ? error.message : 'Failed to start chat session');
25853
25859
  setStatus('failed');
25860
+ // If starting chat fails, SignalR is not connected.
25861
+ setIsSignalRConnected(false);
25854
25862
  }
25855
25863
  };
25856
25864
  const handleSendMessage = async (message) => {