feat: updated right panel leave button

added community leave failed text, handle leaving conversation with no name
pull/2789/head
William Grant 2 years ago
parent 40e3a8fa72
commit b67d52382d

@ -7,7 +7,6 @@ import useInterval from 'react-use/lib/useInterval';
import styled from 'styled-components'; import styled from 'styled-components';
import { Data } from '../../data/data'; import { Data } from '../../data/data';
import { import {
deleteAllMessagesByConvoIdWithConfirmation,
setDisappearingMessagesByConvoId, setDisappearingMessagesByConvoId,
showAddModeratorsByConvoId, showAddModeratorsByConvoId,
showInviteContactByConvoId, showInviteContactByConvoId,
@ -209,7 +208,6 @@ export const SessionRightPanelWithDetails = () => {
const [media, setMedia] = useState<Array<MediaItemType>>([]); const [media, setMedia] = useState<Array<MediaItemType>>([]);
const selectedConvoKey = useSelectedConversationKey(); const selectedConvoKey = useSelectedConversationKey();
// TODO we need to test what happens to the localisad string without a group name
const selectedUsername = useConversationUsername(selectedConvoKey) || selectedConvoKey; const selectedUsername = useConversationUsername(selectedConvoKey) || selectedConvoKey;
const isShowing = useSelector(isRightPanelShowing); const isShowing = useSelector(isRightPanelShowing);
const subscriberCount = useSelectedSubscriberCount(); const subscriberCount = useSelectedSubscriberCount();
@ -264,7 +262,7 @@ export const SessionRightPanelWithDetails = () => {
const commonNoShow = isKickedFromGroup || left || isBlocked || !isActive; const commonNoShow = isKickedFromGroup || left || isBlocked || !isActive;
const hasDisappearingMessages = !isPublic && !commonNoShow; const hasDisappearingMessages = !isPublic && !commonNoShow;
const leaveGroupString = isPublic const leaveGroupString = isPublic
? window.i18n('leaveGroup') ? window.i18n('leaveCommunity')
: isKickedFromGroup : isKickedFromGroup
? window.i18n('youGotKickedFromGroup') ? window.i18n('youGotKickedFromGroup')
: left : left
@ -287,13 +285,10 @@ export const SessionRightPanelWithDetails = () => {
const showAddRemoveModeratorsButton = weAreAdmin && !commonNoShow && isPublic; const showAddRemoveModeratorsButton = weAreAdmin && !commonNoShow && isPublic;
const showUpdateGroupMembersButton = !isPublic && isGroup && !commonNoShow; const showUpdateGroupMembersButton = !isPublic && isGroup && !commonNoShow;
const deleteConvoAction = isPublic const deleteConvoAction = () => {
? () => { showLeaveGroupByConvoId(selectedConvoKey, selectedUsername);
deleteAllMessagesByConvoIdWithConfirmation(selectedConvoKey); // TODOLATER this does not delete the public group and showLeaveGroupByConvoId is not only working for closed groups };
}
: () => {
showLeaveGroupByConvoId(selectedConvoKey);
};
return ( return (
<div className="group-settings"> <div className="group-settings">
<HeaderItem /> <HeaderItem />

@ -38,7 +38,7 @@ export const InteractionItem = (props: InteractionItemProps) => {
window.log.debug( window.log.debug(
`WIP: storedLastMessageId "${storedLastMessageId}" convo.get('lastMessageId') "${convo.get( `WIP: storedLastMessageId "${storedLastMessageId}" convo.get('lastMessageId') "${convo.get(
'lastMessageId' 'lastMessageId'
)}' lastMessageId ${JSON.stringify(lastMessage)}` )}' storedLastMessageText ${storedLastMessageText} text ${text}`
); );
if (storedLastMessageId !== convo.get('lastMessageId')) { if (storedLastMessageId !== convo.get('lastMessageId')) {
@ -67,7 +67,7 @@ export const InteractionItem = (props: InteractionItemProps) => {
break; break;
case ConversationInteractionType.Leave: case ConversationInteractionType.Leave:
failText = isCommunity failText = isCommunity
? '' ? window.i18n('leaveCommunityFailed')
: isGroup : isGroup
? window.i18n('leaveGroupFailed') ? window.i18n('leaveGroupFailed')
: window.i18n('deleteConversationFailed'); : window.i18n('deleteConversationFailed');

@ -242,7 +242,10 @@ export async function showUpdateGroupMembersByConvoId(conversationId: string) {
window.inboxStore?.dispatch(updateGroupMembersModal({ conversationId })); window.inboxStore?.dispatch(updateGroupMembersModal({ conversationId }));
} }
export function showLeavePrivateConversationbyConvoId(conversationId: string, name: string) { export function showLeavePrivateConversationbyConvoId(
conversationId: string,
name: string | undefined
) {
const conversation = getConversationController().get(conversationId); const conversation = getConversationController().get(conversationId);
const isMe = conversation.isMe(); const isMe = conversation.isMe();
@ -284,7 +287,7 @@ export function showLeavePrivateConversationbyConvoId(conversationId: string, na
title: isMe ? window.i18n('hideConversation') : window.i18n('deleteConversation'), title: isMe ? window.i18n('hideConversation') : window.i18n('deleteConversation'),
message: isMe message: isMe
? window.i18n('hideNoteToSelfConfirmation') ? window.i18n('hideNoteToSelfConfirmation')
: window.i18n('deleteConversationConfirmation', [name]), : window.i18n('deleteConversationConfirmation', name ? [name] : ['']),
onClickOk, onClickOk,
okText: isMe ? window.i18n('hide') : window.i18n('delete'), okText: isMe ? window.i18n('hide') : window.i18n('delete'),
okTheme: SessionButtonColor.Danger, okTheme: SessionButtonColor.Danger,
@ -294,7 +297,7 @@ export function showLeavePrivateConversationbyConvoId(conversationId: string, na
); );
} }
export function showLeaveGroupByConvoId(conversationId: string, name?: string) { export function showLeaveGroupByConvoId(conversationId: string, name: string | undefined) {
const conversation = getConversationController().get(conversationId); const conversation = getConversationController().get(conversationId);
if (!conversation.isGroup()) { if (!conversation.isGroup()) {
@ -349,7 +352,7 @@ export function showLeaveGroupByConvoId(conversationId: string, name?: string) {
window?.inboxStore?.dispatch( window?.inboxStore?.dispatch(
updateConfirmModal({ updateConfirmModal({
title: window.i18n('leaveGroup'), title: window.i18n('leaveGroup'),
message: window.i18n('leaveGroupConrirmationOnlyAdminLegacy', name ? [name] : undefined), message: window.i18n('leaveGroupConrirmationOnlyAdminLegacy', name ? [name] : ['']),
onClickOk, onClickOk,
okText: window.i18n('leave'), okText: window.i18n('leave'),
okTheme: SessionButtonColor.Danger, okTheme: SessionButtonColor.Danger,
@ -363,7 +366,7 @@ export function showLeaveGroupByConvoId(conversationId: string, name?: string) {
// window?.inboxStore?.dispatch( // window?.inboxStore?.dispatch(
// updateConfirmModal({ // updateConfirmModal({
// title: window.i18n('leaveGroup'), // title: window.i18n('leaveGroup'),
// message: window.i18n('leaveGroupConfirmationOnlyAdmin', name ? [name] : undefined), // message: window.i18n('leaveGroupConfirmationOnlyAdmin', name ? [name] : ['']),
// messageSub: window.i18n('leaveGroupConfirmationOnlyAdminWarning'), // messageSub: window.i18n('leaveGroupConfirmationOnlyAdminWarning'),
// onClickOk: onClickOkLastAdmin, // onClickOk: onClickOkLastAdmin,
// okText: window.i18n('addModerator'), // okText: window.i18n('addModerator'),
@ -381,7 +384,7 @@ export function showLeaveGroupByConvoId(conversationId: string, name?: string) {
window?.inboxStore?.dispatch( window?.inboxStore?.dispatch(
updateConfirmModal({ updateConfirmModal({
title: isPublic ? window.i18n('leaveCommunity') : window.i18n('leaveGroup'), title: isPublic ? window.i18n('leaveCommunity') : window.i18n('leaveGroup'),
message: window.i18n('leaveGroupConfirmation', name ? [name] : undefined), message: window.i18n('leaveGroupConfirmation', name ? [name] : ['']),
onClickOk, onClickOk,
okText: window.i18n('leave'), okText: window.i18n('leave'),
okTheme: SessionButtonColor.Danger, okTheme: SessionButtonColor.Danger,

Loading…
Cancel
Save