We need chat information in notification manager

This commit is contained in:
Sebastian J. Wolf 2020-09-02 23:05:09 +02:00
parent aa3a841fee
commit 9f708080c8
2 changed files with 13 additions and 0 deletions

View file

@ -27,6 +27,7 @@ NotificationManager::NotificationManager(TDLibWrapper *tdLibWrapper, QObject *pa
connect(this->tdLibWrapper, SIGNAL(activeNotificationsUpdated(QVariantList)), this, SLOT(handleUpdateActiveNotifications(QVariantList))); connect(this->tdLibWrapper, SIGNAL(activeNotificationsUpdated(QVariantList)), this, SLOT(handleUpdateActiveNotifications(QVariantList)));
connect(this->tdLibWrapper, SIGNAL(notificationGroupUpdated(QVariantMap)), this, SLOT(handleUpdateNotificationGroup(QVariantMap))); connect(this->tdLibWrapper, SIGNAL(notificationGroupUpdated(QVariantMap)), this, SLOT(handleUpdateNotificationGroup(QVariantMap)));
connect(this->tdLibWrapper, SIGNAL(notificationUpdated(QVariantMap)), this, SLOT(handleUpdateNotification(QVariantMap))); connect(this->tdLibWrapper, SIGNAL(notificationUpdated(QVariantMap)), this, SLOT(handleUpdateNotification(QVariantMap)));
connect(this->tdLibWrapper, SIGNAL(newChatDiscovered(QString, QVariantMap)), this, SLOT(handleChatDiscovered(QString, QVariantMap)));
} }
NotificationManager::~NotificationManager() NotificationManager::~NotificationManager()
@ -48,3 +49,11 @@ void NotificationManager::handleUpdateNotification(const QVariantMap updatedNoti
{ {
qDebug() << "[NotificationManager] Received notification update, group ID:" << updatedNotification.value("notification_group_id").toInt(); qDebug() << "[NotificationManager] Received notification update, group ID:" << updatedNotification.value("notification_group_id").toInt();
} }
void NotificationManager::handleChatDiscovered(const QString &chatId, const QVariantMap &chatInformation)
{
this->chatListMutex.lock();
qDebug() << "[NotificationManager] Adding chat to internal map " << chatId;
this->chatMap.insert(chatId, chatInformation);
this->chatListMutex.unlock();
}

View file

@ -21,6 +21,7 @@
#define NOTIFICATIONMANAGER_H #define NOTIFICATIONMANAGER_H
#include <QObject> #include <QObject>
#include <QMutex>
#include "tdlibwrapper.h" #include "tdlibwrapper.h"
@ -38,10 +39,13 @@ public slots:
void handleUpdateActiveNotifications(const QVariantList notificationGroups); void handleUpdateActiveNotifications(const QVariantList notificationGroups);
void handleUpdateNotificationGroup(const QVariantMap notificationGroupUpdate); void handleUpdateNotificationGroup(const QVariantMap notificationGroupUpdate);
void handleUpdateNotification(const QVariantMap updatedNotification); void handleUpdateNotification(const QVariantMap updatedNotification);
void handleChatDiscovered(const QString &chatId, const QVariantMap &chatInformation);
private: private:
TDLibWrapper *tdLibWrapper; TDLibWrapper *tdLibWrapper;
QVariantMap chatMap;
QMutex chatListMutex;
}; };