fix(CompactMessage): fix message hover getting stuck

Fixes #2226 and #2196
This commit is contained in:
Jonathan Rainville 2021-04-21 11:22:49 -04:00 committed by Iuri Matias
parent 58e292e9ab
commit 2e25bf4f8a
5 changed files with 28 additions and 11 deletions

View File

@ -22,6 +22,25 @@ ScrollView {
property real scrollY: chatLogView.visibleArea.yPosition * chatLogView.contentHeight
property int newMessages: 0
property string hoveredMessage
property string activeMessage
function setHovered(messageId, hovered) {
if (hovered) {
hoveredMessage = messageId
} else if (hoveredMessage === messageId) {
hoveredMessage = ""
}
}
function setMessageActive(messageId, active) {
if (active) {
activeMessage = messageId
} else if (activeMessage === messageId) {
activeMessage = ""
}
}
contentItem: chatLogView
Layout.fillWidth: true
Layout.fillHeight: true

View File

@ -59,7 +59,7 @@ Rectangle {
width: 32
height: 32
onClicked: {
isMessageActive = true
setMessageActive(messageId, true)
clickMessage(false, false, false, null, true)
messageContextMenu.x = buttonsContainer.x + buttonsContainer.width - messageContextMenu.width

View File

@ -12,8 +12,8 @@ Item {
property int contentType: 2
property var container
property bool isCurrentUser: false
property bool isHovered: false
property bool isMessageActive: false
property bool isHovered: typeof hoveredMessage !== "undefined" && hoveredMessage === messageId
property bool isMessageActive: typeof activeMessage !== "undefined" && activeMessage === messageId
property bool headerRepeatCondition: (authorCurrentMsg !== authorPrevMsg || shouldRepeatHeader || dateGroupLbl.visible)
id: root
@ -32,7 +32,7 @@ Item {
ChatButtons {
contentType: root.contentType
parentIsHovered: root.isHovered
onHoverChanged: root.isHovered = hovered
onHoverChanged: hovered && setHovered(messageId, hovered)
anchors.right: parent.right
anchors.rightMargin: 20
anchors.top: messageContainer.top
@ -46,7 +46,7 @@ Item {
Connections {
enabled: root.isMessageActive
target: messageContextMenu
onClosed: root.isMessageActive = false
onClosed: setMessageActive(messageId, false)
}
}
}
@ -243,9 +243,7 @@ Item {
HoverHandler {
enabled: typeof messageContextMenu !== "undefined" && typeof profilePopupOpened !== "undefined" && !messageContextMenu.opened && !profilePopupOpened && !popupOpened
onHoveredChanged: {
root.isHovered = hovered;
}
onHoveredChanged: setHovered(messageId, hovered)
}
Loader {
@ -258,7 +256,7 @@ Item {
sourceComponent: Component {
EmojiReactions {
onHoverChanged: root.isHovered = hovered
onHoverChanged: setHovered(messageId, hovered)
}
}
}

View File

@ -213,7 +213,7 @@ Item {
onExited: addEmojiBtn.isHovered = false
onClicked: {
if (typeof isMessageActive !== "undefined") {
isMessageActive = true
setMessageActive(messageId, true)
}
clickMessage(false, false, false, null, true)
}

View File

@ -11,7 +11,7 @@ MouseArea {
if(mouse.button & Qt.RightButton) {
clickMessage(false, isSticker, false);
if (typeof isMessageActive !== "undefined") {
isMessageActive = true
setMessageActive(messageId, true)
}
return;
}