fix customer ws subscription
This commit is contained in:
@@ -114,7 +114,10 @@ function AiChatPage() {
|
|||||||
lastMessageIdRef.current = msg.id;
|
lastMessageIdRef.current = msg.id;
|
||||||
} catch { /* silent */ }
|
} 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 {
|
try {
|
||||||
const conv = JSON.parse(frame.body);
|
const conv = JSON.parse(frame.body);
|
||||||
if (conv.id === convId) setConversation(conv);
|
if (conv.id === convId) setConversation(conv);
|
||||||
@@ -124,7 +127,7 @@ function AiChatPage() {
|
|||||||
};
|
};
|
||||||
stompRef.current = client;
|
stompRef.current = client;
|
||||||
client.activate();
|
client.activate();
|
||||||
}, [token]);
|
}, [token, user?.role]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!token || authLoading) return;
|
if (!token || authLoading) return;
|
||||||
|
|||||||
@@ -128,7 +128,10 @@ function ChatPage() {
|
|||||||
lastMessageIdRef.current = msg.id;
|
lastMessageIdRef.current = msg.id;
|
||||||
} catch { /* silent */ }
|
} 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 {
|
try {
|
||||||
const conv = JSON.parse(frame.body);
|
const conv = JSON.parse(frame.body);
|
||||||
if (conv.id === convId) setConversation(conv);
|
if (conv.id === convId) setConversation(conv);
|
||||||
@@ -138,7 +141,7 @@ function ChatPage() {
|
|||||||
};
|
};
|
||||||
stompRef.current = client;
|
stompRef.current = client;
|
||||||
client.activate();
|
client.activate();
|
||||||
}, [token]);
|
}, [token, user?.role]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!token || authLoading) return;
|
if (!token || authLoading) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user