aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-09-30 13:18:46 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-09-30 13:18:46 +0900
commit2c7f3f2a15afcdd7d5200757daa6629239593e02 (patch)
tree1ff05d7d112565b0422e876cb734b81dfe4aa27e
parent4e3703a45fcff6433441482892cfb14fd9bd8a7c (diff)
downloadlibquotient-2c7f3f2a15afcdd7d5200757daa6629239593e02.tar.gz
libquotient-2c7f3f2a15afcdd7d5200757daa6629239593e02.zip
Room: use csapi/tags.h; fix tagsChanged() double-emission
Instead of overwriting the entire set of tags even on single-tag operations, SetRoomTagJob and DeleteRoomTagJob are used now. (Room::setTags() still uses SetRoomAccountDataJob).
-rw-r--r--lib/room.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 2e409124..f41fe12c 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -28,6 +28,7 @@
#include "csapi/message_pagination.h"
#include "csapi/room_state.h"
#include "csapi/room_send.h"
+#include "csapi/tags.h"
#include "events/simplestateevents.h"
#include "events/roomavatarevent.h"
#include "events/roommemberevent.h"
@@ -239,13 +240,6 @@ class Room::Private
bool processRedaction(const RedactionEvent& redaction);
void setTags(TagsMap newTags);
- void sendTagUpdates()
- {
- connection->callApi<SetAccountDataPerRoomJob>(
- connection->userId(), id, TagEvent::matrixTypeId(),
- TagEvent(tags).contentJson());
- emit q->tagsChanged();
- }
QJsonObject toJson() const;
@@ -723,7 +717,8 @@ void Room::addTag(const QString& name, const TagRecord& record)
emit tagsAboutToChange();
d->tags.insert(checkRes.second, record);
emit tagsChanged();
- d->sendTagUpdates();
+ connection()->callApi<SetRoomTagJob>(localUser()->id(), id(),
+ checkRes.second, record.order);
}
void Room::addTag(const QString& name, TagRecord::order_type order)
@@ -738,7 +733,7 @@ void Room::removeTag(const QString& name)
emit tagsAboutToChange();
d->tags.remove(name);
emit tagsChanged();
- d->sendTagUpdates();
+ connection()->callApi<DeleteRoomTagJob>(localUser()->id(), id(), name);
} else if (!name.startsWith("u."))
removeTag("u." + name);
else
@@ -749,7 +744,9 @@ void Room::removeTag(const QString& name)
void Room::setTags(TagsMap newTags)
{
d->setTags(move(newTags));
- d->sendTagUpdates();
+ connection()->callApi<SetAccountDataPerRoomJob>(
+ localUser()->id(), id(), TagEvent::matrixTypeId(),
+ TagEvent(d->tags).contentJson());
}
void Room::Private::setTags(TagsMap newTags)