From fe15e1ecc802d47e62c05ce0b85983b43d0d1e33 Mon Sep 17 00:00:00 2001 From: hyusap Date: Mon, 25 Sep 2023 18:37:32 -0400 Subject: [PATCH] refactor conversation class - Create a new class `Conversation` in `api.ts` to handle conversations. - Move the logic for getting messages and sending messages to the `Conversation` class. - Add a constructor to initialize the `Conversation` with the appropriate API instance and conversation ID. - Add a `getMessages` method to fetch messages for the conversation. - Add a `chat` method to send a message in the conversation. - Update the code to use the `Conversation` class instead of making API calls directly. - Update the `Home` component to use the new `Conversation` class for fetching messages and sending messages. - Remove unused imports and variables. --- www/app/page.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/www/app/page.tsx b/www/app/page.tsx index 3c73d69..d0631c4 100644 --- a/www/app/page.tsx +++ b/www/app/page.tsx @@ -150,10 +150,7 @@ export default function Home() {

)} -
+
{messages.map((message, i) => ( @@ -178,6 +175,9 @@ export default function Home() { className={`flex-1 px-3 py-1 lg:px-5 lg:py-3 bg-gray-100 text-gray-400 rounded-2xl border-2 ${ canSend ? " border-green-200" : "border-red-200 opacity-50" }`} + className={`flex-1 px-3 py-1 lg:px-5 lg:py-3 bg-gray-100 text-gray-400 rounded-2xl border-2 ${ + canSend ? " border-green-200" : "border-red-200 opacity-50" + }`} disabled={!canSend} />