diff --git a/qml/form/RoomListForm.qml b/qml/form/RoomListForm.qml index 398074f..7708b2f 100644 --- a/qml/form/RoomListForm.qml +++ b/qml/form/RoomListForm.qml @@ -73,7 +73,7 @@ Item { RoleSorter { roleName: "category" }, RoleSorter { enabled: MSettings.rearrangeByActivity - roleName: "unreadCount" + roleName: "lastActiveTime" sortOrder: Qt.DescendingOrder }, StringSorter { roleName: "name" } diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index fc06720..5d7d240 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -163,6 +163,7 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const { if (role == UnreadCountRole) return room->unreadCount(); if (role == HighlightCountRole) return room->highlightCount(); if (role == LastEventRole) return room->lastEvent(); + if (role == LastActiveTimeRole) return room->lastActiveTime(); if (role == CurrentRoomRole) return QVariant::fromValue(room); return QVariant(); } @@ -196,6 +197,7 @@ QHash RoomListModel::roleNames() const { roles[UnreadCountRole] = "unreadCount"; roles[HighlightCountRole] = "highlightCount"; roles[LastEventRole] = "lastEvent"; + roles[LastActiveTimeRole] = "lastActiveTime"; roles[CurrentRoomRole] = "currentRoom"; return roles; } diff --git a/src/roomlistmodel.h b/src/roomlistmodel.h index 68fabd5..418a8fb 100644 --- a/src/roomlistmodel.h +++ b/src/roomlistmodel.h @@ -3,8 +3,8 @@ #include "connection.h" #include "events/roomevent.h" -#include "spectralroom.h" #include "room.h" +#include "spectralroom.h" #include @@ -37,6 +37,7 @@ class RoomListModel : public QAbstractListModel { UnreadCountRole, HighlightCountRole, LastEventRole, + LastActiveTimeRole, CurrentRoomRole, }; diff --git a/src/spectralroom.cpp b/src/spectralroom.cpp index 037eb9e..24cf1ac 100644 --- a/src/spectralroom.cpp +++ b/src/spectralroom.cpp @@ -140,3 +140,8 @@ void SpectralRoom::sendReply(QString userId, QString eventId, "" + sendContent}}; postJson("m.room.message", json); } + +QDateTime SpectralRoom::lastActiveTime() { + if (timelineSize() == 0) return QDateTime(); + return messageEvents().rbegin()->get()->timestamp(); +} diff --git a/src/spectralroom.h b/src/spectralroom.h index da41e0f..be0ed8d 100644 --- a/src/spectralroom.h +++ b/src/spectralroom.h @@ -35,6 +35,8 @@ class SpectralRoom : public Room { QString lastEvent(); bool isEventHighlighted(const QMatrixClient::RoomEvent* e) const; + QDateTime lastActiveTime(); + private: QString m_cachedInput; QSet highlights; @@ -59,7 +61,8 @@ class SpectralRoom : public Room { void acceptInvitation(); void forget(); void sendTypingNotification(bool isTyping); - void sendReply(QString userId, QString eventId, QString replyContent, QString sendContent); + void sendReply(QString userId, QString eventId, QString replyContent, + QString sendContent); }; #endif // SpectralRoom_H