From d472d672bd8b5b40785584196370a7c0d593015a Mon Sep 17 00:00:00 2001 From: Chris-1010 <122332721@umail.ucc.ie> Date: Tue, 4 Feb 2025 15:38:13 +0000 Subject: [PATCH] PATCH: Fix to retrieval of chat --- frontend/src/components/Stream/StreamerRoute.tsx | 5 +++-- frontend/src/components/Video/ChatPanel.tsx | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Stream/StreamerRoute.tsx b/frontend/src/components/Stream/StreamerRoute.tsx index f189b18..b8f21c0 100644 --- a/frontend/src/components/Stream/StreamerRoute.tsx +++ b/frontend/src/components/Stream/StreamerRoute.tsx @@ -5,9 +5,9 @@ import UserPage from "../../pages/UserPage"; const StreamerRoute: React.FC = () => { const { streamerName } = useParams<{ streamerName: string }>(); - const [isLive, setIsLive] = useState(false); const [isLoading, setIsLoading] = useState(true); - let streamId: number = 0; + const [isLive, setIsLive] = useState(false); + const [streamId, setStreamId] = useState(0); useEffect(() => { const checkStreamStatus = async () => { @@ -15,6 +15,7 @@ const StreamerRoute: React.FC = () => { const response = await fetch(`/api/streamer/${streamerName}/status`); const data = await response.json(); setIsLive(Boolean(data.is_live)); + setStreamId(data.most_recent_stream); } catch (error) { console.error("Error checking stream status:", error); setIsLive(false); diff --git a/frontend/src/components/Video/ChatPanel.tsx b/frontend/src/components/Video/ChatPanel.tsx index 7933a4a..e52b391 100644 --- a/frontend/src/components/Video/ChatPanel.tsx +++ b/frontend/src/components/Video/ChatPanel.tsx @@ -121,7 +121,7 @@ const ChatPanel: React.FC = ({ streamId }) => {
{messages.map((msg, index) => (
= ({ streamId }) => { onKeyDown={handleKeyPress} placeholder={isLoggedIn ? "Type a message..." : "Login to chat"} disabled={!isLoggedIn} - extraClasses="flex-grow" + extraClasses="flex-grow focus:w-[20vw]" onClick={() => !isLoggedIn && setShowAuthModal(true)} />