upstream_fixes_28112023 #15
3 changed files with 45 additions and 6 deletions
|
@ -705,12 +705,25 @@ ListItem {
|
|||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
tdLibWrapper.setMessageReaction(messageListItem.chatId, messageListItem.messageId, modelData);
|
||||
messageListItem.messageReactions = null;
|
||||
for (var i = 0; i < reactions.length; i++) {
|
||||
var reaction = reactions[i]
|
||||
var reactionText = reaction.reaction ? reaction.reaction : (reaction.type && reaction.type.emoji) ? reaction.type.emoji : ""
|
||||
if (reactionText === modelData) {
|
||||
if (reaction.is_chosen) {
|
||||
// Reaction is already selected
|
||||
tdLibWrapper.removeMessageReaction(chatId, messageId, reactionText)
|
||||
messageReactions = null
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
// Reaction is not yet selected
|
||||
tdLibWrapper.addMessageReaction(chatId, messageId, modelData)
|
||||
messageReactions = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1462,9 +1462,8 @@ void TDLibWrapper::getPageSource(const QString &address)
|
|||
connect(reply, SIGNAL(finished()), this, SLOT(handleGetPageSourceFinished()));
|
||||
}
|
||||
|
||||
void TDLibWrapper::setMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction)
|
||||
void TDLibWrapper::addMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction)
|
||||
{
|
||||
LOG("Set message reaction" << chatId << messageId << reaction);
|
||||
QVariantMap requestObject;
|
||||
requestObject.insert(CHAT_ID, chatId);
|
||||
requestObject.insert(MESSAGE_ID, messageId);
|
||||
|
@ -1479,9 +1478,35 @@ void TDLibWrapper::setMessageReaction(qlonglong chatId, qlonglong messageId, con
|
|||
reactionType.insert(EMOJI, reaction);
|
||||
requestObject.insert(REACTION_TYPE, reactionType);
|
||||
requestObject.insert(_TYPE, "addMessageReaction");
|
||||
LOG("Add message reaction" << chatId << messageId << reaction);
|
||||
} else {
|
||||
requestObject.insert("reaction", reaction);
|
||||
requestObject.insert(_TYPE, "setMessageReaction");
|
||||
LOG("Toggle message reaction" << chatId << messageId << reaction);
|
||||
}
|
||||
this->sendRequest(requestObject);
|
||||
}
|
||||
|
||||
void TDLibWrapper::removeMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction)
|
||||
{
|
||||
QVariantMap requestObject;
|
||||
requestObject.insert(CHAT_ID, chatId);
|
||||
requestObject.insert(MESSAGE_ID, messageId);
|
||||
if (versionNumber > VERSION_NUMBER(1,8,5)) {
|
||||
// "reaction_type": {
|
||||
// "@type": "reactionTypeEmoji",
|
||||
// "emoji": "..."
|
||||
// }
|
||||
QVariantMap reactionType;
|
||||
reactionType.insert(_TYPE, REACTION_TYPE_EMOJI);
|
||||
reactionType.insert(EMOJI, reaction);
|
||||
requestObject.insert(REACTION_TYPE, reactionType);
|
||||
requestObject.insert(_TYPE, "removeMessageReaction");
|
||||
LOG("Remove message reaction" << chatId << messageId << reaction);
|
||||
} else {
|
||||
requestObject.insert("reaction", reaction);
|
||||
requestObject.insert(_TYPE, "setMessageReaction");
|
||||
LOG("Toggle message reaction" << chatId << messageId << reaction);
|
||||
}
|
||||
this->sendRequest(requestObject);
|
||||
}
|
||||
|
|
|
@ -249,7 +249,8 @@ public:
|
|||
Q_INVOKABLE void terminateSession(const QString &sessionId);
|
||||
Q_INVOKABLE void getMessageAvailableReactions(qlonglong chatId, qlonglong messageId);
|
||||
Q_INVOKABLE void getPageSource(const QString &address);
|
||||
Q_INVOKABLE void setMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction);
|
||||
Q_INVOKABLE void addMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction);
|
||||
Q_INVOKABLE void removeMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction);
|
||||
Q_INVOKABLE void setNetworkType(NetworkType networkType);
|
||||
Q_INVOKABLE void setInactiveSessionTtl(int days);
|
||||
|
||||
|
|
Loading…
Reference in a new issue