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 { import {
isChatArchived, getCanDeleteChat, isUserId, isChatChannel, isChatArchived, getCanDeleteChat, isUserId, isChatChannel,
} from '../modules/helpers'; } from '../modules/helpers';
import { compact } from '../util/iteratees';
import useLang from './useLang'; import useLang from './useLang';
export default ({ export default ({
@ -27,6 +28,8 @@ export default ({
}, isInSearch = false) => { }, isInSearch = false) => {
const lang = useLang(); const lang = useLang();
const { isSelf } = privateChatUser || {};
return useMemo(() => { return useMemo(() => {
if (!chat) { if (!chat) {
return undefined; return undefined;
@ -88,17 +91,15 @@ export default ({
handler: handleDelete, handler: handleDelete,
}; };
return [ const isInFolder = folderId !== undefined;
return compact([
actionAddToFolder, actionAddToFolder,
actionUnreadMark, actionUnreadMark,
actionPin, actionPin,
...(!privateChatUser?.isSelf ? [ !isSelf && actionMute,
actionMute, !isSelf && !isInFolder && actionArchive,
actionArchive,
] : []),
actionDelete, actionDelete,
]; ]);
}, [ }, [chat, lang, handleChatFolderChange, isPinned, isInSearch, isMuted, handleDelete, folderId, isSelf]);
chat, isPinned, lang, isInSearch, isMuted, handleDelete, handleChatFolderChange, privateChatUser?.isSelf, folderId,
]);
}; };