From 365efaa5a325a11fb97b6284b7b51514acb5d6ad Mon Sep 17 00:00:00 2001 From: Nicolas Werner <nicolas.werner@hotmail.de> Date: Mon, 24 Jun 2019 16:45:42 +0200 Subject: [PATCH] Synchronize setting unread notifications --- .gdb_history | 1 + src/models/roommodel.cpp | 1 + src/models/roommodel.h | 3 +++ src/sync.cpp | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .gdb_history diff --git a/.gdb_history b/.gdb_history new file mode 100644 index 0000000..a3abe50 --- /dev/null +++ b/.gdb_history @@ -0,0 +1 @@ +exit diff --git a/src/models/roommodel.cpp b/src/models/roommodel.cpp index 2152f54..a6025e0 100644 --- a/src/models/roommodel.cpp +++ b/src/models/roommodel.cpp @@ -140,6 +140,7 @@ Room::Room(QObject *parent) { Q_UNUSED(parent); connect(this, &Room::newEvents, this, &Room::addEvents, Qt::QueuedConnection); connect(this, &Room::newTags, this, &Room::setTags, Qt::QueuedConnection); + connect(this, &Room::newUnreadState, this, &Room::setUnread, Qt::QueuedConnection); this->moveToThread(QGuiApplication::instance()->thread()); } diff --git a/src/models/roommodel.h b/src/models/roommodel.h index 7ef90ab..90d27ff 100644 --- a/src/models/roommodel.h +++ b/src/models/roommodel.h @@ -140,18 +140,21 @@ struct Room : public QAbstractListModel { emit newEvents(events, prev_batch, next_batch); } void applyTags(const std::vector<std::string> &tags) { emit setTags(tags); } + void applyUnreadNotifications(int unread) { emit newUnreadState(unread); } std::string name(); signals: void newEvents(std::vector<mtx::events::collections::TimelineEvents> events, std::string prev_batch, std::string next_batch); void newTags(std::vector<std::string> tags); + void newUnreadState(int); void roomNameChanged(QString name); public slots: void addEvents(std::vector<mtx::events::collections::TimelineEvents> events, std::string prev_batch, std::string next_batch); void setTags(std::vector<std::string> tags) { this->tags = tags; } + void setUnread(int unread) { this->unreadNotifications = unread; } void fetchOlderMessages(); void sendTextMessage(QString message); diff --git a/src/sync.cpp b/src/sync.cpp index 136d032..ca54b80 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -137,8 +137,8 @@ void Sync::sync() { } room->applyTags(tags); room->applyEvents(timeline, r.timeline.prev_batch, res.next_batch); + room->applyUnreadNotifications(r.unread_notifications.notification_count); - room->unreadNotifications = r.unread_notifications.notification_count; if (createRoom) emit newRoom(room); else -- GitLab