feat(Chat): Disable chat actions for non-contacts

This commit is contained in:
MishkaRogachev 2023-03-20 16:59:53 +07:00 committed by Jonathan Rainville
parent ad4838e4f8
commit 1f54d96f5f
7 changed files with 67 additions and 31 deletions

View File

@ -40,7 +40,6 @@ Control {
property bool editMode: false
property bool isAReply: false
property bool isEdited: false
property bool isChatBlocked: false
property bool hasMention: false
property bool isPinned: false
@ -56,6 +55,7 @@ Control {
property bool isActiveMessage: false
property bool disableHover: false
property bool hideQuickActions: false
property bool disableEmojis: false
property color overrideBackgroundColor: "transparent"
property bool overrideBackground: false
property bool profileClickable: true
@ -395,7 +395,7 @@ Control {
visible: active
sourceComponent: StatusMessageEmojiReactions {
id: emojiReactionsPanel
enabled: !root.disableEmojis
emojiReactionsModel: root.reactionsModel
icons: root.reactionIcons

View File

@ -1,6 +1,6 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtGraphicalEffects 1.15
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
@ -57,6 +57,16 @@ Menu {
signal menuItemClicked(int menuIndex)
function checkIfEmpty() {
for (let i = 0; i < root.contentItem.count; ++i) {
const menuItem = root.contentItem.itemAtIndex(i)
if (menuItem.text !== undefined && menuItem.enabled) { // skip menu separators
return false
}
}
return true
}
dim: false
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
topPadding: 8

View File

@ -86,6 +86,8 @@ ColumnLayout {
id: contextmenu
store: root.rootStore
reactionModel: root.rootStore.emojiReactionsModel
disabledForChat: chatType === Constants.chatType.oneToOne && !root.isUserAdded
onPinMessage: {
messageStore.pinMessage(messageId)
}
@ -150,6 +152,7 @@ ColumnLayout {
isChatBlocked: root.isBlocked
channelEmoji: !chatContentModule ? "" : (chatContentModule.chatDetails.emoji || "")
isActiveChannel: root.isActiveChannel
isUserAdded: root.isUserAdded
onShowReplyArea: {
let obj = messageStore.getMessageByIdAsJson(messageId)
if (!obj) {

View File

@ -36,6 +36,7 @@ Item {
property alias chatLogView: chatLogView
property bool isChatBlocked: false
property bool isActiveChannel: false
property bool isUserAdded: true
property var messageContextMenu
@ -225,7 +226,7 @@ Item {
chatLogView: ListView.view
isActiveChannel: root.isActiveChannel
isChatBlocked: root.isChatBlocked
isChatBlocked: root.isChatBlocked || !root.isUserAdded
messageContextMenu: root.messageContextMenu
messageId: model.id

View File

@ -1337,7 +1337,12 @@ Rectangle {
}
}
onEnabledChanged: if (!enabled) text = ""
onEnabledChanged: {
if (!enabled) {
text = ""
control.hideExtendedArea()
}
}
cursorDelegate: Rectangle {
color: Theme.palette.primaryColor1

View File

@ -24,6 +24,7 @@ StatusMenu {
property string myPublicKey: ""
property bool amIChatAdmin: false
property bool disabledForChat: false
property string selectedUserPublicKey: ""
property string selectedUserDisplayName: ""
@ -144,7 +145,8 @@ StatusMenu {
id: emojiContainer
width: emojiRow.width
height: visible ? emojiRow.height : 0
visible: !root.hideEmojiPicker && (root.isEmoji || !root.isProfile) && !root.pinnedPopup
visible: !root.hideEmojiPicker && (root.isEmoji || !root.isProfile) && !root.pinnedPopup && !root.disabledForChat
Row {
id: emojiRow
spacing: Style.current.halfPadding
@ -190,7 +192,7 @@ StatusMenu {
height: visible ? root.topPadding : 0
}
Separator {
StatusMenuSeparator {
anchors.bottom: viewProfileAction.top
visible: !root.isEmoji && !root.hideEmojiPicker && !pinnedPopup
}
@ -238,6 +240,7 @@ StatusMenu {
}
SendContactRequestMenuItem {
id: sendContactRequestMenuItem
enabled: root.isProfile && !root.isMe && !root.isContact
&& !root.isBlockedContact && !root.hasPendingContactRequest
onTriggered: {
@ -247,6 +250,7 @@ StatusMenu {
}
StatusAction {
id: verifyIdentityAction
text: qsTr("Verify Identity")
icon.name: "checkmark-circle"
enabled: root.isProfile && !root.isMe && root.isContact
@ -260,7 +264,8 @@ StatusMenu {
}
StatusAction {
text: isVerificationRequestSent ||
id: pendingIdentityAction
text: isVerificationRequestSent ||
root.incomingVerificationStatus === Constants.verificationStatus.verified ?
qsTr("ID Request Pending....") :
qsTr("Respond to ID Request...")
@ -281,6 +286,7 @@ StatusMenu {
}
StatusAction {
id: renameAction
text: qsTr("Rename")
icon.name: "edit_pencil"
enabled: root.isProfile && !root.isMe
@ -292,6 +298,7 @@ StatusMenu {
}
StatusAction {
id: unblockAction
text: qsTr("Unblock User")
icon.name: "remove-circle"
enabled: root.isProfile && !root.isMe && root.isBlockedContact
@ -340,7 +347,8 @@ StatusMenu {
!root.isEmoji &&
!root.isProfile &&
!root.pinnedPopup &&
!root.isRightClickOnImage)
!root.isRightClickOnImage &&
!root.disabledForChat)
}
StatusAction {
@ -356,7 +364,8 @@ StatusMenu {
!root.isSticker &&
!root.isProfile &&
!root.pinnedPopup &&
!root.isRightClickOnImage
!root.isRightClickOnImage &&
!root.disabledForChat
}
StatusAction {
@ -406,7 +415,7 @@ StatusMenu {
}
icon.name: "pin"
enabled: {
if(root.isProfile || root.isEmoji || root.isRightClickOnImage)
if (root.isProfile || root.isEmoji || root.isRightClickOnImage || root.disabledForChat)
return false
if (root.pinnedPopup)
@ -440,6 +449,7 @@ StatusMenu {
StatusAction {
id: deleteMessageAction
enabled: (root.isMyMessage || root.amIChatAdmin) &&
!root.disabledForChat &&
!root.isProfile &&
!root.isEmoji &&
!root.pinnedPopup &&

View File

@ -134,7 +134,7 @@ Loader {
imageSource = "") {
if (placeholderMessage || !(root.rootStore.mainModuleInst.activeSection.joined || isProfileClick)) {
return
return false
}
messageContextMenu.myPublicKey = userProfile.pubKey
@ -164,7 +164,7 @@ Loader {
if (isReply) {
if (!quotedMessageFrom) {
// The responseTo message was deleted so we don't eneble to right click the unaviable profile
return
return false
}
messageContextMenu.messageSenderId = quotedMessageFrom
messageContextMenu.selectedUserPublicKey = quotedMessageFrom
@ -172,8 +172,14 @@ Loader {
messageContextMenu.selectedUserIcon = quotedMessageAuthorDetailsThumbnailImage
}
messageContextMenu.parent = sender;
messageContextMenu.popup(point);
// Emoji container is not a menu item of messageContextMenu so checking it separatly
if (messageContextMenu.checkIfEmpty() && !isEmoji) {
return false
}
messageContextMenu.parent = sender
messageContextMenu.popup(point)
return true
}
signal showReplyArea(string messageId, string author)
@ -462,6 +468,7 @@ Loader {
root.editModeOn ||
!root.rootStore.mainModuleInst.activeSection.joined
disableEmojis: root.isChatBlocked
hideMessage: d.hideMessage
overrideBackground: root.placeholderMessage
@ -504,13 +511,13 @@ Loader {
}
onProfilePictureClicked: {
d.setMessageActive(root.messageId, true);
root.messageClickHandler(sender, Qt.point(mouse.x, mouse.y), true);
if (root.messageClickHandler(sender, Qt.point(mouse.x, mouse.y), true))
d.setMessageActive(root.messageId, true)
}
onReplyProfileClicked: {
d.setMessageActive(root.messageId, true);
root.messageClickHandler(sender, Qt.point(mouse.x, mouse.y), true, false, false, null, false, false, true);
if (root.messageClickHandler(sender, Qt.point(mouse.x, mouse.y), true, false, false, null, false, false, true))
d.setMessageActive(root.messageId, true)
}
onReplyMessageClicked: {
@ -518,8 +525,8 @@ Loader {
}
onSenderNameClicked: {
d.setMessageActive(root.messageId, true);
root.messageClickHandler(sender, Qt.point(mouse.x, mouse.y), true);
if (root.messageClickHandler(sender, Qt.point(mouse.x, mouse.y), true))
d.setMessageActive(root.messageId, true)
}
onToggleReactionClicked: {
@ -536,10 +543,10 @@ Loader {
onAddReactionClicked: {
if (root.isChatBlocked)
return;
return
d.setMessageActive(root.messageId, true);
root.messageClickHandler(sender, Qt.point(mouse.x, mouse.y), false, false, false, null, true, false);
if (root.messageClickHandler(sender, Qt.point(mouse.x, mouse.y), false, false, false, null, true, false))
d.setMessageActive(root.messageId, true)
}
onStickerClicked: {
@ -556,9 +563,9 @@ Loader {
!root.placeholderMessage &&
delegate.contentType !== StatusMessage.ContentType.Image
onClicked: {
d.setMessageActive(root.messageId, true);
root.messageClickHandler(this, Qt.point(mouse.x, mouse.y),
false, false, false, null, root.isEmoji, false, false, false, "");
if (root.messageClickHandler(this, Qt.point(mouse.x, mouse.y),
false, false, false, null, root.isEmoji, false, false, false, ""))
d.setMessageActive(root.messageId, true)
}
}
@ -729,8 +736,8 @@ Loader {
type: StatusFlatRoundButton.Type.Tertiary
tooltip.text: qsTr("Add reaction")
onClicked: {
d.setMessageActive(root.messageId, true)
root.messageClickHandler(delegate, mapToItem(delegate, mouse.x, mouse.y), false, false, false, null, true, false)
if (root.messageClickHandler(delegate, mapToItem(delegate, mouse.x, mouse.y), false, false, false, null, true, false))
d.setMessageActive(root.messageId, true)
}
}
},