fix(web): use keyed Fragment in ChatArea message list
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useRef, useState, useMemo, useCallback, memo } from "react";
|
import { useEffect, useRef, useState, useMemo, useCallback, memo, Fragment } from "react";
|
||||||
import { useMessageStore } from "../stores/message.ts";
|
import { useMessageStore } from "../stores/message.ts";
|
||||||
import { api } from "../lib/api.ts";
|
import { api } from "../lib/api.ts";
|
||||||
import { useChannelStore } from "../stores/channel.ts";
|
import { useChannelStore } from "../stores/channel.ts";
|
||||||
@@ -284,11 +284,12 @@ const MessageItem = memo(({
|
|||||||
MessageItem.displayName = "MessageItem";
|
MessageItem.displayName = "MessageItem";
|
||||||
|
|
||||||
export function ChatArea() {
|
export function ChatArea() {
|
||||||
const activeChannelId = useChannelStore((s) => s.activeChannelId);
|
const rawActiveChannelId = useChannelStore((s) => s.activeChannelId);
|
||||||
|
const activeChannelId = rawActiveChannelId ? rawActiveChannelId.toLowerCase() : null;
|
||||||
const channelsByServer = useChannelStore((s) => s.channelsByServer);
|
const channelsByServer = useChannelStore((s) => s.channelsByServer);
|
||||||
const activeServerId = useServerStore((s) => s.activeServerId);
|
const activeServerId = useServerStore((s) => s.activeServerId);
|
||||||
const messages = useMessageStore((s) =>
|
const messages = useMessageStore(
|
||||||
activeChannelId ? s.messagesByChannel[activeChannelId] || [] : [],
|
useCallback((s) => (activeChannelId ? s.messagesByChannel[activeChannelId] || [] : []), [activeChannelId])
|
||||||
);
|
);
|
||||||
const isLoading = useMessageStore((s) => s.isLoading);
|
const isLoading = useMessageStore((s) => s.isLoading);
|
||||||
const isLoadingOlder = useMessageStore((s) => s.isLoadingOlder);
|
const isLoadingOlder = useMessageStore((s) => s.isLoadingOlder);
|
||||||
@@ -846,9 +847,8 @@ export function ChatArea() {
|
|||||||
const lastReadId = activeChannelId ? readStates[activeChannelId] : undefined;
|
const lastReadId = activeChannelId ? readStates[activeChannelId] : undefined;
|
||||||
const showDivider = lastReadId && message.id === lastReadId && i < messages.length - 1;
|
const showDivider = lastReadId && message.id === lastReadId && i < messages.length - 1;
|
||||||
return (
|
return (
|
||||||
<>
|
<Fragment key={message.id}>
|
||||||
<MessageItem
|
<MessageItem
|
||||||
key={message.id}
|
|
||||||
message={message}
|
message={message}
|
||||||
memberUsernames={memberUsernames}
|
memberUsernames={memberUsernames}
|
||||||
selectMode={selectMode}
|
selectMode={selectMode}
|
||||||
@@ -873,7 +873,7 @@ export function ChatArea() {
|
|||||||
<span className="flex-1 border-t border-gb-red"></span>
|
<span className="flex-1 border-t border-gb-red"></span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<div ref={bottomRef} />
|
<div ref={bottomRef} />
|
||||||
|
|||||||
Reference in New Issue
Block a user