REFACTOR: Repositioned chat toggle functionality and context management;
UPDATE: Improve stream time display; REFACTOR: Update Video Page Styles; Co-authored-by: JustIceO7 <oscarcao777@gmail.com>
This commit is contained in:
26
frontend/src/context/ChatContext.tsx
Normal file
26
frontend/src/context/ChatContext.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { createContext, useContext, useState, ReactNode } from "react";
|
||||
|
||||
interface ChatContextType {
|
||||
showChat: boolean;
|
||||
setShowChat: (show: boolean) => void;
|
||||
}
|
||||
|
||||
const ChatContext = createContext<ChatContextType | undefined>(undefined);
|
||||
|
||||
export function ChatProvider({ children }: { children: ReactNode }) {
|
||||
const [showChat, setShowChat] = useState(true);
|
||||
|
||||
return (
|
||||
<ChatContext.Provider value={{ showChat, setShowChat }}>
|
||||
{children}
|
||||
</ChatContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useChat() {
|
||||
const context = useContext(ChatContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("useChat must be used within a ChatProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in New Issue
Block a user