Group img preview (#196)
* Add group img preview * Cut group default name * Clear modal form
This commit is contained in:
parent
f5dd23ce97
commit
27b81243fc
|
@ -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 = () => {
|
|||
</NameSection>
|
||||
<LogoSection>
|
||||
<Label>Group image</Label>
|
||||
<GroupLogo icon={image || activeChannel?.icon}>
|
||||
<GroupLogo icon={activeChannel?.icon}>
|
||||
{!activeChannel?.icon &&
|
||||
!image &&
|
||||
activeChannel?.name?.slice(0, 1)?.toUpperCase()}
|
||||
{image && <LogoPreview src={image} />}
|
||||
<AddPictureInputWrapper>
|
||||
<AddIcon />
|
||||
<AddPictureInput
|
||||
|
@ -128,6 +135,12 @@ const GroupLogo = styled(ChannelLogo)`
|
|||
margin-right: 0;
|
||||
`;
|
||||
|
||||
const LogoPreview = styled.img`
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
border-radius: 50%;
|
||||
`;
|
||||
|
||||
const AddPictureInputWrapper = styled(AddWrapper)`
|
||||
top: 0;
|
||||
right: 8px;
|
||||
|
|
|
@ -38,7 +38,7 @@ export function useGroupChats(
|
|||
.map(contactFromId);
|
||||
const channel: ChannelData = {
|
||||
id: chat.chatId,
|
||||
name: chat.name ?? chat.chatId,
|
||||
name: chat.name ?? chat.chatId.slice(0, 10),
|
||||
type: "group",
|
||||
description: `${chat.members.length} members`,
|
||||
members: members,
|
||||
|
|
Loading…
Reference in New Issue