Left Search: Do not show unneeded context menu items

This commit is contained in:
Alexander Zinchuk 2021-08-27 21:08:42 +03:00
parent d76c948b06
commit 44adc496b6
2 changed files with 18 additions and 19 deletions

View File

@ -48,7 +48,7 @@ const LeftSearchResultChat: FC<OwnProps & StateProps> = ({
isPinned,
isMuted,
handleDelete: openDeleteModal,
});
}, true);
const handleClick = () => {
onClick(chatId);

View File

@ -22,9 +22,14 @@ export default ({
folderId?: number;
isPinned?: boolean;
isMuted?: boolean;
}) => {
}, isInSearch = false) => {
const lang = useLang();
return useMemo(() => {
if (!chat) {
return undefined;
}
const {
toggleChatPinned,
updateChatMutedState,
@ -32,17 +37,6 @@ export default ({
toggleChatUnread,
} = getDispatch();
return useMemo(() => {
if (!chat) {
return undefined;
}
const isChatWithSelf = privateChatUser?.isSelf;
const actionUnreadMark = chat.unreadCount || chat.hasUnreadMark
? { title: lang('MarkAsRead'), icon: 'readchats', handler: () => toggleChatUnread({ id: chat.id }) }
: { title: lang('MarkAsUnread'), icon: 'unread', handler: () => toggleChatUnread({ id: chat.id }) };
const actionPin = isPinned
? {
title: lang('UnpinFromTop'),
@ -51,6 +45,14 @@ export default ({
}
: { title: lang('PinToTop'), icon: 'pin', handler: () => toggleChatPinned({ id: chat.id, folderId }) };
if (isInSearch) {
return [actionPin];
}
const actionUnreadMark = chat.unreadCount || chat.hasUnreadMark
? { title: lang('MarkAsRead'), icon: 'readchats', handler: () => toggleChatUnread({ id: chat.id }) }
: { title: lang('MarkAsUnread'), icon: 'unread', handler: () => toggleChatUnread({ id: chat.id }) };
const actionMute = isMuted
? {
title: lang('ChatList.Unmute'),
@ -81,14 +83,11 @@ export default ({
return [
actionUnreadMark,
actionPin,
...(!isChatWithSelf ? [
...(!privateChatUser?.isSelf ? [
actionMute,
actionArchive,
] : []),
actionDelete,
];
}, [
chat, privateChatUser, lang, isPinned, handleDelete, toggleChatUnread, toggleChatPinned, folderId,
updateChatMutedState, toggleChatArchived, isMuted,
]);
}, [chat, isPinned, lang, isInSearch, isMuted, handleDelete, privateChatUser?.isSelf, folderId]);
};