PATCH: Fix to retrieval of chat
This commit is contained in:
@@ -5,9 +5,9 @@ import UserPage from "../../pages/UserPage";
|
|||||||
|
|
||||||
const StreamerRoute: React.FC = () => {
|
const StreamerRoute: React.FC = () => {
|
||||||
const { streamerName } = useParams<{ streamerName: string }>();
|
const { streamerName } = useParams<{ streamerName: string }>();
|
||||||
const [isLive, setIsLive] = useState<boolean>(false);
|
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||||
let streamId: number = 0;
|
const [isLive, setIsLive] = useState<boolean>(false);
|
||||||
|
const [streamId, setStreamId] = useState<number>(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const checkStreamStatus = async () => {
|
const checkStreamStatus = async () => {
|
||||||
@@ -15,6 +15,7 @@ const StreamerRoute: React.FC = () => {
|
|||||||
const response = await fetch(`/api/streamer/${streamerName}/status`);
|
const response = await fetch(`/api/streamer/${streamerName}/status`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setIsLive(Boolean(data.is_live));
|
setIsLive(Boolean(data.is_live));
|
||||||
|
setStreamId(data.most_recent_stream);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error checking stream status:", error);
|
console.error("Error checking stream status:", error);
|
||||||
setIsLive(false);
|
setIsLive(false);
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ streamId }) => {
|
|||||||
<div
|
<div
|
||||||
ref={chatContainerRef}
|
ref={chatContainerRef}
|
||||||
id="chat-message-list"
|
id="chat-message-list"
|
||||||
className="flex-grow w-full max-h-[50vh] overflow-y-auto mb-4 space-y-2 rounded-[67px]"
|
className="flex-grow w-full max-h-[50vh] overflow-y-auto mb-4 space-y-2 rounded-md"
|
||||||
>
|
>
|
||||||
{messages.map((msg, index) => (
|
{messages.map((msg, index) => (
|
||||||
<div
|
<div
|
||||||
@@ -156,7 +156,7 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ streamId }) => {
|
|||||||
onKeyDown={handleKeyPress}
|
onKeyDown={handleKeyPress}
|
||||||
placeholder={isLoggedIn ? "Type a message..." : "Login to chat"}
|
placeholder={isLoggedIn ? "Type a message..." : "Login to chat"}
|
||||||
disabled={!isLoggedIn}
|
disabled={!isLoggedIn}
|
||||||
extraClasses="flex-grow"
|
extraClasses="flex-grow focus:w-[20vw]"
|
||||||
onClick={() => !isLoggedIn && setShowAuthModal(true)}
|
onClick={() => !isLoggedIn && setShowAuthModal(true)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user