From ec972d7edcd3f9a1e17a2e470bc7528ecf6f78d0 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 +- src/tdlibwrapper.cpp | 1 + src/tdlibwrapper.h | 1 + 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 52bb33d..cbc7865 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 f45d1a7..b361923 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 634f456..51a5f21 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 Aurora OS Version: 0.17 -Release: 7 +Release: 8 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ 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);