@aslaluroba/help-center-react 3.2.12 → 3.2.13
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 +11 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/ui/help-popup.d.ts +1 -0
- package/package.json +1 -1
- package/src/ui/help-center.tsx +11 -8
- package/src/ui/help-popup.tsx +1 -1
package/dist/ui/help-popup.d.ts
CHANGED
package/package.json
CHANGED
package/src/ui/help-center.tsx
CHANGED
|
@@ -110,20 +110,24 @@ const HelpCenterContent = ({
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
const handleEndChat = useCallback(
|
|
113
|
-
async (options?: { fromChatScreen?: boolean }) => {
|
|
113
|
+
async (options?: { fromChatScreen?: boolean; sessionClosedByServer?: boolean }) => {
|
|
114
114
|
if (!sessionId || !selectedOption) return;
|
|
115
115
|
|
|
116
116
|
const fromChatScreen = options?.fromChatScreen === true;
|
|
117
|
+
// When Ably sends end_session (e.g. admin closed from dashboard), skip close API call
|
|
118
|
+
const sessionClosedByServer = options?.sessionClosedByServer === true;
|
|
117
119
|
|
|
118
120
|
try {
|
|
119
121
|
await ClientAblyService.stopConnection();
|
|
120
122
|
setIsAblyConnected(false);
|
|
121
123
|
setAssistantStatus('idle');
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
if (!sessionClosedByServer) {
|
|
126
|
+
const response = await apiRequest(`Client/ClientChatSession/${sessionId}/close`, 'POST', null, {
|
|
127
|
+
language: language,
|
|
128
|
+
});
|
|
129
|
+
if (!response.ok) throw new Error('Failed to close chat session');
|
|
130
|
+
}
|
|
127
131
|
|
|
128
132
|
setReviewSessionId(sessionId);
|
|
129
133
|
setSessionId(null);
|
|
@@ -131,7 +135,6 @@ const HelpCenterContent = ({
|
|
|
131
135
|
if (fromChatScreen) {
|
|
132
136
|
setInChatReviewSessionId(sessionId);
|
|
133
137
|
setIsChatClosed(true);
|
|
134
|
-
// Keep selectedOption and messages; do not open popup
|
|
135
138
|
} else {
|
|
136
139
|
setSelectedOption(null);
|
|
137
140
|
setMessages([]);
|
|
@@ -341,9 +344,9 @@ const HelpCenterContent = ({
|
|
|
341
344
|
setNeedsAgent(true);
|
|
342
345
|
});
|
|
343
346
|
|
|
344
|
-
// "end_session" →
|
|
347
|
+
// "end_session" → session was closed by server (e.g. admin from dashboard); update local state only, do not call close API
|
|
345
348
|
actionHandler.registerHandler('end_session', () => {
|
|
346
|
-
void handleEndChat({ fromChatScreen: true });
|
|
349
|
+
void handleEndChat({ fromChatScreen: true, sessionClosedByServer: true });
|
|
347
350
|
});
|
|
348
351
|
|
|
349
352
|
return () => {
|
package/src/ui/help-popup.tsx
CHANGED
|
@@ -25,7 +25,7 @@ type HelpPopupProps = {
|
|
|
25
25
|
onStartChat: (option: Option) => void;
|
|
26
26
|
onSendMessage: (message: string, attachmentIds: string[]) => void;
|
|
27
27
|
onEnsureSession: () => Promise<string>;
|
|
28
|
-
onEndChat: (options?: { fromChatScreen?: boolean }) => void | Promise<void>;
|
|
28
|
+
onEndChat: (options?: { fromChatScreen?: boolean; sessionClosedByServer?: boolean }) => void | Promise<void>;
|
|
29
29
|
messages: Message[];
|
|
30
30
|
needsAgent: boolean;
|
|
31
31
|
assistantStatus: string;
|