mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 03:10:15 +01:00
41 lines
999 B
React
41 lines
999 B
React
|
|
import React, { useState } from 'react';
|
||
|
|
import Message from './Message';
|
||
|
|
|
||
|
|
export default function MultiMessage({
|
||
|
|
messageList,
|
||
|
|
messages,
|
||
|
|
scrollToBottom,
|
||
|
|
currentEditId,
|
||
|
|
setCurrentEditId
|
||
|
|
}) {
|
||
|
|
const [siblingIdx, setSiblingIdx] = useState(0);
|
||
|
|
|
||
|
|
const setSiblingIdxRev = (value) => {
|
||
|
|
setSiblingIdx(messageList?.length - value - 1);
|
||
|
|
};
|
||
|
|
|
||
|
|
// if (!messageList?.length) return null;
|
||
|
|
if (!(messageList && messageList.length)) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (siblingIdx >= messageList?.length) {
|
||
|
|
setSiblingIdx(0);
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
return (
|
||
|
|
<Message
|
||
|
|
key={messageList[messageList.length - siblingIdx - 1].messageId}
|
||
|
|
message={messageList[messageList.length - siblingIdx - 1]}
|
||
|
|
messages={messages}
|
||
|
|
scrollToBottom={scrollToBottom}
|
||
|
|
currentEditId={currentEditId}
|
||
|
|
setCurrentEditId={setCurrentEditId}
|
||
|
|
siblingIdx={messageList.length - siblingIdx - 1}
|
||
|
|
siblingCount={messageList.length}
|
||
|
|
setSiblingIdx={setSiblingIdxRev}
|
||
|
|
/>
|
||
|
|
);
|
||
|
|
}
|