From 9d10319007d50561a35377ff6fe073ed43359621 Mon Sep 17 00:00:00 2001 From: Ben Lopata Date: Mon, 14 Oct 2024 15:41:45 -0500 Subject: [PATCH] Updates from code review. --- api/routers/chat.py | 2 -- www/app/page.tsx | 4 +--- www/utils/api.ts | 36 ------------------------------------ 3 files changed, 1 insertion(+), 41 deletions(-) diff --git a/api/routers/chat.py b/api/routers/chat.py index b318f49..c780f98 100644 --- a/api/routers/chat.py +++ b/api/routers/chat.py @@ -113,10 +113,8 @@ async def add_or_remove_reaction( metadata = message.metadata or {} if reaction is None: - # Remove the reaction metadata.pop('reaction', None) else: - # Set or update the reaction metadata['reaction'] = reaction honcho.apps.users.sessions.messages.update( diff --git a/www/app/page.tsx b/www/app/page.tsx index 622f1aa..f904677 100644 --- a/www/app/page.tsx +++ b/www/app/page.tsx @@ -163,9 +163,7 @@ export default function Home() { } return msg; }); - }, false); - - mutateMessages(); + }, true); } catch (error) { console.error("Failed to update reaction:", error); } diff --git a/www/utils/api.ts b/www/utils/api.ts index 2aa7842..11d4f35 100644 --- a/www/utils/api.ts +++ b/www/utils/api.ts @@ -217,40 +217,4 @@ export class API { throw error; } } - - async getReaction( - conversationId: string, - messageId: string, - ): Promise<{ reaction: Reaction }> { - try { - const response = await fetch( - `${this.url}/api/reaction/${messageId}?user_id=${this.userId}&conversation_id=${conversationId}`, - { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }, - ); - - if (!response.ok) { - throw new Error("Failed to get reaction"); - } - - const data = await response.json(); - - // Validate the reaction - if ( - data.reaction !== null && - !["thumbs_up", "thumbs_down"].includes(data.reaction) - ) { - throw new Error("Invalid reaction received from server"); - } - - return data as { reaction: Reaction }; - } catch (error) { - console.error("Error getting reaction:", error); - throw error; - } - } }