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 = () => {
|
export const EditModal = () => {
|
||||||
const { activeChannel, changeGroupChatName } = useMessengerContext();
|
const { activeChannel, changeGroupChatName } = useMessengerContext();
|
||||||
|
const { setModal } = useModal(EditModalName);
|
||||||
|
|
||||||
const [groupName, setGroupName] = useState("");
|
const [groupName, setGroupName] = useState("");
|
||||||
const [image, setImage] = useState("");
|
const [image, setImage] = useState("");
|
||||||
|
|
||||||
|
@ -31,12 +33,16 @@ export const EditModal = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const { setModal } = useModal(EditModalName);
|
|
||||||
|
|
||||||
const handleUpload = () => {
|
const handleUpload = () => {
|
||||||
if (activeChannel) {
|
if (activeChannel) {
|
||||||
activeChannel.icon = image;
|
if (image) {
|
||||||
changeGroupChatName(groupName, activeChannel.id);
|
activeChannel.icon = image; // Need function to send image to waku
|
||||||
|
setImage("");
|
||||||
|
}
|
||||||
|
if (groupName) {
|
||||||
|
changeGroupChatName(groupName, activeChannel.id);
|
||||||
|
setGroupName("");
|
||||||
|
}
|
||||||
setModal(false);
|
setModal(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -64,10 +70,11 @@ export const EditModal = () => {
|
||||||
</NameSection>
|
</NameSection>
|
||||||
<LogoSection>
|
<LogoSection>
|
||||||
<Label>Group image</Label>
|
<Label>Group image</Label>
|
||||||
<GroupLogo icon={image || activeChannel?.icon}>
|
<GroupLogo icon={activeChannel?.icon}>
|
||||||
{!activeChannel?.icon &&
|
{!activeChannel?.icon &&
|
||||||
!image &&
|
!image &&
|
||||||
activeChannel?.name?.slice(0, 1)?.toUpperCase()}
|
activeChannel?.name?.slice(0, 1)?.toUpperCase()}
|
||||||
|
{image && <LogoPreview src={image} />}
|
||||||
<AddPictureInputWrapper>
|
<AddPictureInputWrapper>
|
||||||
<AddIcon />
|
<AddIcon />
|
||||||
<AddPictureInput
|
<AddPictureInput
|
||||||
|
@ -128,6 +135,12 @@ const GroupLogo = styled(ChannelLogo)`
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const LogoPreview = styled.img`
|
||||||
|
width: 128px;
|
||||||
|
height: 128px;
|
||||||
|
border-radius: 50%;
|
||||||
|
`;
|
||||||
|
|
||||||
const AddPictureInputWrapper = styled(AddWrapper)`
|
const AddPictureInputWrapper = styled(AddWrapper)`
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 8px;
|
right: 8px;
|
||||||
|
|
|
@ -38,7 +38,7 @@ export function useGroupChats(
|
||||||
.map(contactFromId);
|
.map(contactFromId);
|
||||||
const channel: ChannelData = {
|
const channel: ChannelData = {
|
||||||
id: chat.chatId,
|
id: chat.chatId,
|
||||||
name: chat.name ?? chat.chatId,
|
name: chat.name ?? chat.chatId.slice(0, 10),
|
||||||
type: "group",
|
type: "group",
|
||||||
description: `${chat.members.length} members`,
|
description: `${chat.members.length} members`,
|
||||||
members: members,
|
members: members,
|
||||||
|
|
Loading…
Reference in New Issue