From 2d39b1e51e500fa17788630cd0e6a57a451eb475 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 4 May 2019 08:34:18 +0900 Subject: Room::allHistoryLoaded --- lib/room.cpp | 5 +++++ lib/room.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/room.cpp b/lib/room.cpp index e363767a..2ce37acc 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -370,6 +370,11 @@ const Room::PendingEvents& Room::pendingEvents() const return d->unsyncedEvents; } +bool Room::allHistoryLoaded() const +{ + return !d->timeline.empty() && is(*d->timeline.front()); +} + QString Room::name() const { return d->getCurrentState()->name(); diff --git a/lib/room.h b/lib/room.h index db4336ea..055da3da 100644 --- a/lib/room.h +++ b/lib/room.h @@ -110,6 +110,7 @@ namespace QMatrixClient Q_PROPERTY(int unreadCount READ unreadCount NOTIFY unreadMessagesChanged) Q_PROPERTY(int highlightCount READ highlightCount NOTIFY highlightCountChanged RESET resetHighlightCount) Q_PROPERTY(int notificationCount READ notificationCount NOTIFY notificationCountChanged RESET resetNotificationCount) + Q_PROPERTY(bool allHistoryLoaded READ allHistoryLoaded NOTIFY addedMessages STORED false) Q_PROPERTY(QStringList tagNames READ tagNames NOTIFY tagsChanged) Q_PROPERTY(bool isFavourite READ isFavourite NOTIFY tagsChanged) Q_PROPERTY(bool isLowPriority READ isLowPriority NOTIFY tagsChanged) @@ -228,6 +229,14 @@ namespace QMatrixClient const Timeline& messageEvents() const; const PendingEvents& pendingEvents() const; + + /// Check whether all historical messages are already loaded + /** + * \return true if the "oldest" event in the timeline is + * a room creation event and there's no further history + * to load; false otherwise + */ + bool allHistoryLoaded() const; /** * A convenience method returning the read marker to the position * before the "oldest" event; same as messageEvents().crend() -- cgit v1.2.3