Leaving group (#120)
* Leaving group * YArn fix * Fix setting active channel group * Fix leaving group * Add community icon backgroud
This commit is contained in:
parent
42dc2c53a9
commit
70e4f34cfe
|
@ -81,7 +81,7 @@ export function Channels({
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setActiveChannel({
|
setActiveChannel({
|
||||||
id: group.join(""),
|
id: group.join(""),
|
||||||
name: group.join(", ").slice(0, 10),
|
name: group.join(", "),
|
||||||
type: "group",
|
type: "group",
|
||||||
});
|
});
|
||||||
setCreateChat(false);
|
setCreateChat(false);
|
||||||
|
|
|
@ -43,8 +43,7 @@ export function EmptyChannel({ channel }: EmptyChannelProps) {
|
||||||
</EmptyTextGroup>
|
</EmptyTextGroup>
|
||||||
) : (
|
) : (
|
||||||
<EmptyText>
|
<EmptyText>
|
||||||
Welcome to the beginning of the <span>#{channel.name}</span> <br />
|
Welcome to the beginning of the <span>#{channel.name}</span> channel!
|
||||||
channel!
|
|
||||||
</EmptyText>
|
</EmptyText>
|
||||||
)}
|
)}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
|
|
|
@ -130,6 +130,7 @@ export function ChatBody({
|
||||||
setShowChannelMenu={setShowChannelMenu}
|
setShowChannelMenu={setShowChannelMenu}
|
||||||
setEditGroup={setEditGroup}
|
setEditGroup={setEditGroup}
|
||||||
onEditClick={onEditClick}
|
onEditClick={onEditClick}
|
||||||
|
setGroupList={setGroupList}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ChatTopbar>
|
</ChatTopbar>
|
||||||
|
|
|
@ -15,9 +15,20 @@ export const CommunityIdentity = ({
|
||||||
className,
|
className,
|
||||||
}: CommunityIdentityProps) => {
|
}: CommunityIdentityProps) => {
|
||||||
const { communityData } = useMessengerContext();
|
const { communityData } = useMessengerContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className={className}>
|
<Row className={className}>
|
||||||
<Logo src={communityData?.icon} alt={`${communityData?.name} logo`} />
|
<Logo
|
||||||
|
style={{
|
||||||
|
backgroundImage: communityData?.icon
|
||||||
|
? `url(${communityData?.icon}`
|
||||||
|
: "",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
{communityData?.icon === undefined &&
|
||||||
|
communityData?.name.slice(0, 1).toUpperCase()}
|
||||||
|
</Logo>
|
||||||
<Column>
|
<Column>
|
||||||
<Name>{communityData?.name}</Name>
|
<Name>{communityData?.name}</Name>
|
||||||
<Subtitle>{subtitle}</Subtitle>
|
<Subtitle>{subtitle}</Subtitle>
|
||||||
|
@ -36,11 +47,22 @@ export const Column = styled.div`
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Logo = styled.img`
|
const Logo = styled.div`
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
|
background-color: ${({ theme }) => theme.tertiary};
|
||||||
|
background-size: cover;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
color: ${({ theme }) => theme.iconTextColor};
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 20px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Name = styled.p`
|
const Name = styled.p`
|
||||||
|
|
|
@ -22,6 +22,7 @@ interface ChannelMenuProps {
|
||||||
setShowChannelMenu: (val: boolean) => void;
|
setShowChannelMenu: (val: boolean) => void;
|
||||||
setEditGroup: (val: boolean) => void;
|
setEditGroup: (val: boolean) => void;
|
||||||
onEditClick: () => void;
|
onEditClick: () => void;
|
||||||
|
setGroupList: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChannelMenu = ({
|
export const ChannelMenu = ({
|
||||||
|
@ -31,9 +32,11 @@ export const ChannelMenu = ({
|
||||||
setShowChannelMenu,
|
setShowChannelMenu,
|
||||||
setEditGroup,
|
setEditGroup,
|
||||||
onEditClick,
|
onEditClick,
|
||||||
|
setGroupList,
|
||||||
}: ChannelMenuProps) => {
|
}: ChannelMenuProps) => {
|
||||||
const narrow = useNarrow();
|
const narrow = useNarrow();
|
||||||
const { clearNotifications } = useMessengerContext();
|
const { clearNotifications, setActiveChannel, channels } =
|
||||||
|
useMessengerContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
|
@ -50,7 +53,12 @@ export const ChannelMenu = ({
|
||||||
)}
|
)}
|
||||||
{channel.type === "group" && (
|
{channel.type === "group" && (
|
||||||
<>
|
<>
|
||||||
<MenuItem onClick={() => setEditGroup(true)}>
|
<MenuItem
|
||||||
|
onClick={() => {
|
||||||
|
setEditGroup(true);
|
||||||
|
setShowChannelMenu(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<AddMemberIconSvg width={16} height={16} />
|
<AddMemberIconSvg width={16} height={16} />
|
||||||
<MenuText>Add / remove from group</MenuText>
|
<MenuText>Add / remove from group</MenuText>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
@ -80,7 +88,16 @@ export const ChannelMenu = ({
|
||||||
{channel.type === "group" && (
|
{channel.type === "group" && (
|
||||||
<MenuSection>
|
<MenuSection>
|
||||||
{" "}
|
{" "}
|
||||||
<MenuItem onClick={() => channel}>
|
<MenuItem
|
||||||
|
onClick={() => {
|
||||||
|
setGroupList((prevGroups: string[][]) => {
|
||||||
|
const idx = prevGroups.indexOf(channel.name.split(", "));
|
||||||
|
return idx >= 0 ? prevGroups.splice(idx, 1) : [];
|
||||||
|
});
|
||||||
|
setActiveChannel(channels[0]);
|
||||||
|
setShowChannelMenu(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<LeftIconSvg width={16} height={16} />
|
<LeftIconSvg width={16} height={16} />
|
||||||
<MenuText>Leave Group</MenuText>
|
<MenuText>Leave Group</MenuText>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
Loading…
Reference in New Issue