2023-02-11 13:48:48 -05:00
|
|
|
import React, { useState } from 'react';
|
2023-02-06 13:27:28 -05:00
|
|
|
import Conversation from './Conversation';
|
|
|
|
|
|
2023-02-14 16:15:45 -05:00
|
|
|
export default function Conversations({ conversations, conversationId }) {
|
2023-02-11 11:37:20 -05:00
|
|
|
// const currentRef = useRef(null);
|
|
|
|
|
|
|
|
|
|
// const scrollToTop = () => {
|
|
|
|
|
// currentRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// // this useEffect triggers the following warning in the Messages component (but not here):
|
|
|
|
|
// // Warning: Internal React error: Expected static flag was missing.
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
// scrollToTop();
|
|
|
|
|
// }, [conversationId]);
|
|
|
|
|
|
2023-02-06 13:27:28 -05:00
|
|
|
return (
|
2023-02-14 16:15:45 -05:00
|
|
|
<>
|
|
|
|
|
{/* <div ref={currentRef} /> */}
|
|
|
|
|
{conversations &&
|
|
|
|
|
conversations.length > 0 &&
|
2023-02-20 21:16:40 -05:00
|
|
|
conversations.map((convo, i) => {
|
|
|
|
|
const bingData = convo.conversationSignature
|
|
|
|
|
? {
|
|
|
|
|
conversationSignature: convo.conversationSignature,
|
|
|
|
|
clientId: convo.clientId,
|
|
|
|
|
invocationId: convo.invocationId
|
|
|
|
|
}
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Conversation
|
|
|
|
|
key={convo.conversationId}
|
|
|
|
|
id={convo.conversationId}
|
|
|
|
|
parentMessageId={convo.parentMessageId}
|
|
|
|
|
title={convo.title}
|
|
|
|
|
conversationId={conversationId}
|
|
|
|
|
bingData={bingData}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2023-02-14 16:15:45 -05:00
|
|
|
{conversations && conversations.length >= 12 && (
|
|
|
|
|
<button className="btn btn-dark btn-small m-auto mb-2 flex justify-center gap-2">
|
|
|
|
|
Show more
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
2023-02-06 13:27:28 -05:00
|
|
|
);
|
|
|
|
|
}
|