From c673f8302a42a9483071e4486ccaadcaefc0410e Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Tue, 17 May 2022 12:40:27 +0200 Subject: [PATCH] fix(@chat): only show reaction to emoji right click fixes #5764 --- ui/app/AppLayouts/stores/MessageStore.qml | 4 +-- .../shared/panels/chat/ChatButtonsPanel.qml | 2 +- .../shared/panels/chat/ChatReplyPanel.qml | 2 +- .../shared/views/chat/CompactMessageView.qml | 26 +++++++++++++------ .../views/chat/MessageContextMenuView.qml | 18 ++++++------- ui/imports/shared/views/chat/MessageView.qml | 16 +++--------- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/ui/app/AppLayouts/stores/MessageStore.qml b/ui/app/AppLayouts/stores/MessageStore.qml index 0c0d7f938e..173343c94f 100644 --- a/ui/app/AppLayouts/stores/MessageStore.qml +++ b/ui/app/AppLayouts/stores/MessageStore.qml @@ -131,7 +131,7 @@ QtObject { return [] } } - property var clickMessage: function(isProfileClick, isSticker = false, isImage = false, image = null, emojiOnly = false, hideEmojiPicker = false, isReply = false, isRightClickOnImage = false, imageSource = "") { + property var clickMessage: function(isProfileClick, isSticker = false, isImage = false, image = null, isEmoji = false, hideEmojiPicker = false, isReply = false, isRightClickOnImage = false, imageSource = "") { if (placeholderMessage || activityCenterMessage) { return } @@ -147,7 +147,7 @@ QtObject { messageContextMenu.isCurrentUser = isCurrentUser messageContextMenu.isText = isText messageContextMenu.isSticker = isSticker; - messageContextMenu.emojiOnly = emojiOnly; + messageContextMenu.isEmoji = isEmoji; messageContextMenu.hideEmojiPicker = hideEmojiPicker; messageContextMenu.pinnedMessage = pinnedMessage; messageContextMenu.isCurrentUser = isCurrentUser; diff --git a/ui/imports/shared/panels/chat/ChatButtonsPanel.qml b/ui/imports/shared/panels/chat/ChatButtonsPanel.qml index f0c4827a65..cbdf861ba3 100644 --- a/ui/imports/shared/panels/chat/ChatButtonsPanel.qml +++ b/ui/imports/shared/panels/chat/ChatButtonsPanel.qml @@ -23,7 +23,7 @@ Rectangle { signal replyClicked(string messageId, string author) signal hoverChanged(bool hovered) signal setMessageActive(string messageId, bool active) - signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker) + signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool isEmoji, bool hideEmojiPicker) visible: !buttonsContainer.isChatBlocked && !buttonsContainer.placeholderMsg && !buttonsContainer.activityCenterMsg && diff --git a/ui/imports/shared/panels/chat/ChatReplyPanel.qml b/ui/imports/shared/panels/chat/ChatReplyPanel.qml index 276c9d2f1d..d52096e7d3 100644 --- a/ui/imports/shared/panels/chat/ChatReplyPanel.qml +++ b/ui/imports/shared/panels/chat/ChatReplyPanel.qml @@ -34,7 +34,7 @@ Loader { property int chatHorizontalPadding property string stickerData - signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker, bool isReply) + signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool isEmoji, bool hideEmojiPicker, bool isReply) signal scrollToBottom(bool isit, var container) sourceComponent: Component { diff --git a/ui/imports/shared/views/chat/CompactMessageView.qml b/ui/imports/shared/views/chat/CompactMessageView.qml index 115708011d..58f6602407 100644 --- a/ui/imports/shared/views/chat/CompactMessageView.qml +++ b/ui/imports/shared/views/chat/CompactMessageView.qml @@ -67,11 +67,21 @@ Item { property var transactionParams signal openStickerPackPopup(string stickerPackId) - signal addEmoji(bool isProfileClick, bool isSticker, bool isImage , var image, bool emojiOnly, bool hideEmojiPicker) - signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker, bool isReply, bool isRightClickOnImage, string imageSource) + signal addEmoji(bool isProfileClick, bool isSticker, bool isImage , var image, bool isEmoji, bool hideEmojiPicker) + signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool isEmoji, bool hideEmojiPicker, bool isReply, bool isRightClickOnImage, string imageSource) signal replyClicked(string messageId, string author) signal imageClicked(var image) + + function setMessageActive(messageId, active) { + if (active) { + activeMessage = messageId; + } else if (activeMessage === messageId) { + activeMessage = ""; + } + } + + width: parent.width height: messageContainer.height + messageContainer.anchors.topMargin + (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0) @@ -104,7 +114,7 @@ Item { isActivityCenterMessage: activityCenterMessage stickersLoaded: root.stickersLoaded onClickMessage: { - root.clickMessage(isProfileClick, isSticker, isImage, null, false, false, false, false, ""); + root.clickMessage(isProfileClick, isSticker, isImage, null, isEmoji, false, false, false, ""); } } @@ -128,7 +138,7 @@ Item { activityCenterMsg: activityCenterMessage placeholderMsg: placeholderMessage onClickMessage: { - root.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, false, false, ""); + root.clickMessage(isProfileClick, isSticker, isImage, image, isEmoji, hideEmojiPicker, false, false, ""); } onReplyClicked: { root.replyClicked(messageId, author) @@ -141,7 +151,7 @@ Item { Connections { enabled: isMessageActive target: root.messageContextMenu - onClosed: setMessageActive(messageId, false) + onClosed: root.setMessageActive(messageId, false) } } } @@ -322,7 +332,7 @@ Item { } onClickMessage: { - root.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, isReply, false, "") + root.clickMessage(isProfileClick, isSticker, isImage, image, isEmoji, hideEmojiPicker, isReply, false, "") } } @@ -600,7 +610,7 @@ Item { } onSetMessageActive: { - setMessageActive(messageId, active); + root.setMessageActive(messageId, active); } } @@ -749,7 +759,7 @@ Item { } onSetMessageActive: { - setMessageActive(messageId, active);; + root.setMessageActive(messageId, active); } } } diff --git a/ui/imports/shared/views/chat/MessageContextMenuView.qml b/ui/imports/shared/views/chat/MessageContextMenuView.qml index b98155b816..92d9de91d6 100644 --- a/ui/imports/shared/views/chat/MessageContextMenuView.qml +++ b/ui/imports/shared/views/chat/MessageContextMenuView.qml @@ -41,7 +41,7 @@ StatusPopupMenu { property bool isRightClickOnImage: false property bool pinnedPopup: false property bool isDebugEnabled: false - property bool emojiOnly: false + property bool isEmoji: false property bool hideEmojiPicker: true property bool pinnedMessage: false property bool canPin: false @@ -83,7 +83,7 @@ StatusPopupMenu { /* // copy link feature not ready yet const numLinkUrls = root.linkUrls.split(" ").length copyLinkMenu.enabled = numLinkUrls > 1 - copyLinkAction.enabled = !!root.linkUrls && numLinkUrls === 1 && !emojiOnly && !root.isProfile + copyLinkAction.enabled = !!root.linkUrls && numLinkUrls === 1 && !isEmoji && !root.isProfile */ popup() } @@ -92,13 +92,13 @@ StatusPopupMenu { id: emojiContainer width: emojiRow.width height: visible ? emojiRow.height : 0 - visible: !root.hideEmojiPicker && (root.emojiOnly || !root.isProfile) && !root.pinnedPopup + visible: !root.hideEmojiPicker && (root.isEmoji || !root.isProfile) && !root.pinnedPopup Row { id: emojiRow spacing: Style.current.halfPadding leftPadding: Style.current.halfPadding rightPadding: Style.current.halfPadding - bottomPadding: root.emojiOnly ? 0 : Style.current.padding + bottomPadding: root.isEmoji ? 0 : Style.current.padding Repeater { model: root.reactionModel @@ -131,7 +131,7 @@ StatusPopupMenu { Separator { anchors.bottom: viewProfileAction.top - visible: !root.emojiOnly && !root.hideEmojiPicker && !pinnedPopup + visible: !root.isEmoji && !root.hideEmojiPicker && !pinnedPopup } StatusMenuItem { @@ -188,7 +188,7 @@ StatusPopupMenu { icon.name: "chat" enabled: root.isProfile && root.store.contactsStore.isMyMutualContact(root.selectedUserPublicKey) || (!root.hideEmojiPicker && - !root.emojiOnly && + !root.isEmoji && !root.isProfile && !root.pinnedPopup && !root.isRightClickOnImage) @@ -204,7 +204,7 @@ StatusPopupMenu { icon.name: "edit" enabled: root.isMyMessage && !root.hideEmojiPicker && - !root.emojiOnly && + !root.isEmoji && !root.isProfile && !root.pinnedPopup && !root.isRightClickOnImage @@ -248,7 +248,7 @@ StatusPopupMenu { } icon.name: "pin" enabled: { - if(root.isProfile || root.emojiOnly || root.isRightClickOnImage) + if(root.isProfile || root.isEmoji || root.isRightClickOnImage) return false switch (root.chatType) { @@ -280,7 +280,7 @@ StatusPopupMenu { id: deleteMessageAction enabled: root.isMyMessage && !root.isProfile && - !root.emojiOnly && + !root.isEmoji && !root.pinnedPopup && !root.isRightClickOnImage && (root.messageContentType === Constants.messageContentType.messageType || diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 9724579095..3e773093b0 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -83,14 +83,6 @@ Column { } } - function setMessageActive(messageId, active) { - if (active) { - activeMessage = messageId; - } else if (activeMessage === messageId) { - activeMessage = ""; - } - } - // Legacy property string responseTo: responseToMessageWithId property bool isCurrentUser: amISender @@ -159,7 +151,7 @@ Column { isSticker = false, isImage = false, image = null, - emojiOnly = false, + isEmoji = false, hideEmojiPicker = false, isReply = false, isRightClickOnImage = false, @@ -187,7 +179,7 @@ Column { messageContextMenu.isProfile = !!isProfileClick messageContextMenu.isRightClickOnImage = isRightClickOnImage - messageContextMenu.emojiOnly = emojiOnly + messageContextMenu.isEmoji = isEmoji messageContextMenu.hideEmojiPicker = hideEmojiPicker if(isReply){ @@ -363,11 +355,11 @@ Column { transactionParams: root.transactionParams onAddEmoji: { - root.clickMessage(isProfileClick, isSticker, isImage , image, emojiOnly, hideEmojiPicker) + root.clickMessage(isProfileClick, isSticker, isImage , image, isEmoji, hideEmojiPicker) } onClickMessage: { - root.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, isReply, isRightClickOnImage, imageSource) + root.clickMessage(isProfileClick, isSticker, isImage, image, isEmoji, hideEmojiPicker, isReply, isRightClickOnImage, imageSource) } onOpenStickerPackPopup: {