"use client"; import React, { createContext, useContext, useState, useRef } from "react"; import type { ReplyTo, Message, UserProfile } from "@/lib/types"; // This is the most basic context for app-wide state that doesn't fit elsewhere. interface AppContextType { replyTo: ReplyTo | null; setReplyTo: React.Dispatch>; privateReplyTo: UserProfile | null; setPrivateReplyTo: React.Dispatch>; messageCache: React.MutableRefObject>; } const AppContext = createContext(null); export function useAppContext() { const context = useContext(AppContext); if (!context) { throw new Error("useAppContext must be used within an AppProvider"); } return context; } export function AppProvider({ children }: { children: React.ReactNode }) { const [replyTo, setReplyTo] = useState(null); const [privateReplyTo, setPrivateReplyTo] = useState(null); const messageCache = useRef(new Map()); return ( {children} ); }