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.
session-desktop/ts/components/session/menu/ConversationListItemContext...

104 lines
2.6 KiB
TypeScript

import React, { useState } from 'react';
import { animation, Menu } from 'react-contexify';
import { ConversationTypeEnum } from '../../../models/conversation';
import {
getBlockMenuItem,
getChangeNicknameMenuItem,
getClearNicknameMenuItem,
getCopyMenuItem,
getDeleteContactMenuItem,
getDeleteMessagesMenuItem,
getInviteContactMenuItem,
getLeaveGroupMenuItem,
getMarkAllReadMenuItem,
} from './Menu';
export type PropsContextConversationItem = {
id: string;
triggerId: string;
type: ConversationTypeEnum;
isMe: boolean;
isPublic?: boolean;
isBlocked?: boolean;
hasNickname?: boolean;
isKickedFromGroup?: boolean;
left?: boolean;
theme?: any
onDeleteMessages?: () => void;
onDeleteContact?: () => void;
onLeaveGroup?: () => void;
onBlockContact?: () => void;
onMarkAllRead: () => void;
onCopyPublicKey?: () => void;
onUnblockContact?: () => void;
onInviteContacts?: () => void;
onClearNickname?: () => void;
onChangeNickname?: () => void;
};
export const ConversationListItemContextMenu = (props: PropsContextConversationItem) => {
const {
id,
triggerId,
isBlocked,
isMe,
isPublic,
hasNickname,
type,
left,
isKickedFromGroup,
onDeleteContact,
onDeleteMessages,
onBlockContact,
onClearNickname,
onCopyPublicKey,
onMarkAllRead,
onUnblockContact,
onInviteContacts,
onLeaveGroup,
onChangeNickname,
theme
} = props;
const isGroup = type === 'group';
const [ modal, setModal ] = useState<any>(null);
return (
<>
{ modal ? modal : null}
<Menu id={triggerId} animation={animation.fade}>
{getBlockMenuItem(
isMe,
type === ConversationTypeEnum.PRIVATE,
isBlocked,
onBlockContact,
onUnblockContact,
window.i18n
)}
{getCopyMenuItem(isPublic, isGroup, onCopyPublicKey, window.i18n)}
{getMarkAllReadMenuItem(onMarkAllRead, window.i18n)}
{getChangeNicknameMenuItem(isMe, onChangeNickname, isGroup, window.i18n, id, setModal)}
{getClearNicknameMenuItem(isMe, hasNickname, onClearNickname, isGroup, window.i18n)}
{getDeleteMessagesMenuItem(isPublic, onDeleteMessages, window.i18n, id)}
{getInviteContactMenuItem(isGroup, isPublic, onInviteContacts, window.i18n)}
{getDeleteContactMenuItem(
isMe,
isGroup,
isPublic,
left,
isKickedFromGroup,
onDeleteContact,
window.i18n,
id
)}
{getLeaveGroupMenuItem(isKickedFromGroup, left, isGroup, isPublic, onLeaveGroup, window.i18n, id, setModal, theme)}
</Menu>
</>
);
};