Refactor lastEvent
Now lastEvent() return the last event and lastActiveTime() and lastEventToString() are convenient functions to get the visual representation and the timestamp. We are also now fetching new events when the timeline is empty so that we can correctly order the rooms. In the future, we should instead probably cache the last event in an SQLite database to optimize the startup time. This also ignore state event when the configuration ask to ignore them. Fix: #97
This commit is contained in:
@@ -31,16 +31,31 @@ class NeoChatRoom : public Room
|
||||
Q_PROPERTY(int fileUploadingProgress READ fileUploadingProgress NOTIFY fileUploadingProgressChanged)
|
||||
Q_PROPERTY(QString avatarMediaId READ avatarMediaId NOTIFY avatarChanged STORED false)
|
||||
Q_PROPERTY(bool readMarkerLoaded READ readMarkerLoaded NOTIFY readMarkerLoadedChanged)
|
||||
Q_PROPERTY(QDateTime lastActiveTime READ lastActiveTime NOTIFY lastActiveTimeChanged)
|
||||
|
||||
public:
|
||||
explicit NeoChatRoom(Connection *connection, QString roomId, JoinState joinState = {});
|
||||
|
||||
[[nodiscard]] QVariantList getUsersTyping() const;
|
||||
|
||||
[[nodiscard]] QString lastEvent() const;
|
||||
bool isEventHighlighted(const Quotient::RoomEvent *e) const;
|
||||
/// Get the interesting last event.
|
||||
///
|
||||
/// This function respect the showLeaveJoinEvent setting and discard
|
||||
/// other not interesting events. This function can return an empty pointer
|
||||
/// when the room is empty of RoomMessageEvent.
|
||||
[[nodiscard]] const RoomMessageEvent *lastEvent(bool ignoreStateEvent = false) const;
|
||||
|
||||
[[nodiscard]] QDateTime lastActiveTime() const;
|
||||
/// Convenient way to get the last event but in a string format.
|
||||
///
|
||||
/// \see lastEvent
|
||||
[[nodiscard]] QString lastEventToString() const;
|
||||
|
||||
/// Convenient way to get the QDateTime of the last event.
|
||||
///
|
||||
/// \see lastEvent
|
||||
[[nodiscard]] QDateTime lastActiveTime();
|
||||
|
||||
bool isEventHighlighted(const Quotient::RoomEvent *e) const;
|
||||
|
||||
[[nodiscard]] bool hasFileUploading() const
|
||||
{
|
||||
@@ -112,6 +127,7 @@ Q_SIGNALS:
|
||||
void fileUploadingProgressChanged();
|
||||
void backgroundChanged();
|
||||
void readMarkerLoadedChanged();
|
||||
void lastActiveTimeChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
void uploadFile(const QUrl &url, const QString &body = "");
|
||||
|
||||
Reference in New Issue
Block a user