Skip to content

Commit

Permalink
Updates from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
bLopata committed Oct 14, 2024
1 parent 26e946f commit 9d10319
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 41 deletions.
2 changes: 0 additions & 2 deletions api/routers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions www/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ export default function Home() {
}
return msg;
});
}, false);

mutateMessages();
}, true);
} catch (error) {
console.error("Failed to update reaction:", error);
}
Expand Down
36 changes: 0 additions & 36 deletions www/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

0 comments on commit 9d10319

Please sign in to comment.