diff --git a/web/src/components/Layout.tsx b/web/src/components/Layout.tsx index a050d2a..8b290f5 100644 --- a/web/src/components/Layout.tsx +++ b/web/src/components/Layout.tsx @@ -3,6 +3,7 @@ import { Link, Outlet, useLocation, useNavigate } from 'react-router-dom'; import { useAuthStore, type UserStatus } from '../stores/auth.ts'; import { useWebSocketStore } from '../stores/ws.ts'; import { useServerStore } from '../stores/server.ts'; +import { useChannelStore } from '../stores/channel.ts'; import { useLayoutStore } from '../stores/layout.ts'; import { ServerBar } from './ServerBar.tsx'; import { ChannelList } from './ChannelList.tsx'; @@ -42,7 +43,7 @@ export function Layout() { const setMobileView = useLayoutStore((s) => s.setMobileView); const [showServerSettings, setShowServerSettings] = useState(false); const activeServerId = useServerStore((s) => s.activeServerId); - const activeChannelId = useServerStore((s) => s.activeChannelId); + const activeChannelId = useChannelStore((s) => s.activeChannelId); useEffect(() => { wsConnect(); return () => { wsDisconnect(); }; @@ -54,7 +55,7 @@ export function Layout() { }, [isLoading, isAuthenticated, location.pathname, navigate]); // Navigate to chat when a channel/DM is selected on mobile useEffect(() => { - const unsub = useServerStore.subscribe((state, prev) => { + const unsub = useChannelStore.subscribe((state, prev) => { if (state.activeChannelId !== prev.activeChannelId && state.activeChannelId) { setMobileView('chat'); }