diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-03 21:23:28 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-03 22:47:43 +0900 |
commit | 564d518c086f2aeab0f0466b7cd1915e20edc7da (patch) | |
tree | f7e704855739b80728e51eb8187a932b3df78b73 /lib/user.cpp | |
parent | d304c1b9ac7a86096899b459eba8e36ed310b6ce (diff) | |
download | libquotient-564d518c086f2aeab0f0466b7cd1915e20edc7da.tar.gz libquotient-564d518c086f2aeab0f0466b7cd1915e20edc7da.zip |
GetRoomEventsJob (replaces RoomMessagesJob) + refactoring
1. Updates in this commit (see further) allow to generate and build
GetRoomEventsJob from message_pagination.yaml; this job completely
preempts RoomMessagesJob.
2. EventsBatch<> is no more a thing; there's EventsArray<> to replace it
but it's loaded from a JSON array rather than an event batch (a JSON
array inside another JSON object). SyncJob that used it extensively has
been moved to "conventional" containers (Events, RoomEvents and the
newly introduced StateEvents). RoomMessagesJob that also used
EventsBatch<> is decommissioned (see above).
3. RoomEventsRange is now an alias for Range<RoomEvents>, defined in
util.h (otherwise almost the same).
4. Connection::getMessages() is no more. Use Room::getPreviousContent()
and Connection::callApi<GetRooMEventsJob>() instead.
5. Moving things around in Room, since SyncJob now supplies state events
in more specific StateEvents, rather than RoomEvents.
Diffstat (limited to 'lib/user.cpp')
-rw-r--r-- | lib/user.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/user.cpp b/lib/user.cpp index 91b340d5..89e324f9 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -358,19 +358,20 @@ QUrl User::avatarUrl(const Room* room) const return avatarObject(room).url(); } -void User::processEvent(const RoomMemberEvent* event, const Room* room) +void User::processEvent(const RoomMemberEvent& event, const Room* room) { - if (event->membership() != MembershipType::Invite && - event->membership() != MembershipType::Join) + Q_ASSERT(room); + if (event.membership() != MembershipType::Invite && + event.membership() != MembershipType::Join) return; auto aboutToEnter = room->memberJoinState(this) == JoinState::Leave && - (event->membership() == MembershipType::Join || - event->membership() == MembershipType::Invite); + (event.membership() == MembershipType::Join || + event.membership() == MembershipType::Invite); if (aboutToEnter) ++d->totalRooms; - auto newName = event->displayName(); + auto newName = event.displayName(); // `bridged` value uses the same notification signal as the name; // it is assumed that first setting of the bridge occurs together with // the first setting of the name, and further bridge updates are @@ -390,17 +391,17 @@ void User::processEvent(const RoomMemberEvent* event, const Room* room) } newName.truncate(match.capturedStart(0)); } - if (event->prevContent()) + if (event.prevContent()) { // FIXME: the hint doesn't work for bridged users auto oldNameHint = - d->nameForRoom(room, event->prevContent()->displayName); + d->nameForRoom(room, event.prevContent()->displayName); updateName(newName, oldNameHint, room); - updateAvatarUrl(event->avatarUrl(), - d->avatarUrlForRoom(room, event->prevContent()->avatarUrl), + updateAvatarUrl(event.avatarUrl(), + d->avatarUrlForRoom(room, event.prevContent()->avatarUrl), room); } else { updateName(newName, room); - updateAvatarUrl(event->avatarUrl(), d->avatarUrlForRoom(room), room); + updateAvatarUrl(event.avatarUrl(), d->avatarUrlForRoom(room), room); } } |