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

@ -54,14 +54,23 @@ export const InteractionItem = (props: InteractionItemProps) => {
}
let text = storedLastMessageText || '';
let failText = '';
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:
const failText = isCommunity
failText = isCommunity
? ''
: isGroup
? window.i18n('leaveGroupFailed')
: window.i18n('deleteConversationFailed');
text =
interactionStatus === ConversationInteractionStatus.Error
? failText

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

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

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

Loading…
Cancel
Save