From 61faf0f4079e3c8f089052f33edc8eb7e5e3125a Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 26 Nov 2023 23:36:29 +0100 Subject: [PATCH] More tweaks for reactions --- qml/components/MessageListViewItem.qml | 43 +++++++++++++++++++------- qml/pages/ChatPage.qml | 3 ++ rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/tdlibwrapper.cpp | 1 + src/tdlibwrapper.h | 1 + 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index c174da2..98a5c32 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -115,6 +115,19 @@ ListItem { return interactionText; } + function openReactions() { + if (messageListItem.chatReactions) { + Debug.log("Using chat reactions") + messageListItem.messageReactions = chatReactions + showItemCompletelyTimer.requestedIndex = index; + showItemCompletelyTimer.start(); + } else { + Debug.log("Obtaining message reactions") + tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); + } + selectReactionBubble.visible = false; + } + onClicked: { if (messageListItem.precalculatedValues.pageIsSelecting) { page.toggleMessageSelection(myMessage); @@ -134,11 +147,17 @@ ListItem { messageListItem.messageReactions = null; selectReactionBubble.visible = false; } else { - selectReactionBubble.visible = !selectReactionBubble.visible; + if (messageListItem.chatReactions) { + selectReactionBubble.visible = !selectReactionBubble.visible; + } } } } + onDoubleClicked: { + openReactions(); + } + onPressAndHold: { if (openMenuOnPressAndHold) { openContextMenu() @@ -643,6 +662,17 @@ ListItem { textFormat: Text.StyledText maximumLineCount: 1 elide: Text.ElideRight + MouseArea { + anchors.fill: parent + onClicked: { + if (messageListItem.messageReactions) { + messageListItem.messageReactions = null; + selectReactionBubble.visible = false; + } else { + openReactions(); + } + } + } } } } @@ -672,16 +702,7 @@ ListItem { icon.source: "image://theme/icon-s-favorite" anchors.centerIn: selectReactionBubble onClicked: { - if (messageListItem.chatReactions) { - Debug.log("Using chat reactions") - messageListItem.messageReactions = chatReactions - showItemCompletelyTimer.requestedIndex = index; - showItemCompletelyTimer.start(); - } else { - Debug.log("Obtaining message reactions") - tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); - } - selectReactionBubble.visible = false; + openReactions(); } } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index c70e454..48d741b 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -576,6 +576,9 @@ Page { onSponsoredMessageReceived: { chatPage.containsSponsoredMessages = true; } + onReactionsUpdated: { + availableReactions = tdLibWrapper.getChatReactions(chatInformation.id); + } } Connections { diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index e114f17..e074a21 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 7 +Release: 8 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 4f49d27..05f2fd4 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 7 +Release: 8 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index e082592..6b3e994 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -2093,6 +2093,7 @@ void TDLibWrapper::handleActiveEmojiReactionsUpdated(const QStringList& emojis) if (activeEmojiReactions != emojis) { activeEmojiReactions = emojis; LOG(emojis.count() << "reaction(s) available"); + emit reactionsUpdated(); } } diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 49cda61..c4773e3 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -339,6 +339,7 @@ signals: void chatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount); void chatUnreadReactionCountUpdated(qlonglong chatId, int unreadReactionCount); void tgUrlFound(const QString &tgUrl); + void reactionsUpdated(); public slots: void handleVersionDetected(const QString &version);