Start work on un/muting chats

This commit is contained in:
Sebastian J. Wolf 2020-09-16 00:15:43 +02:00
parent 0daea61bd9
commit 1a5aa9de3f
5 changed files with 44 additions and 1 deletions

View file

@ -223,6 +223,21 @@ Page {
pageStack.push(Qt.resolvedUrl("../pages/ChatPage.qml"), { "chatInformation" : display });
}
menu: ContextMenu {
MenuItem {
onClicked: {
var newNotificationSettings = display.notification_settings;
if (newNotificationSettings.mute_for > 0) {
newNotificationSettings.mute_for = 0;
} else {
newNotificationSettings.mute_for = 666666;
}
tdLibWrapper.setChatNotificationSettings(display.id, newNotificationSettings);
}
text: display.notification_settings.mute_for > 0 ? qsTr("Unmute Chat") : qsTr("Mute Chat")
}
}
Connections {
target: chatListModel
onChatChanged: {

View file

@ -90,6 +90,7 @@ void TDLibWrapper::sendRequest(const QVariantMap &requestObject)
{
qDebug() << "[TDLibWrapper] Sending request to TD Lib, object type name: " << requestObject.value("@type").toString();
QJsonDocument requestDocument = QJsonDocument::fromVariant(requestObject);
qDebug().noquote() << requestDocument.toJson();
td_json_client_send(this->tdLibClient, requestDocument.toJson().constData());
}
@ -227,7 +228,7 @@ void TDLibWrapper::getMessage(const QString &chatId, const QString &messageId)
void TDLibWrapper::setOptionInteger(const QString &optionName, const int &optionValue)
{
qDebug() << "[TDLibWrapper] Setting integet option " << optionName << optionValue;
qDebug() << "[TDLibWrapper] Setting integer option " << optionName << optionValue;
QVariantMap requestObject;
requestObject.insert("@type", "setOption");
requestObject.insert("name", optionName);
@ -238,6 +239,16 @@ void TDLibWrapper::setOptionInteger(const QString &optionName, const int &option
this->sendRequest(requestObject);
}
void TDLibWrapper::setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings)
{
qDebug() << "[TDLibWrapper] Notification settings for chat " << chatId << notificationSettings;
QVariantMap requestObject;
requestObject.insert("@type", "setChatNotificationSettings");
requestObject.insert("chat_id", chatId);
requestObject.insert("notification_settings", notificationSettings);
this->sendRequest(requestObject);
}
QVariantMap TDLibWrapper::getUserInformation()
{
return this->userInformation;

View file

@ -89,6 +89,7 @@ public:
Q_INVOKABLE void sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void getMessage(const QString &chatId, const QString &messageId);
Q_INVOKABLE void setOptionInteger(const QString &optionName, const int &optionValue);
Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings);
signals:
void versionDetected(const QString &version);

View file

@ -358,6 +358,14 @@
<source>Loading chat list...</source>
<translation>Lade Chatliste...</translation>
</message>
<message>
<source>Unmute Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mute Chat</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VideoPage</name>

View file

@ -358,6 +358,14 @@
<source>Loading chat list...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mute Chat</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VideoPage</name>