feat: support seeing who liked a message

This commit is contained in:
hydrogen 2020-11-23 11:50:00 +02:00 committed by Iuri Matias
parent 2baa55b5c4
commit 9f6e582111

View File

@ -1,4 +1,5 @@
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 2.13
import "../../../../../shared" import "../../../../../shared"
import "../../../../../imports" import "../../../../../imports"
@ -23,11 +24,13 @@ Item {
if (!byEmoji[reaction.emojiId]) { if (!byEmoji[reaction.emojiId]) {
byEmoji[reaction.emojiId] = { byEmoji[reaction.emojiId] = {
emojiId: reaction.emojiId, emojiId: reaction.emojiId,
fromAccounts: [],
count: 0, count: 0,
currentUserReacted: false currentUserReacted: false
} }
} }
byEmoji[reaction.emojiId].count++; byEmoji[reaction.emojiId].count++;
byEmoji[reaction.emojiId].fromAccounts.push(chatsModel.userNameOrAlias(reaction.from));
if (!byEmoji[reaction.emojiId].currentUserReacted && reaction.from === profileModel.profile.pubKey) { if (!byEmoji[reaction.emojiId].currentUserReacted && reaction.from === profileModel.profile.pubKey) {
byEmoji[reaction.emojiId].currentUserReacted = true byEmoji[reaction.emojiId].currentUserReacted = true
} }
@ -49,6 +52,11 @@ Item {
anchors.leftMargin: (index === 0) ? 0 : root.imageMargin anchors.leftMargin: (index === 0) ? 0 : root.imageMargin
color: modelData.currentUserReacted ? Style.current.primary : Style.current.inputBackground color: modelData.currentUserReacted ? Style.current.primary : Style.current.inputBackground
ToolTip {
visible: mouseArea.containsMouse
text: modelData.fromAccounts.join(", ")
}
// Rounded corner to cover one corner // Rounded corner to cover one corner
Rectangle { Rectangle {
color: parent.color color: parent.color
@ -95,7 +103,9 @@ Item {
} }
MouseArea { MouseArea {
id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
chatsModel.toggleEmojiReaction(messageId, modelData.emojiId) chatsModel.toggleEmojiReaction(messageId, modelData.emojiId)