Delete chat: Allow to leave; Seen By: Better view (#1749)

This commit is contained in:
Alexander Zinchuk 2022-03-04 16:22:24 +03:00
parent 2ce560cf1a
commit 139bc84174
3 changed files with 28 additions and 5 deletions

View File

@ -108,6 +108,15 @@ const DeleteChatModal: FC<OwnProps & StateProps> = ({
deleteChannel,
]);
const handleLeaveChat = useCallback(() => {
if (isChannel || isSuperGroup) {
leaveChannel({ chatId: chat.id });
onClose();
} else {
handleDeleteChat();
}
}, [chat.id, handleDeleteChat, isChannel, isSuperGroup, leaveChannel, onClose]);
function renderHeader() {
return (
<div className="modal-header" dir={lang.isRtl ? 'rtl' : undefined}>
@ -183,7 +192,17 @@ const DeleteChatModal: FC<OwnProps & StateProps> = ({
{contactName ? renderText(lang('ChatList.DeleteForEveryone', contactName)) : lang('DeleteForAll')}
</Button>
)}
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteChat}>
{!isPrivateChat && chat.isCreator && (
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteChat}>
{lang('DeleteForAll')}
</Button>
)}
<Button
color="danger"
className="confirm-dialog-button"
isText
onClick={isPrivateChat ? handleDeleteChat : handleLeaveChat}
>
{lang(renderActionText())}
</Button>
<Button className="confirm-dialog-button" isText onClick={onClose}>{lang('Cancel')}</Button>

View File

@ -46,7 +46,7 @@ const SeenByModal: FC<OwnProps & StateProps> = ({
isOpen={isOpen}
onClose={closeSeenByModal}
className="narrow"
title="Which users read the message"
title={`Seen by ${memberIds?.length} users`}
>
<div dir={lang.isRtl ? 'rtl' : undefined}>
{renderingMemberIds && renderingMemberIds.map((userId) => (

View File

@ -7,6 +7,7 @@ import { IAnchorPosition } from '../../../types';
import { getMessageCopyOptions } from './helpers/copyOptions';
import { disableScrolling, enableScrolling } from '../../../util/scrollLock';
import { getUserFullName } from '../../../modules/helpers';
import useContextMenuPosition from '../../../hooks/useContextMenuPosition';
import useLang from '../../../hooks/useLang';
import buildClassName from '../../../util/buildClassName';
@ -259,9 +260,12 @@ const MessageContextMenu: FC<OwnProps> = ({
? lang('Chat.OutgoingContextMixedReactionCount', [message.reactors.count, message.seenByUserIds.length])
: lang('Chat.ContextReactionCount', message.reactors.count, 'i')
) : (
message.seenByUserIds?.length
? lang('Conversation.ContextMenuSeen', message.seenByUserIds.length, 'i')
: lang('Conversation.ContextMenuNoViews')
message.seenByUserIds?.length === 1 && seenByRecentUsers
? getUserFullName(seenByRecentUsers[0])
: (message.seenByUserIds?.length
? lang('Conversation.ContextMenuSeen', message.seenByUserIds.length, 'i')
: lang('Conversation.ContextMenuNoViews')
)
)}
<div className="avatars">
{seenByRecentUsers?.map((user) => (