feat: finished note to self and 1o1 conversation leaving and hiding

pull/2789/head
William Grant 2 years ago
parent 1df57140ff
commit 38c6cb0d7d

@ -94,6 +94,7 @@
"continue": "Continue", "continue": "Continue",
"error": "Error", "error": "Error",
"delete": "Delete", "delete": "Delete",
"hide": "Hide",
"messageDeletionForbidden": "You dont have permission to delete others messages", "messageDeletionForbidden": "You dont have permission to delete others messages",
"deleteJustForMe": "Delete just for me", "deleteJustForMe": "Delete just for me",
"deleteForEveryone": "Delete for everyone", "deleteForEveryone": "Delete for everyone",
@ -101,9 +102,13 @@
"deleteMessageQuestion": "Delete this message?", "deleteMessageQuestion": "Delete this message?",
"deleteMessages": "Delete Messages", "deleteMessages": "Delete Messages",
"deleteMessagesConfirmation": "Permanently delete the messages in this conversation?", "deleteMessagesConfirmation": "Permanently delete the messages in this conversation?",
"hideConversation": "Hide Conversation",
"hideNoteToSelfConfirmation": "Are you sure you want to hide your <b>Note to Self</b> conversation?",
"hideConversationFailed": "Failed to hide the Conversation!",
"deleteConversation": "Delete Conversation", "deleteConversation": "Delete Conversation",
"deleteConversationConfirmation": "Are you sure you want to delete your conversation with <b>$name$</b>?", "deleteConversationConfirmation": "Are you sure you want to delete your conversation with <b>$name$</b>?",
"deleteConversationFailed": "Failed to leave the Conversation!", "deleteConversationFailed": "Failed to leave the Conversation!",
"hiding": "Hiding...",
"leaving": "Leaving...", "leaving": "Leaving...",
"deleted": "$count$ deleted", "deleted": "$count$ deleted",
"messageDeletedPlaceholder": "This message has been deleted", "messageDeletedPlaceholder": "This message has been deleted",

@ -54,14 +54,23 @@ export const InteractionItem = (props: InteractionItemProps) => {
} }
let text = storedLastMessageText || ''; let text = storedLastMessageText || '';
let failText = '';
switch (interactionType) { switch (interactionType) {
case ConversationInteractionType.Hide:
failText = window.i18n('hideConversationFailed');
text =
interactionStatus === ConversationInteractionStatus.Error
? failText
: interactionStatus === ConversationInteractionStatus.Loading
? window.i18n('hiding')
: text;
break;
case ConversationInteractionType.Leave: case ConversationInteractionType.Leave:
const failText = isCommunity failText = isCommunity
? '' ? ''
: isGroup : isGroup
? window.i18n('leaveGroupFailed') ? window.i18n('leaveGroupFailed')
: window.i18n('deleteConversationFailed'); : window.i18n('deleteConversationFailed');
text = text =
interactionStatus === ConversationInteractionStatus.Error interactionStatus === ConversationInteractionStatus.Error
? failText ? failText

@ -452,6 +452,7 @@ export const DeletePrivateConversationMenuItem = () => {
const username = useConversationUsername(convoId) || convoId; const username = useConversationUsername(convoId) || convoId;
const isRequest = useIsIncomingRequest(convoId); const isRequest = useIsIncomingRequest(convoId);
const isPrivate = useIsPrivate(convoId); const isPrivate = useIsPrivate(convoId);
const isMe = useIsMe(convoId);
if (!convoId || !isPrivate || isRequest) { if (!convoId || !isPrivate || isRequest) {
return null; return null;
@ -463,7 +464,7 @@ export const DeletePrivateConversationMenuItem = () => {
showLeavePrivateConversationbyConvoId(convoId, username); showLeavePrivateConversationbyConvoId(convoId, username);
}} }}
> >
{window.i18n('deleteConversation')} {isMe ? window.i18n('hideConversation') : window.i18n('deleteConversation')}
</Item> </Item>
); );
}; };

@ -51,6 +51,7 @@ export enum ConversationInteractionStatus {
} }
export enum ConversationInteractionType { export enum ConversationInteractionType {
Hide = 'hide',
Leave = 'leave', Leave = 'leave',
} }
@ -243,6 +244,7 @@ export async function showUpdateGroupMembersByConvoId(conversationId: string) {
export function showLeavePrivateConversationbyConvoId(conversationId: string, name: string) { export function showLeavePrivateConversationbyConvoId(conversationId: string, name: string) {
const conversation = getConversationController().get(conversationId); const conversation = getConversationController().get(conversationId);
const isMe = conversation.isMe();
if (!conversation.isPrivate()) { if (!conversation.isPrivate()) {
throw new Error('showLeavePrivateConversationDialog() called with a non private convo.'); throw new Error('showLeavePrivateConversationDialog() called with a non private convo.');
@ -256,12 +258,12 @@ export function showLeavePrivateConversationbyConvoId(conversationId: string, na
try { try {
await updateConversationInteractionState({ await updateConversationInteractionState({
conversationId, conversationId,
type: ConversationInteractionType.Leave, type: isMe ? ConversationInteractionType.Hide : ConversationInteractionType.Leave,
status: ConversationInteractionStatus.Start, status: ConversationInteractionStatus.Start,
}); });
await getConversationController().delete1o1(conversationId, { await getConversationController().delete1o1(conversationId, {
fromSyncMessage: false, fromSyncMessage: false,
justHidePrivate: true, justHidePrivate: isMe,
}); });
onClickClose(); onClickClose();
@ -271,7 +273,7 @@ export function showLeavePrivateConversationbyConvoId(conversationId: string, na
window.log.warn(`showLeavePrivateConversationbyConvoId error: ${err}`); window.log.warn(`showLeavePrivateConversationbyConvoId error: ${err}`);
await updateConversationInteractionState({ await updateConversationInteractionState({
conversationId, conversationId,
type: ConversationInteractionType.Leave, type: isMe ? ConversationInteractionType.Hide : ConversationInteractionType.Leave,
status: ConversationInteractionStatus.Error, status: ConversationInteractionStatus.Error,
}); });
} }
@ -279,10 +281,12 @@ export function showLeavePrivateConversationbyConvoId(conversationId: string, na
window?.inboxStore?.dispatch( window?.inboxStore?.dispatch(
updateConfirmModal({ updateConfirmModal({
title: window.i18n('deleteConversation'), title: isMe ? window.i18n('hideConversation') : window.i18n('deleteConversation'),
message: window.i18n('deleteConversationConfirmation', [name]), message: isMe
? window.i18n('hideNoteToSelfConfirmation')
: window.i18n('deleteConversationConfirmation', [name]),
onClickOk, onClickOk,
okText: window.i18n('delete'), okText: isMe ? window.i18n('hide') : window.i18n('delete'),
okTheme: SessionButtonColor.Danger, okTheme: SessionButtonColor.Danger,
onClickClose, onClickClose,
conversationId, conversationId,

@ -94,6 +94,7 @@ export type LocalizerKeys =
| 'continue' | 'continue'
| 'error' | 'error'
| 'delete' | 'delete'
| 'hide'
| 'messageDeletionForbidden' | 'messageDeletionForbidden'
| 'deleteJustForMe' | 'deleteJustForMe'
| 'deleteForEveryone' | 'deleteForEveryone'
@ -101,9 +102,13 @@ export type LocalizerKeys =
| 'deleteMessageQuestion' | 'deleteMessageQuestion'
| 'deleteMessages' | 'deleteMessages'
| 'deleteMessagesConfirmation' | 'deleteMessagesConfirmation'
| 'hideConversation'
| 'hideNoteToSelfConfirmation'
| 'hideConversationFailed'
| 'deleteConversation' | 'deleteConversation'
| 'deleteConversationConfirmation' | 'deleteConversationConfirmation'
| 'deleteConversationFailed' | 'deleteConversationFailed'
| 'hiding'
| 'leaving' | 'leaving'
| 'deleted' | 'deleted'
| 'messageDeletedPlaceholder' | 'messageDeletedPlaceholder'

Loading…
Cancel
Save