You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
901 B
TypeScript
27 lines
901 B
TypeScript
import { useConvoIdFromContext } from '../../../../contexts/ConvoIdContext';
|
|
import { useConversationUsername, useIsPublic } from '../../../../hooks/useParamSelector';
|
|
import { showLeaveGroupByConvoId } from '../../../../interactions/conversationInteractions';
|
|
import { Localizer } from '../../../basic/Localizer';
|
|
import { ItemWithDataTestId } from '../MenuItemWithDataTestId';
|
|
import { showLeaveCommunityItem } from './guard';
|
|
|
|
export const LeaveCommunityMenuItem = () => {
|
|
const convoId = useConvoIdFromContext();
|
|
const username = useConversationUsername(convoId) || convoId;
|
|
const isPublic = useIsPublic(convoId);
|
|
|
|
if (!showLeaveCommunityItem({ isPublic })) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ItemWithDataTestId
|
|
onClick={() => {
|
|
void showLeaveGroupByConvoId(convoId, username);
|
|
}}
|
|
>
|
|
<Localizer token="communityLeave" />
|
|
</ItemWithDataTestId>
|
|
);
|
|
};
|