用户消息处理优化

This commit is contained in:
xintaofei
2026-03-10 20:18:14 +08:00
parent 11a5484b79
commit 516aebd7e5

View File

@@ -173,16 +173,13 @@ const PendingTypingIndicator = memo(function PendingTypingIndicator() {
const AutoScrollOnSend = memo(function AutoScrollOnSend({ const AutoScrollOnSend = memo(function AutoScrollOnSend({
signal, signal,
enabled,
}: { }: {
signal: number signal: number
enabled: boolean
}) { }) {
const { scrollToBottom } = useStickToBottomContext() const { scrollToBottom } = useStickToBottomContext()
const lastSignalRef = useRef(signal) const lastSignalRef = useRef(signal)
useEffect(() => { useEffect(() => {
if (!enabled) return
if (signal === lastSignalRef.current) return if (signal === lastSignalRef.current) return
lastSignalRef.current = signal lastSignalRef.current = signal
@@ -193,7 +190,7 @@ const AutoScrollOnSend = memo(function AutoScrollOnSend({
return () => { return () => {
cancelAnimationFrame(rafId) cancelAnimationFrame(rafId)
} }
}, [enabled, scrollToBottom, signal]) }, [scrollToBottom, signal])
return null return null
}) })
@@ -369,7 +366,7 @@ export function MessageListView({
className="flex-1 min-h-0" className="flex-1 min-h-0"
resize={shouldUseSmoothResize ? "smooth" : undefined} resize={shouldUseSmoothResize ? "smooth" : undefined}
> >
<AutoScrollOnSend signal={sendSignal} enabled={isActive} /> <AutoScrollOnSend signal={sendSignal} />
<VirtualizedMessageThread <VirtualizedMessageThread
items={threadItems} items={threadItems}
getItemKey={(item) => item.key} getItemKey={(item) => item.key}