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, isPinned,
isMuted, isMuted,
handleDelete: openDeleteModal, handleDelete: openDeleteModal,
}); }, true);
const handleClick = () => { const handleClick = () => {
onClick(chatId); onClick(chatId);

View File

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