From 8e5e0546df38cc851f094bee3e31335d81426482 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Fri, 13 Oct 2023 14:06:04 +0800 Subject: [PATCH] Align own user messages to the right and other user messages to the left --- src/routes/ConversationPage/ConversationPage.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/ConversationPage/ConversationPage.tsx b/src/routes/ConversationPage/ConversationPage.tsx index fdba4cf..b2fd297 100644 --- a/src/routes/ConversationPage/ConversationPage.tsx +++ b/src/routes/ConversationPage/ConversationPage.tsx @@ -34,9 +34,12 @@ import { useToast } from "react-native-toast-notifications"; import { useQueryClient } from "@tanstack/react-query"; import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer"; import AsyncStorage from "@react-native-async-storage/async-storage"; +import { useSelector } from "react-redux"; +import { RootState } from "../../features/redux/Store/Store"; export default function ConversationPage() { const toast = useToast(); + const user = useSelector((state: RootState) => state.user); // Student Status const [student_status, setStudentStatus] = useState(); const StudentStatusQuery = useQuery({ @@ -248,7 +251,10 @@ export default function ConversationPage() { key={message.id} style={{ ...styles.message_contentContainer, - alignItems: index % 2 == 0 ? "flex-end" : "flex-start", + alignItems: + message.user === user.user.username + ? "flex-end" + : "flex-start", }} >