From 27b81243fcdb598ba9aa1a2aacc56580a648ae19 Mon Sep 17 00:00:00 2001 From: Maria Rushkova <66270386+mrushkova@users.noreply.github.com> Date: Thu, 20 Jan 2022 02:17:02 +0100 Subject: [PATCH] Group img preview (#196) * Add group img preview * Cut group default name * Clear modal form --- .../src/components/Modals/EditModal.tsx | 23 +++++++++++++++---- .../src/hooks/messenger/useGroupChats.ts | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/react-chat/src/components/Modals/EditModal.tsx b/packages/react-chat/src/components/Modals/EditModal.tsx index df89226..6d3a8a5 100644 --- a/packages/react-chat/src/components/Modals/EditModal.tsx +++ b/packages/react-chat/src/components/Modals/EditModal.tsx @@ -22,6 +22,8 @@ export const EditModalName = "editModal"; export const EditModal = () => { const { activeChannel, changeGroupChatName } = useMessengerContext(); + const { setModal } = useModal(EditModalName); + const [groupName, setGroupName] = useState(""); const [image, setImage] = useState(""); @@ -31,12 +33,16 @@ export const EditModal = () => { } }; - const { setModal } = useModal(EditModalName); - const handleUpload = () => { if (activeChannel) { - activeChannel.icon = image; - changeGroupChatName(groupName, activeChannel.id); + if (image) { + activeChannel.icon = image; // Need function to send image to waku + setImage(""); + } + if (groupName) { + changeGroupChatName(groupName, activeChannel.id); + setGroupName(""); + } setModal(false); } }; @@ -64,10 +70,11 @@ export const EditModal = () => { - + {!activeChannel?.icon && !image && activeChannel?.name?.slice(0, 1)?.toUpperCase()} + {image && }