Chat: Hide "Archive" action in folders

This commit is contained in:
Alexander Zinchuk 2021-11-19 17:26:13 +03:00
parent d5fafe8529
commit f07d4f1eb7

View File

@ -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]);
};