2023-02-11 13:48:48 -05:00
|
|
|
import React, { useState } from 'react';
|
2023-02-11 11:37:20 -05:00
|
|
|
import { useSelector } from 'react-redux';
|
2023-02-06 13:27:28 -05:00
|
|
|
import Conversation from './Conversation';
|
|
|
|
|
|
2023-02-07 00:05:00 -05:00
|
|
|
export default function Conversations({ conversations }) {
|
2023-02-11 13:48:48 -05:00
|
|
|
const [isHovering, setIsHovering] = useState(false);
|
2023-02-11 11:37:20 -05:00
|
|
|
const { conversationId } = useSelector((state) => state.convo);
|
|
|
|
|
// 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-11 13:48:48 -05:00
|
|
|
<div
|
|
|
|
|
className={`-mr-2 flex-1 flex-col overflow-y-auto ${
|
|
|
|
|
isHovering ? '' : 'scrollbar-transparent'
|
|
|
|
|
} border-b border-white/20`}
|
|
|
|
|
onMouseEnter={() => setIsHovering(true)}
|
|
|
|
|
onMouseLeave={() => setIsHovering(false)}
|
|
|
|
|
>
|
2023-02-06 13:27:28 -05:00
|
|
|
<div className="flex flex-col gap-2 text-sm text-gray-100">
|
2023-02-11 11:37:20 -05:00
|
|
|
{/* <div ref={currentRef} /> */}
|
2023-02-06 16:00:59 -05:00
|
|
|
{conversations &&
|
|
|
|
|
conversations.map((convo, i) => (
|
|
|
|
|
<Conversation
|
|
|
|
|
key={convo.conversationId}
|
2023-02-06 18:25:11 -05:00
|
|
|
id={convo.conversationId}
|
|
|
|
|
parentMessageId={convo.parentMessageId}
|
2023-02-06 16:00:59 -05:00
|
|
|
title={convo.title}
|
2023-02-11 11:37:20 -05:00
|
|
|
conversationId={conversationId}
|
2023-02-06 16:00:59 -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
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|