From 1a0ed7f2986449bc522a20177cd48285c838ce96 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Wed, 29 Nov 2023 23:47:59 +0100 Subject: [PATCH] Only one star per list, restore users in poll results --- qml/components/MessageListViewItem.qml | 20 ++++++++++++++++++++ qml/pages/ChatPage.qml | 5 +++++ qml/pages/PollResultsPage.qml | 7 ++++--- rpm/harbour-fernschreiber.spec | 2 +- src/tdlibreceiver.cpp | 7 +++++++ src/tdlibreceiver.h | 4 +++- src/tdlibwrapper.cpp | 1 + src/tdlibwrapper.h | 1 + 8 files changed, 42 insertions(+), 5 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index dcb5b47..9608a08 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -132,6 +132,10 @@ ListItem { if (messageListItem.messageReactions) { messageListItem.messageReactions = null; + selectReactionBubble.visible = false; + } else { + selectReactionBubble.visible = !selectReactionBubble.visible; + elementSelected(index); } } } @@ -171,6 +175,19 @@ ListItem { } } + Connections { + target: chatPage + onResetElements: { + messageListItem.messageReactions = null; + selectReactionBubble.visible = false; + } + onElementSelected: { + if (elementIndex !== index) { + selectReactionBubble.visible = false; + } + } + } + Loader { id: contextMenuLoader active: false @@ -275,6 +292,9 @@ ListItem { messageListItem.messageReactions = null; } } + onReactionsUpdated: { + chatReactions = tdLibWrapper.getChatReactions(page.chatInformation.id); + } } Timer { diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 993db38..313e642 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -67,6 +67,8 @@ Page { property bool doSendBotStartMessage property string sendBotStartMessageParameter property var availableReactions + signal resetElements() + signal elementSelected(int elementIndex) states: [ State { @@ -480,7 +482,10 @@ Page { if (pageStack.depth === 1) { // Only clear chat model if navigated back to overview page. In other cases we keep the information... chatModel.clear(); + } else { + resetElements(); } + break; } } diff --git a/qml/pages/PollResultsPage.qml b/qml/pages/PollResultsPage.qml index 69dabb7..0368757 100644 --- a/qml/pages/PollResultsPage.qml +++ b/qml/pages/PollResultsPage.qml @@ -143,10 +143,11 @@ Page { Connections { target: tdLibWrapper - onUsersReceived: { + onMessageSendersReceived: { + Debug.log("Received poll users...") if(extra === optionDelegate.usersResponseIdentifierString) { - for(var i = 0; i < userIds.length; i += 1) { - optionDelegate.users.append({id: userIds[i], user:tdLibWrapper.getUserInformation(userIds[i])}); + for(var i = 0; i < senders.length; i += 1) { + optionDelegate.users.append({id: senders[i].user_id, user:tdLibWrapper.getUserInformation(senders[i].user_id)}); } loadUsersTimer.start(); } diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 4b6264a..8923dbb 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: 10 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index abd9d03..c93b549 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -160,6 +160,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("updateChatPinnedMessage", &TDLibReceiver::processUpdateChatPinnedMessage); handlers.insert("updateMessageIsPinned", &TDLibReceiver::processUpdateMessageIsPinned); handlers.insert("users", &TDLibReceiver::processUsers); + handlers.insert("messageSenders", &TDLibReceiver::processMessageSenders); handlers.insert("error", &TDLibReceiver::processError); handlers.insert("ok", &TDLibReceiver::ok); handlers.insert("secretChat", &TDLibReceiver::processSecretChat); @@ -634,6 +635,12 @@ void TDLibReceiver::processUsers(const QVariantMap &receivedInformation) emit usersReceived(receivedInformation.value(_EXTRA).toString(), receivedInformation.value("user_ids").toList(), receivedInformation.value(TOTAL_COUNT).toInt()); } +void TDLibReceiver::processMessageSenders(const QVariantMap &receivedInformation) +{ + LOG("Received Message Senders"); + emit messageSendersReceived(receivedInformation.value(_EXTRA).toString(), receivedInformation.value("senders").toList(), receivedInformation.value(TOTAL_COUNT).toInt()); +} + void TDLibReceiver::processError(const QVariantMap &receivedInformation) { LOG("Received an error"); diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index bfb380e..dda2cd0 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -88,7 +88,8 @@ signals: void chatTitleUpdated(const QString &chatId, const QString &title); void chatPinnedMessageUpdated(qlonglong chatId, qlonglong pinnedMessageId); void messageIsPinnedUpdated(qlonglong chatId, qlonglong messageId, bool isPinned); - void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers); + void usersReceived(const QString &extra, const QVariantList &senders, int totalUsers); + void messageSendersReceived(const QString &extra, const QVariantList &userIds, int totalUsers); void errorReceived(const int code, const QString &message, const QString &extra); void secretChat(qlonglong secretChatId, const QVariantMap &secretChat); void secretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat); @@ -173,6 +174,7 @@ private: void processUpdateChatPinnedMessage(const QVariantMap &receivedInformation); void processUpdateMessageIsPinned(const QVariantMap &receivedInformation); void processUsers(const QVariantMap &receivedInformation); + void processMessageSenders(const QVariantMap &receivedInformation); void processError(const QVariantMap &receivedInformation); void processSecretChat(const QVariantMap &receivedInformation); void processUpdateSecretChat(const QVariantMap &receivedInformation); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index f815ccf..7e56268 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -176,6 +176,7 @@ void TDLibWrapper::initializeTDLibReceiver() { connect(this->tdLibReceiver, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong)), this, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong))); connect(this->tdLibReceiver, SIGNAL(messageIsPinnedUpdated(qlonglong, qlonglong, bool)), this, SLOT(handleMessageIsPinnedUpdated(qlonglong, qlonglong, bool))); connect(this->tdLibReceiver, SIGNAL(usersReceived(QString, QVariantList, int)), this, SIGNAL(usersReceived(QString, QVariantList, int))); + connect(this->tdLibReceiver, SIGNAL(messageSendersReceived(QString, QVariantList, int)), this, SIGNAL(messageSendersReceived(QString, QVariantList, int))); connect(this->tdLibReceiver, SIGNAL(errorReceived(int, QString, QString)), this, SLOT(handleErrorReceived(int, QString, QString))); connect(this->tdLibReceiver, SIGNAL(contactsImported(QVariantList, QVariantList)), this, SIGNAL(contactsImported(QVariantList, QVariantList))); connect(this->tdLibReceiver, SIGNAL(messageEditedUpdated(qlonglong, qlonglong, QVariantMap)), this, SIGNAL(messageEditedUpdated(qlonglong, qlonglong, QVariantMap))); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 17a0896..8217804 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -322,6 +322,7 @@ signals: void chatTitleUpdated(const QString &chatId, const QString &title); void chatPinnedMessageUpdated(qlonglong chatId, qlonglong pinnedMessageId); void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers); + void messageSendersReceived(const QString &extra, const QVariantList &senders, int totalUsers); void errorReceived(int code, const QString &message, const QString &extra); void contactsImported(const QVariantList &importerCount, const QVariantList &userIds); void messageNotFound(qlonglong chatId, qlonglong messageId);