fix(web): resolve React #310 hook order crash in MessageList
Some checks failed
CI / test (push) Failing after 22s

- move forwardTargets useMemo above conditional early return

- keep hooks call order stable after login/activeChat switch
This commit is contained in:
2026-03-08 01:05:45 +03:00
parent 997598188d
commit a42f97962b

View File

@@ -34,12 +34,6 @@ export function MessageList() {
const messagesMap = useMemo(() => new Map(messages.map((m) => [m.id, m])), [messages]);
const activeChat = chats.find((chat) => chat.id === activeChatId);
if (!activeChatId) {
return <div className="flex h-full items-center justify-center text-slate-300/80">Select a chat</div>;
}
const chatId = activeChatId;
const forwardTargets = useMemo(() => {
const q = forwardQuery.trim().toLowerCase();
if (!q) return chats;
@@ -50,6 +44,11 @@ export function MessageList() {
});
}, [chats, forwardQuery]);
if (!activeChatId) {
return <div className="flex h-full items-center justify-center text-slate-300/80">Select a chat</div>;
}
const chatId = activeChatId;
async function handleForward(targetChatId: number) {
if (!forwardMessageId) return;
setIsForwarding(true);