Merge pull request #318 from RecentRunner/fix-customer-ws-subscription
fix customer ws subscription
This commit was merged in pull request #318.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user