Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112318
D123.1732292637.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D123.1732292637.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 8:23 AM (39 m, 24 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38844
Default Alt Text
D123.1732292637.diff (2 KB)
Attached To
Mode
D123: Show favourite rooms at the top
Attached
Detach File
Event Timeline
Log In to Comment