From a65a3a84aad94ccff4b07eb26a7989ce79774476 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Fri, 27 Oct 2023 22:03:46 +0800 Subject: [PATCH] Added enter button to conversation page and fixed error not properly displaying when sending an invalid message. Also added refresh interval of 20 seconds to study group query in conversations page to automatically refresh students count --- src/icons/CaretLeftIcon/CaretLeftIcon.tsx | 6 +- src/icons/CaretRightIcon/CaretLeftIcon.tsx | 28 +++++++++ .../ConversationPage/ConversationPage.tsx | 58 +++++++++++++------ 3 files changed, 70 insertions(+), 22 deletions(-) create mode 100644 src/icons/CaretRightIcon/CaretLeftIcon.tsx diff --git a/src/icons/CaretLeftIcon/CaretLeftIcon.tsx b/src/icons/CaretLeftIcon/CaretLeftIcon.tsx index e2caaa5..d6f2c5c 100644 --- a/src/icons/CaretLeftIcon/CaretLeftIcon.tsx +++ b/src/icons/CaretLeftIcon/CaretLeftIcon.tsx @@ -3,7 +3,7 @@ import { IconProps } from "../../interfaces/Interfaces"; import { Svg, Path } from "react-native-svg"; import { colors } from "../../styles"; -export default function CaretLeftIcon(props: IconProps) { +export default function CaretRightIcon(props: IconProps) { return ( <> diff --git a/src/icons/CaretRightIcon/CaretLeftIcon.tsx b/src/icons/CaretRightIcon/CaretLeftIcon.tsx new file mode 100644 index 0000000..e2caaa5 --- /dev/null +++ b/src/icons/CaretRightIcon/CaretLeftIcon.tsx @@ -0,0 +1,28 @@ +import * as React from "react"; +import { IconProps } from "../../interfaces/Interfaces"; +import { Svg, Path } from "react-native-svg"; +import { colors } from "../../styles"; + +export default function CaretLeftIcon(props: IconProps) { + return ( + <> + + + + + + ); +} diff --git a/src/routes/ConversationPage/ConversationPage.tsx b/src/routes/ConversationPage/ConversationPage.tsx index b2fd297..5f433ef 100644 --- a/src/routes/ConversationPage/ConversationPage.tsx +++ b/src/routes/ConversationPage/ConversationPage.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { ActivityIndicator, Image } from "react-native"; +import { ActivityIndicator, Image, Pressable } from "react-native"; import styles from "../../styles"; import { View, @@ -36,6 +36,7 @@ import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContai import AsyncStorage from "@react-native-async-storage/async-storage"; import { useSelector } from "react-redux"; import { RootState } from "../../features/redux/Store/Store"; +import CaretRightIcon from "../../icons/CaretLeftIcon/CaretLeftIcon"; export default function ConversationPage() { const toast = useToast(); @@ -70,6 +71,7 @@ export default function ConversationPage() { enabled: student_status?.study_group != "" && student_status?.study_group != null, queryKey: ["study_group"], + refetchInterval: 20, queryFn: async () => { const data = await GetStudyGroup(student_status?.study_group || ""); if (data[0] == false) { @@ -162,7 +164,7 @@ export default function ConversationPage() { mutationFn: async (info: MessagePostType) => { const data = await PostMessage(info); if (data[0] != true) { - return Promise.reject(new Error()); + return Promise.reject(new Error(data[1])); } return data; }, @@ -293,23 +295,41 @@ export default function ConversationPage() { There are no messages )} - - ): void => { - setMessage(e.nativeEvent.text); - }} - onSubmitEditing={() => { - send_message.mutate({ - message_content: message, - }); - setMessage(""); - }} - /> + + + ): void => { + setMessage(e.nativeEvent.text); + }} + onSubmitEditing={() => { + send_message.mutate({ + message_content: message, + }); + setMessage(""); + }} + /> + { + send_message.mutate({ + message_content: message, + }); + setMessage(""); + }} + > + + + );