fix customer ws subscription #318

Merged
RecentRunner merged 1 commits from fix-customer-ws-subscription into main 2026-04-15 21:19:58 -06:00
2 changed files with 10 additions and 4 deletions

View File

@@ -114,7 +114,10 @@ function AiChatPage() {
lastMessageIdRef.current = msg.id;
} catch { /* silent */ }
});
client.subscribe(`/topic/chat/conversations`, (frame) => {
const convTopic = user?.role === "CUSTOMER"
? `/user/queue/chat/conversations`
: `/topic/chat/conversations`;
client.subscribe(convTopic, (frame) => {
try {
const conv = JSON.parse(frame.body);
if (conv.id === convId) setConversation(conv);
@@ -124,7 +127,7 @@ function AiChatPage() {
};
stompRef.current = client;
client.activate();
}, [token]);
}, [token, user?.role]);
useEffect(() => {
if (!token || authLoading) return;

View File

@@ -128,7 +128,10 @@ function ChatPage() {
lastMessageIdRef.current = msg.id;
} catch { /* silent */ }
});
client.subscribe(`/topic/chat/conversations`, (frame) => {
const convTopic = user?.role === "CUSTOMER"
? `/user/queue/chat/conversations`
: `/topic/chat/conversations`;
client.subscribe(convTopic, (frame) => {
try {
const conv = JSON.parse(frame.body);
if (conv.id === convId) setConversation(conv);
@@ -138,7 +141,7 @@ function ChatPage() {
};
stompRef.current = client;
client.activate();
}, [token]);
}, [token, user?.role]);
useEffect(() => {
if (!token || authLoading) return;