fix: use ChannelStore for activeChannelId subscription

activeChannelId lives on ChannelStore, not ServerStore.
This commit is contained in:
2026-07-02 13:59:27 -04:00
parent b6d4614881
commit 9e70884a16
+3 -2
View File
@@ -3,6 +3,7 @@ import { Link, Outlet, useLocation, useNavigate } from 'react-router-dom';
import { useAuthStore, type UserStatus } from '../stores/auth.ts'; import { useAuthStore, type UserStatus } from '../stores/auth.ts';
import { useWebSocketStore } from '../stores/ws.ts'; import { useWebSocketStore } from '../stores/ws.ts';
import { useServerStore } from '../stores/server.ts'; import { useServerStore } from '../stores/server.ts';
import { useChannelStore } from '../stores/channel.ts';
import { useLayoutStore } from '../stores/layout.ts'; import { useLayoutStore } from '../stores/layout.ts';
import { ServerBar } from './ServerBar.tsx'; import { ServerBar } from './ServerBar.tsx';
import { ChannelList } from './ChannelList.tsx'; import { ChannelList } from './ChannelList.tsx';
@@ -42,7 +43,7 @@ export function Layout() {
const setMobileView = useLayoutStore((s) => s.setMobileView); const setMobileView = useLayoutStore((s) => s.setMobileView);
const [showServerSettings, setShowServerSettings] = useState(false); const [showServerSettings, setShowServerSettings] = useState(false);
const activeServerId = useServerStore((s) => s.activeServerId); const activeServerId = useServerStore((s) => s.activeServerId);
const activeChannelId = useServerStore((s) => s.activeChannelId); const activeChannelId = useChannelStore((s) => s.activeChannelId);
useEffect(() => { useEffect(() => {
wsConnect(); wsConnect();
return () => { wsDisconnect(); }; return () => { wsDisconnect(); };
@@ -54,7 +55,7 @@ export function Layout() {
}, [isLoading, isAuthenticated, location.pathname, navigate]); }, [isLoading, isAuthenticated, location.pathname, navigate]);
// Navigate to chat when a channel/DM is selected on mobile // Navigate to chat when a channel/DM is selected on mobile
useEffect(() => { useEffect(() => {
const unsub = useServerStore.subscribe((state, prev) => { const unsub = useChannelStore.subscribe((state, prev) => {
if (state.activeChannelId !== prev.activeChannelId && state.activeChannelId) { if (state.activeChannelId !== prev.activeChannelId && state.activeChannelId) {
setMobileView('chat'); setMobileView('chat');
} }