aboutsummaryrefslogtreecommitdiff
path: root/room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-02-25 18:57:02 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-02-26 09:06:37 +0900
commitec412621d71b1a7758b15d2b3c5cd5e7b2081ab1 (patch)
tree7a79286d7c6e5a99644c3f7141e1cdc8e2459416 /room.cpp
parent7c10807549b2a73527bd594789d0e5b9ab58c874 (diff)
downloadlibquotient-ec412621d71b1a7758b15d2b3c5cd5e7b2081ab1.tar.gz
libquotient-ec412621d71b1a7758b15d2b3c5cd5e7b2081ab1.zip
Room and Connection: support room tags
Closes #134.
Diffstat (limited to 'room.cpp')
-rw-r--r--room.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/room.cpp b/room.cpp
index 762e929c..29244da2 100644
--- a/room.cpp
+++ b/room.cpp
@@ -95,6 +95,8 @@ class Room::Private
QString firstDisplayedEventId;
QString lastDisplayedEventId;
QHash<const User*, QString> lastReadEventIds;
+ QHash<QString, TagRecord> tags;
+ QHash<QString, QJsonObject> accountData;
QString prevBatch;
QPointer<RoomMessagesJob> roomMessagesJob;
@@ -552,6 +554,16 @@ void Room::resetHighlightCount()
emit highlightCountChanged(this);
}
+QStringList Room::tagNames() const
+{
+ return d->tags.keys();
+}
+
+const QHash<QString, TagRecord>& Room::tags() const
+{
+ return d->tags;
+}
+
const RoomMessageEvent*
Room::Private::getEventWithFile(const QString& eventId) const
{
@@ -873,6 +885,15 @@ void Room::updateData(SyncRoomData&& data)
<< et.elapsed() << "ms";
}
+ if (!data.accountData.empty())
+ {
+ et.restart();
+ for (auto&& event: data.accountData)
+ processAccountDataEvent(move(event));
+ qCDebug(PROFILER) << "*** Room::processAccountData():"
+ << et.elapsed() << "ms";
+ }
+
if( data.highlightCount != d->highlightCount )
{
d->highlightCount = data.highlightCount;
@@ -1433,6 +1454,19 @@ void Room::processEphemeralEvent(EventPtr event)
}
}
+void Room::processAccountDataEvent(EventPtr event)
+{
+ switch (event->type())
+ {
+ case EventType::Tag:
+ d->tags = static_cast<TagEvent*>(event.get())->tags();
+ emit tagsChanged();
+ break;
+ default:
+ d->accountData[event->jsonType()] = event->contentJson();
+ }
+}
+
QString Room::Private::roomNameFromMemberNames(const QList<User *> &userlist) const
{
// This is part 3(i,ii,iii) in the room displayname algorithm described