2023-02-21 21:31:36 -05:00
|
|
|
import React from 'react';
|
2023-02-06 13:27:28 -05:00
|
|
|
import Conversation from './Conversation';
|
|
|
|
|
|
2023-03-15 04:05:14 +08:00
|
|
|
export default function Conversations({ conversations, conversationId, pageNumber, pages, nextPage, previousPage, moveToTop }) {
|
|
|
|
|
const clickHandler = (func) => async (e) => {
|
2023-03-05 14:41:50 -05:00
|
|
|
e.preventDefault();
|
2023-03-15 04:05:14 +08:00
|
|
|
await func();
|
2023-03-05 14:41:50 -05:00
|
|
|
};
|
2023-02-11 11:37:20 -05:00
|
|
|
|
2023-02-06 13:27:28 -05:00
|
|
|
return (
|
2023-02-14 16:15:45 -05:00
|
|
|
<>
|
|
|
|
|
{conversations &&
|
|
|
|
|
conversations.length > 0 &&
|
2023-02-21 21:31:36 -05:00
|
|
|
conversations.map((convo) => {
|
2023-02-20 21:16:40 -05:00
|
|
|
const bingData = convo.conversationSignature
|
|
|
|
|
? {
|
2023-03-08 19:47:23 -05:00
|
|
|
jailbreakConversationId: convo.jailbreakConversationId,
|
2023-02-20 21:16:40 -05:00
|
|
|
conversationSignature: convo.conversationSignature,
|
2023-03-08 22:30:29 -05:00
|
|
|
parentMessageId: convo.parentMessageId || null,
|
2023-02-20 21:16:40 -05:00
|
|
|
clientId: convo.clientId,
|
|
|
|
|
invocationId: convo.invocationId
|
|
|
|
|
}
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Conversation
|
|
|
|
|
key={convo.conversationId}
|
|
|
|
|
id={convo.conversationId}
|
2023-03-13 13:11:53 +08:00
|
|
|
model={convo.model}
|
2023-02-20 21:16:40 -05:00
|
|
|
parentMessageId={convo.parentMessageId}
|
|
|
|
|
title={convo.title}
|
|
|
|
|
conversationId={conversationId}
|
2023-03-04 17:39:06 -05:00
|
|
|
chatGptLabel={convo.chatGptLabel}
|
|
|
|
|
promptPrefix={convo.promptPrefix}
|
2023-02-20 21:16:40 -05:00
|
|
|
bingData={bingData}
|
2023-03-15 04:05:14 +08:00
|
|
|
retainView={moveToTop}
|
2023-02-20 21:16:40 -05:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2023-03-15 04:05:14 +08:00
|
|
|
<div className="m-auto mt-4 mb-2 flex justify-center items-center gap-2">
|
|
|
|
|
<button
|
|
|
|
|
onClick={clickHandler(previousPage)}
|
|
|
|
|
className={"flex btn btn-small transition bg-transition dark:text-white disabled:text-gray-300 dark:disabled:text-gray-400 m-auto gap-2 hover:bg-gray-800" + (pageNumber<=1?" hidden-visibility":"")}
|
|
|
|
|
disabled={pageNumber<=1}
|
|
|
|
|
>
|
|
|
|
|
<<
|
|
|
|
|
</button>
|
|
|
|
|
<span className="flex-none text-gray-400">
|
|
|
|
|
{pageNumber} / {pages}
|
|
|
|
|
</span>
|
|
|
|
|
<button
|
|
|
|
|
onClick={clickHandler(nextPage)}
|
|
|
|
|
className={"flex btn btn-small transition bg-transition dark:text-white disabled:text-gray-300 dark:disabled:text-gray-400 m-auto gap-2 hover:bg-gray-800" + (pageNumber>=pages?" hidden-visibility":"")}
|
|
|
|
|
disabled={pageNumber>=pages}
|
|
|
|
|
>
|
|
|
|
|
>>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2023-02-14 16:15:45 -05:00
|
|
|
</>
|
2023-02-06 13:27:28 -05:00
|
|
|
);
|
|
|
|
|
}
|