Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112156
D32.1732272273.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D32.1732272273.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
@@ -100,8 +100,22 @@
container.begin(),
container.end(),
[allRooms](const std::string &idA, const std::string &idB) {
- return latestEventTimestamp(allRooms[idA])
- > latestEventTimestamp(allRooms[idB]);
+ const auto &roomA = allRooms[idA];
+ const auto &roomB = allRooms[idB];
+ auto aIsInvite = roomA.membership == Invite;
+ auto bIsInvite = roomB.membership == Invite;
+ if (aIsInvite != bIsInvite) {
+ /**
+ * if my membership in A is invite,
+ * then the membership in B is not invite,
+ * so A should come first;
+ * otherwise B should come first
+ **/
+ return aIsInvite;
+ } else {
+ return latestEventTimestamp(roomA)
+ > latestEventTimestamp(roomB);
+ }
}
);
return immer::flex_vector<std::string>(container.begin(), container.end());
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
@@ -71,30 +71,42 @@
makeEvent(withEventKV("/origin_server_ts"_json_pointer, 1000)),
makeEvent(withEventKV("/origin_server_ts"_json_pointer, 2000))
})
+ | withRoomMembership(Join)
);
auto room2 = makeRoom(
withRoomTimeline({
makeEvent(withEventKV("/origin_server_ts"_json_pointer, 700)),
makeEvent(withEventKV("/origin_server_ts"_json_pointer, 1500))
})
+ | withRoomMembership(Join)
);
auto room3 = makeRoom(
withRoomTimeline({
makeEvent(withEventKV("/origin_server_ts"_json_pointer, 1500)),
makeEvent(withEventKV("/origin_server_ts"_json_pointer, 2500))
})
+ | withRoomMembership(Join)
+ );
+ auto room4 = makeRoom(
+ withRoomTimeline({
+ makeEvent(withEventKV("/origin_server_ts"_json_pointer, 300)),
+ makeEvent(withEventKV("/origin_server_ts"_json_pointer, 500))
+ })
+ | withRoomMembership(Invite)
);
withRoom(room1)(model.client);
withRoom(room2)(model.client);
withRoom(room3)(model.client);
+ withRoom(room4)(model.client);
std::unique_ptr<MatrixSdk> sdk{makeTestSdk(model)};
auto roomList = toUniquePtr(sdk->roomList());
- QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId));
- QCOMPARE(roomList->roomIdAt(1), QString::fromStdString(room1.roomId));
- QCOMPARE(roomList->roomIdAt(2), QString::fromStdString(room2.roomId));
+ QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room4.roomId));
+ QCOMPARE(roomList->roomIdAt(1), QString::fromStdString(room3.roomId));
+ QCOMPARE(roomList->roomIdAt(2), QString::fromStdString(room1.roomId));
+ QCOMPARE(roomList->roomIdAt(3), QString::fromStdString(room2.roomId));
}
void MatrixRoomListTest::testSortedWithTag()
@@ -163,8 +175,8 @@
roomList->setfilter("some");
QCOMPARE(roomList->count(), 2);
- QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room2.roomId));
- QCOMPARE(roomList->roomIdAt(1), QString::fromStdString(room1.roomId));
+ QCOMPARE(roomList->roomIds().contains(QString::fromStdString(room2.roomId)), true);
+ QCOMPARE(roomList->roomIds().contains(QString::fromStdString(room1.roomId)), true);
roomList->setfilter("!some:example.org");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 2:44 AM (11 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38796
Default Alt Text
D32.1732272273.diff (3 KB)
Attached To
Mode
D32: Display invited room at the top of RoomListView
Attached
Detach File
Event Timeline
Log In to Comment