@anakin824/prdg-chat-ui 0.3.2 → 0.3.3
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -178,10 +178,15 @@ function chatDebugWarn(debug, ...args) {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// src/chat/lib/queryKeys.ts
|
|
181
|
+
function normalizeConversationCacheId(conversationId) {
|
|
182
|
+
if (conversationId == null) return null;
|
|
183
|
+
const t = conversationId.trim();
|
|
184
|
+
return t ? t.toLowerCase() : null;
|
|
185
|
+
}
|
|
181
186
|
var chatKeys = {
|
|
182
187
|
all: ["chat"],
|
|
183
188
|
conversations: () => [...chatKeys.all, "conversations"],
|
|
184
|
-
messages: (conversationId) => [...chatKeys.all, "messages", conversationId],
|
|
189
|
+
messages: (conversationId) => [...chatKeys.all, "messages", normalizeConversationCacheId(conversationId)],
|
|
185
190
|
members: (conversationId) => [...chatKeys.all, "members", conversationId],
|
|
186
191
|
contacts: (q) => [...chatKeys.all, "contacts", q]
|
|
187
192
|
};
|
|
@@ -248,7 +253,10 @@ function getMessagePageSummary(queryClient, conversationId) {
|
|
|
248
253
|
function pushMessageToCache(queryClient, msg) {
|
|
249
254
|
let result = "missing-cache";
|
|
250
255
|
queryClient.setQueryData(chatKeys.messages(msg.conversation_id), (prev) => {
|
|
251
|
-
if (!prev)
|
|
256
|
+
if (!prev) {
|
|
257
|
+
result = "seeded";
|
|
258
|
+
return { items: [msg], next_cursor: "" };
|
|
259
|
+
}
|
|
252
260
|
if (prev.items.some((m) => m.id === msg.id)) {
|
|
253
261
|
result = "duplicate";
|
|
254
262
|
return prev;
|
|
@@ -426,11 +434,12 @@ function ChatNatsBridge({ natsWsUrl, natsToken, onConnectedChange }) {
|
|
|
426
434
|
const connRef = useRef(null);
|
|
427
435
|
useEffect(() => {
|
|
428
436
|
if (servers.length === 0) return;
|
|
437
|
+
const entityConvIds = entityKey ? entityKey.split(",").filter(Boolean) : [];
|
|
429
438
|
chatDebugLog(debug, "ChatNatsBridge: starting subscriptions", {
|
|
430
439
|
userId,
|
|
431
440
|
natsTenantId,
|
|
432
441
|
servers,
|
|
433
|
-
entityConversationIds
|
|
442
|
+
entityConversationIds: entityConvIds
|
|
434
443
|
});
|
|
435
444
|
let cancelled = false;
|
|
436
445
|
void (async () => {
|
|
@@ -523,7 +532,7 @@ function ChatNatsBridge({ natsWsUrl, natsToken, onConnectedChange }) {
|
|
|
523
532
|
handleMsg(m.data, m.subject);
|
|
524
533
|
}
|
|
525
534
|
})();
|
|
526
|
-
for (const convId of
|
|
535
|
+
for (const convId of entityConvIds) {
|
|
527
536
|
const subj = entityConversationSubject(natsTenantId, convId);
|
|
528
537
|
chatDebugLog(debug, "ChatNatsBridge: subscribing entity conversation", {
|
|
529
538
|
conversationId: convId,
|
|
@@ -540,7 +549,7 @@ function ChatNatsBridge({ natsWsUrl, natsToken, onConnectedChange }) {
|
|
|
540
549
|
if (process.env.NODE_ENV === "development") {
|
|
541
550
|
const subjectList = [
|
|
542
551
|
inbox,
|
|
543
|
-
...
|
|
552
|
+
...entityConvIds.map((id) => entityConversationSubject(natsTenantId, id))
|
|
544
553
|
];
|
|
545
554
|
console.info("[NATS] WebSocket connected \u2014 servers:", servers, "subjects:", subjectList);
|
|
546
555
|
void (async () => {
|
|
@@ -571,7 +580,7 @@ function ChatNatsBridge({ natsWsUrl, natsToken, onConnectedChange }) {
|
|
|
571
580
|
connRef.current = null;
|
|
572
581
|
void c?.drain();
|
|
573
582
|
};
|
|
574
|
-
}, [servers, natsToken, natsTenantId, userId, entityKey, queryClient,
|
|
583
|
+
}, [servers, natsToken, natsTenantId, userId, entityKey, queryClient, debug]);
|
|
575
584
|
return null;
|
|
576
585
|
}
|
|
577
586
|
|
|
@@ -2393,6 +2402,6 @@ function ChatConversationView({
|
|
|
2393
2402
|
), showTyping ? /* @__PURE__ */ React.createElement(TypingIndicator, { names: typingNames }) : null), /* @__PURE__ */ React.createElement("div", { className: inputAreaClassName }, /* @__PURE__ */ React.createElement(MessageInput, { conversationId })));
|
|
2394
2403
|
}
|
|
2395
2404
|
|
|
2396
|
-
export { ChatAPI, MessageInput as ChatComposer, ChatConversationView, ChatInboxSidebar, ChatMainColumn, ChatPanel, ChatProvider, ChatWidget, ConversationList, INITIAL_MESSAGE_PAGE_SIZE, MessageBubble, MessageInput, MessageThread, NewChatModal, StandaloneChatPage, TypingIndicator, chatKeys, convDisplayName, convLabel, formatConvTime, initials2 as initials, mergeMessagePages, useChat, useChatActions, useChatPanelController, useConversationMembers, useConversations, useMessages, usePresignedUrl, useUpload, useVoiceRecorder };
|
|
2405
|
+
export { ChatAPI, MessageInput as ChatComposer, ChatConversationView, ChatInboxSidebar, ChatMainColumn, ChatPanel, ChatProvider, ChatWidget, ConversationList, INITIAL_MESSAGE_PAGE_SIZE, MessageBubble, MessageInput, MessageThread, NewChatModal, StandaloneChatPage, TypingIndicator, chatKeys, convDisplayName, convLabel, formatConvTime, initials2 as initials, mergeMessagePages, normalizeConversationCacheId, useChat, useChatActions, useChatPanelController, useConversationMembers, useConversations, useMessages, usePresignedUrl, useUpload, useVoiceRecorder };
|
|
2397
2406
|
//# sourceMappingURL=index.mjs.map
|
|
2398
2407
|
//# sourceMappingURL=index.mjs.map
|