From f07d4f1eb7f012e20e84ed4a0295c7491417a9d0 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 19 Nov 2021 17:26:13 +0300 Subject: [PATCH] Chat: Hide "Archive" action in folders --- src/hooks/useChatContextActions.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/hooks/useChatContextActions.ts b/src/hooks/useChatContextActions.ts index ca48ddb4..65930830 100644 --- a/src/hooks/useChatContextActions.ts +++ b/src/hooks/useChatContextActions.ts @@ -6,6 +6,7 @@ import { ApiChat, ApiUser } from '../api/types'; import { isChatArchived, getCanDeleteChat, isUserId, isChatChannel, } from '../modules/helpers'; +import { compact } from '../util/iteratees'; import useLang from './useLang'; export default ({ @@ -27,6 +28,8 @@ export default ({ }, isInSearch = false) => { const lang = useLang(); + const { isSelf } = privateChatUser || {}; + return useMemo(() => { if (!chat) { return undefined; @@ -88,17 +91,15 @@ export default ({ handler: handleDelete, }; - return [ + const isInFolder = folderId !== undefined; + + return compact([ actionAddToFolder, actionUnreadMark, actionPin, - ...(!privateChatUser?.isSelf ? [ - actionMute, - actionArchive, - ] : []), + !isSelf && actionMute, + !isSelf && !isInFolder && actionArchive, actionDelete, - ]; - }, [ - chat, isPinned, lang, isInSearch, isMuted, handleDelete, handleChatFolderChange, privateChatUser?.isSelf, folderId, - ]); + ]); + }, [chat, lang, handleChatFolderChange, isPinned, isInSearch, isMuted, handleDelete, folderId, isSelf]); };