+ );
+};
+
+export default Spinner;
diff --git a/www/utils/api.ts b/www/utils/api.ts
index 2c29e45..50b9a78 100644
--- a/www/utils/api.ts
+++ b/www/utils/api.ts
@@ -1,5 +1,7 @@
+import { type Reaction } from "@/components/messagebox";
+
const defaultMessage: Message = {
- text: `I'm your Aristotelian learning companion — here to help you follow your curiosity in whatever direction you like. My engineering makes me extremely receptive to your needs and interests. You can reply normally, and I’ll always respond!\n\nIf I'm off track, just say so!\n\nNeed to leave or just done chatting? Let me know! I’m conversational by design so I’ll say goodbye 😊.`,
+ text: `I'm your Aristotelian learning companion — here to help you follow your curiosity in whatever direction you like. My engineering makes me extremely receptive to your needs and interests. You can reply normally, and I’ll always respond!\n\nIf I'm off track, just say so!\n\nNeed to leave or just done chatting? Let me know! I’m conversational by design so I’ll say goodbye 😊.`,
isUser: false,
id: '',
};
@@ -8,6 +10,7 @@ export interface Message {
text: string;
isUser: boolean;
id: string;
+ metadata?: { reaction?: Reaction };
}
export class Conversation {
@@ -154,6 +157,7 @@ export class API {
text: rawMessage.content,
isUser: rawMessage.isUser,
id: rawMessage.id,
+ metadata: rawMessage.metadata,
};
});
@@ -186,4 +190,31 @@ export class API {
return null;
}
}
+
+ async addOrRemoveReaction(
+ conversationId: string,
+ messageId: string,
+ reaction: Reaction,
+ ): Promise<{ status: string }> {
+ try {
+ const response = await fetch(
+ `${this.url}/api/reaction/${messageId}?user_id=${this.userId}&conversation_id=${conversationId}`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ reaction: reaction || undefined }),
+ },
+ );
+ if (!response.ok) {
+ throw new Error("Failed to update reaction");
+ }
+
+ return await response.json();
+ } catch (error) {
+ console.error("Error updating reaction:", error);
+ throw error;
+ }
+ }
}