Page MenuHomePhorge

D32.1732272265.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D32.1732272265.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
@@ -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()

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 2:44 AM (12 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38815
Default Alt Text
D32.1732272265.diff (3 KB)

Event Timeline