From 2448b710b4af11dd9f1733dc054344e331406d57 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Tue, 14 Sep 2021 11:58:20 +0200 Subject: [PATCH] fix(@desktop/chat): Fix for Leave chat is shown instead of Delete confirmation when deleting community channel fixes #3365 --- ui/app/AppLayouts/Chat/ChatColumn.qml | 2 +- .../Chat/components/ChatContextMenu.qml | 29 +++++++++++-------- ui/shared/ConfirmationDialog.qml | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ui/app/AppLayouts/Chat/ChatColumn.qml b/ui/app/AppLayouts/Chat/ChatColumn.qml index 7c7c97f05a..05fa0193bf 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn.qml @@ -218,7 +218,7 @@ Item { onNotificationButtonClicked: activityCenter.open() popupMenu: ChatContextMenu { - openHandler: { + onOpened: { chatItem = chatsModel.channelView.activeChannel } } diff --git a/ui/app/AppLayouts/Chat/components/ChatContextMenu.qml b/ui/app/AppLayouts/Chat/components/ChatContextMenu.qml index 8834762f0e..13586ff680 100644 --- a/ui/app/AppLayouts/Chat/components/ChatContextMenu.qml +++ b/ui/app/AppLayouts/Chat/components/ChatContextMenu.qml @@ -136,16 +136,7 @@ StatusPopupMenu { type: StatusMenuItem.Type.Danger onTriggered: { - let label = chatItem && chatItem.chatType === Constants.chatTypeOneToOne ? - //% "Delete chat" - qsTrId("delete-chat") : - //% "Leave chat" - qsTrId("leave-chat") - openPopup(deleteChatConfirmationDialogComponent, { - title: label, - confirmButtonLabel: label, - chatId: chatItem.id - }) + openPopup(deleteChatConfirmationDialogComponent) } enabled: !communityActive || chatsModel.communities.activeCommunity.admin @@ -166,13 +157,27 @@ StatusPopupMenu { Component { id: deleteChatConfirmationDialogComponent ConfirmationDialog { - property string chatId + property string chatId: chatItem.id btnType: "warn" - confirmationText: communityActive ? qsTr("Are you sure you want to delete this channel?") : + header.title: communityActive ? qsTr("Delete #%1").arg(chatItem.name) : + chatItem && chatItem.chatType === Constants.chatTypeOneToOne ? + //% "Delete chat" + qsTrId("delete-chat") : + //% "Leave chat" + qsTrId("leave-chat") + confirmButtonLabel: communityActive ? qsTr("Delete") : header.title + confirmationText: communityActive ? qsTr("Are you sure you want to delete #%1 channel?").arg(chatItem.name) : + chatItem && chatItem.chatType === Constants.chatTypeOneToOne ? + qsTr("Are you sure you want to delete this chat?"): qsTr("Are you sure you want to leave this chat?") + showCancelButton: communityActive + onClosed: { destroy() } + onCancelButtonClicked: { + close() + } onConfirmButtonClicked: { if (communityActive) { chatsModel.communities.deleteCommunityChat(chatsModel.communities.activeCommunity.id, chatId) diff --git a/ui/shared/ConfirmationDialog.qml b/ui/shared/ConfirmationDialog.qml index e605838722..a908870742 100644 --- a/ui/shared/ConfirmationDialog.qml +++ b/ui/shared/ConfirmationDialog.qml @@ -23,7 +23,7 @@ StatusModal { property alias checkbox: checkbox - header.title: qsTr("Confirm you action") + header.title: qsTr("Confirm your action") focus: visible signal confirmButtonClicked()