From b67d52382d8d1fd581b80ad8ef3810b91a67255f Mon Sep 17 00:00:00 2001 From: William Grant Date: Wed, 14 Jun 2023 11:08:59 +1000 Subject: [PATCH] feat: updated right panel leave button added community leave failed text, handle leaving conversation with no name --- ts/components/conversation/SessionRightPanel.tsx | 15 +++++---------- .../conversation-list-item/InteractionItem.tsx | 4 ++-- ts/interactions/conversationInteractions.ts | 15 +++++++++------ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/ts/components/conversation/SessionRightPanel.tsx b/ts/components/conversation/SessionRightPanel.tsx index a6b3d8ff2..8076f5c4d 100644 --- a/ts/components/conversation/SessionRightPanel.tsx +++ b/ts/components/conversation/SessionRightPanel.tsx @@ -7,7 +7,6 @@ import useInterval from 'react-use/lib/useInterval'; import styled from 'styled-components'; import { Data } from '../../data/data'; import { - deleteAllMessagesByConvoIdWithConfirmation, setDisappearingMessagesByConvoId, showAddModeratorsByConvoId, showInviteContactByConvoId, @@ -209,7 +208,6 @@ export const SessionRightPanelWithDetails = () => { const [media, setMedia] = useState>([]); const selectedConvoKey = useSelectedConversationKey(); - // TODO we need to test what happens to the localisad string without a group name const selectedUsername = useConversationUsername(selectedConvoKey) || selectedConvoKey; const isShowing = useSelector(isRightPanelShowing); const subscriberCount = useSelectedSubscriberCount(); @@ -264,7 +262,7 @@ export const SessionRightPanelWithDetails = () => { const commonNoShow = isKickedFromGroup || left || isBlocked || !isActive; const hasDisappearingMessages = !isPublic && !commonNoShow; const leaveGroupString = isPublic - ? window.i18n('leaveGroup') + ? window.i18n('leaveCommunity') : isKickedFromGroup ? window.i18n('youGotKickedFromGroup') : left @@ -287,13 +285,10 @@ export const SessionRightPanelWithDetails = () => { const showAddRemoveModeratorsButton = weAreAdmin && !commonNoShow && isPublic; const showUpdateGroupMembersButton = !isPublic && isGroup && !commonNoShow; - const deleteConvoAction = isPublic - ? () => { - deleteAllMessagesByConvoIdWithConfirmation(selectedConvoKey); // TODOLATER this does not delete the public group and showLeaveGroupByConvoId is not only working for closed groups - } - : () => { - showLeaveGroupByConvoId(selectedConvoKey); - }; + const deleteConvoAction = () => { + showLeaveGroupByConvoId(selectedConvoKey, selectedUsername); + }; + return (
diff --git a/ts/components/leftpane/conversation-list-item/InteractionItem.tsx b/ts/components/leftpane/conversation-list-item/InteractionItem.tsx index d11d04037..246363bc0 100644 --- a/ts/components/leftpane/conversation-list-item/InteractionItem.tsx +++ b/ts/components/leftpane/conversation-list-item/InteractionItem.tsx @@ -38,7 +38,7 @@ export const InteractionItem = (props: InteractionItemProps) => { window.log.debug( `WIP: storedLastMessageId "${storedLastMessageId}" convo.get('lastMessageId') "${convo.get( 'lastMessageId' - )}' lastMessageId ${JSON.stringify(lastMessage)}` + )}' storedLastMessageText ${storedLastMessageText} text ${text}` ); if (storedLastMessageId !== convo.get('lastMessageId')) { @@ -67,7 +67,7 @@ export const InteractionItem = (props: InteractionItemProps) => { break; case ConversationInteractionType.Leave: failText = isCommunity - ? '' + ? window.i18n('leaveCommunityFailed') : isGroup ? window.i18n('leaveGroupFailed') : window.i18n('deleteConversationFailed'); diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index c08151df7..a42e702c9 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -242,7 +242,10 @@ export async function showUpdateGroupMembersByConvoId(conversationId: string) { 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 isMe = conversation.isMe(); @@ -284,7 +287,7 @@ export function showLeavePrivateConversationbyConvoId(conversationId: string, na title: isMe ? window.i18n('hideConversation') : window.i18n('deleteConversation'), message: isMe ? window.i18n('hideNoteToSelfConfirmation') - : window.i18n('deleteConversationConfirmation', [name]), + : window.i18n('deleteConversationConfirmation', name ? [name] : ['']), onClickOk, okText: isMe ? window.i18n('hide') : window.i18n('delete'), 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); if (!conversation.isGroup()) { @@ -349,7 +352,7 @@ export function showLeaveGroupByConvoId(conversationId: string, name?: string) { window?.inboxStore?.dispatch( updateConfirmModal({ title: window.i18n('leaveGroup'), - message: window.i18n('leaveGroupConrirmationOnlyAdminLegacy', name ? [name] : undefined), + message: window.i18n('leaveGroupConrirmationOnlyAdminLegacy', name ? [name] : ['']), onClickOk, okText: window.i18n('leave'), okTheme: SessionButtonColor.Danger, @@ -363,7 +366,7 @@ export function showLeaveGroupByConvoId(conversationId: string, name?: string) { // window?.inboxStore?.dispatch( // updateConfirmModal({ // title: window.i18n('leaveGroup'), - // message: window.i18n('leaveGroupConfirmationOnlyAdmin', name ? [name] : undefined), + // message: window.i18n('leaveGroupConfirmationOnlyAdmin', name ? [name] : ['']), // messageSub: window.i18n('leaveGroupConfirmationOnlyAdminWarning'), // onClickOk: onClickOkLastAdmin, // okText: window.i18n('addModerator'), @@ -381,7 +384,7 @@ export function showLeaveGroupByConvoId(conversationId: string, name?: string) { window?.inboxStore?.dispatch( updateConfirmModal({ title: isPublic ? window.i18n('leaveCommunity') : window.i18n('leaveGroup'), - message: window.i18n('leaveGroupConfirmation', name ? [name] : undefined), + message: window.i18n('leaveGroupConfirmation', name ? [name] : ['']), onClickOk, okText: window.i18n('leave'), okTheme: SessionButtonColor.Danger,