diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-11-18 20:18:10 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-11-19 08:35:37 +0900 |
commit | 82c78b63cdd093853fd058740e7038e3c8a1cbbd (patch) | |
tree | 0d85b8356a7075fd5e86ceba0af256dec32db719 | |
parent | e9d72c469b4c9a2246a086e4c47d80fe7d011179 (diff) | |
download | libquotient-82c78b63cdd093853fd058740e7038e3c8a1cbbd.tar.gz libquotient-82c78b63cdd093853fd058740e7038e3c8a1cbbd.zip |
Room: expose eventsHistoryJob as a Q_PROPERTY
-rw-r--r-- | lib/room.cpp | 9 | ||||
-rw-r--r-- | lib/room.h | 6 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 6777732b..4bd96fc3 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -25,7 +25,6 @@ #include "csapi/receipts.h" #include "csapi/redaction.h" #include "csapi/account-data.h" -#include "csapi/message_pagination.h" #include "csapi/room_state.h" #include "csapi/room_send.h" #include "csapi/tags.h" @@ -975,6 +974,11 @@ bool Room::usesEncryption() const return !d->getCurrentState<EncryptionEvent>()->algorithm().isEmpty(); } +GetRoomEventsJob* Room::eventsHistoryJob() const +{ + return d->eventsHistoryJob; +} + void Room::Private::insertMemberIntoMap(User *u) { const auto userName = u->name(q); @@ -1393,10 +1397,13 @@ void Room::Private::getPreviousContent(int limit) { eventsHistoryJob = connection->callApi<GetRoomEventsJob>(id, prevBatch, "b", "", limit); + emit q->eventsHistoryJobChanged(); connect( eventsHistoryJob, &BaseJob::success, q, [=] { prevBatch = eventsHistoryJob->end(); addHistoricalMessageEvents(eventsHistoryJob->chunk()); }); + connect( eventsHistoryJob, &QObject::destroyed, + q, &Room::eventsHistoryJobChanged); } } @@ -19,6 +19,7 @@ #pragma once #include "jobs/syncjob.h" +#include "csapi/message_pagination.h" #include "events/roommessageevent.h" #include "events/accountdataevents.h" #include "eventitem.h" @@ -95,6 +96,8 @@ namespace QMatrixClient Q_PROPERTY(bool isFavourite READ isFavourite NOTIFY tagsChanged) Q_PROPERTY(bool isLowPriority READ isLowPriority NOTIFY tagsChanged) + Q_PROPERTY(GetRoomEventsJob* eventsHistoryJob READ eventsHistoryJob NOTIFY eventsHistoryJobChanged) + public: using Timeline = std::deque<TimelineItem>; using PendingEvents = std::vector<PendingEventItem>; @@ -126,6 +129,8 @@ namespace QMatrixClient int timelineSize() const; bool usesEncryption() const; + GetRoomEventsJob* eventsHistoryJob() const; + /** * Returns a square room avatar with the given size and requests it * from the network if needed @@ -364,6 +369,7 @@ namespace QMatrixClient void markAllMessagesAsRead(); signals: + void eventsHistoryJobChanged(); void aboutToAddHistoricalMessages(RoomEventsRange events); void aboutToAddNewMessages(RoomEventsRange events); void addedMessages(int fromIndex, int toIndex); |