From 032d9ae4714038c2276aa303c4c1afc0e1ba316c Mon Sep 17 00:00:00 2001
From: Szymon Szlachtowicz <38212223+Szymx95@users.noreply.github.com>
Date: Thu, 9 Dec 2021 14:38:29 +0100
Subject: [PATCH] Refactor chat messages (#151)
---
.../src/components/Chat/ChatMessages.tsx | 53 +++++++++++--------
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/packages/react-chat/src/components/Chat/ChatMessages.tsx b/packages/react-chat/src/components/Chat/ChatMessages.tsx
index 3145300..a81df7a 100644
--- a/packages/react-chat/src/components/Chat/ChatMessages.tsx
+++ b/packages/react-chat/src/components/Chat/ChatMessages.tsx
@@ -29,6 +29,37 @@ import { ChatMessageContent } from "./ChatMessageContent";
const today = new Date();
+function calcHeight(quote: ChatMessage) {
+ if (quote.image && quote.content) {
+ return 88;
+ } else if (quote.image && !quote.content) {
+ return 68;
+ } else {
+ return 25;
+ }
+}
+
+type MessageQuoteProps = {
+ quote: ChatMessage | undefined;
+};
+
+function MessageQuote({ quote }: MessageQuoteProps) {
+ if (quote) {
+ return (
+
+
+
+ {" "}
+ {quote.sender}
+
+ {quote.content}
+ {quote.image && }
+
+ );
+ }
+ return null;
+}
+
type ChatUiMessageProps = {
idx: number;
message: ChatMessage;
@@ -98,28 +129,8 @@ function ChatUiMessage({
: message.date.toLocaleDateString()}
)}
-
- {quote && (
-
-
-
- {" "}
- {quote.sender}
-
- {quote.content}
- {quote.image && }
-
- )}
+
{