From 4674a2eaaf625042497fe2798bf9282e2d3e018f Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Wed, 15 Apr 2026 20:57:50 -0600 Subject: [PATCH] fix customer ws subscription --- web/app/ai-chat/page.js | 7 +++++-- web/app/chat/page.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/web/app/ai-chat/page.js b/web/app/ai-chat/page.js index a4cd4127..09ac5ba3 100644 --- a/web/app/ai-chat/page.js +++ b/web/app/ai-chat/page.js @@ -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; diff --git a/web/app/chat/page.js b/web/app/chat/page.js index cc3fb717..f5b8432f 100644 --- a/web/app/chat/page.js +++ b/web/app/chat/page.js @@ -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;