diff --git a/src/App.jsx b/src/App.jsx index 2e993b2..d988952 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -6,6 +6,7 @@ import PostList from "./components/Posts/PostList"; const MapView = React.lazy(() => import("./components/Map/MapView")); const THEME_KEY = "sociowire:theme"; +const ACTIVE_CHATS_KEY = "sociowire:activeChats"; export default function App() { const [theme, setTheme] = useState("blue"); @@ -52,6 +53,29 @@ export default function App() { } }, [theme]); + // Chats actifs (s'ajoutent quand on clique sur Contacts) + const [activeChats, setActiveChats] = useState([]); + + useEffect(() => { + try { + const saved = localStorage.getItem(ACTIVE_CHATS_KEY); + if (saved) setActiveChats(JSON.parse(saved)); + } catch {} + }, []); + + useEffect(() => { + try { + localStorage.setItem(ACTIVE_CHATS_KEY, JSON.stringify(activeChats)); + } catch {} + }, [activeChats]); + + // Ouvrir un chat (simulé ici par un clic sur Contacts) + const openChat = (name) => { + if (!activeChats.includes(name)) { + setActiveChats(prev => [...prev, name]); + } + }; + return (