Page MenuHomePhorge

D123.1732516161.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D123.1732516161.diff

diff --git a/src/matrix-room-list.cpp b/src/matrix-room-list.cpp
--- a/src/matrix-room-list.cpp
+++ b/src/matrix-room-list.cpp
@@ -112,6 +112,8 @@
const auto &roomB = allRooms[idB];
auto aIsInvite = roomA.membership == Invite;
auto bIsInvite = roomB.membership == Invite;
+ auto aIsFavourite = roomA.tags().count("m.favourite") == 1;
+ auto bIsFavourite = roomB.tags().count("m.favourite") == 1;
if (aIsInvite != bIsInvite) {
/**
* if my membership in A is invite,
@@ -120,6 +122,8 @@
* otherwise B should come first
**/
return aIsInvite;
+ } else if (aIsFavourite != bIsFavourite) {
+ return aIsFavourite;
} else {
return latestEventTimestamp(roomA)
> latestEventTimestamp(roomB);
diff --git a/src/tests/matrix-room-list-test.cpp b/src/tests/matrix-room-list-test.cpp
--- a/src/tests/matrix-room-list-test.cpp
+++ b/src/tests/matrix-room-list-test.cpp
@@ -32,6 +32,7 @@
void testSorted();
void testSortedWithTag();
void testFilter();
+ void testPriority();
};
static auto tagEvent = Event{R"({
@@ -204,6 +205,30 @@
QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId));
}
+void MatrixRoomListTest::testPriority()
+{
+ auto model = makeTestModel();
+ RoomModel roomFavourited = makeRoom(
+ withRoomId("!favourite:tusooa.xyz")
+ | withRoomAccountData(immer::flex_vector{
+ makeEvent(withEventContent(tagEvent))}));
+ RoomModel roomInvited = makeRoom(
+ withRoomId("!invite:tusooa.xyz")
+ | withRoomMembership(RoomMembership::Invite));
+ model.client.roomList.rooms = model.client.roomList.rooms.set(
+ roomInvited.roomId, roomInvited);
+ model.client.roomList.rooms = model.client.roomList.rooms.set(
+ roomFavourited.roomId, roomFavourited);
+
+ std::unique_ptr<MatrixSdk> sdk{makeTestSdk(model)};
+ auto roomList = toUniquePtr(sdk->roomList());
+
+ QCOMPARE(roomList->count(), 3);
+ // Priority: Invite > Favourite
+ QCOMPARE(roomList->roomIdAt(0), "!invite:tusooa.xyz");
+ QCOMPARE(roomList->roomIdAt(1), "!favourite:tusooa.xyz");
+}
+
QTEST_MAIN(MatrixRoomListTest)
#include "matrix-room-list-test.moc"

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 10:29 PM (4 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39892
Default Alt Text
D123.1732516161.diff (2 KB)

Event Timeline