Page MenuHomePhorge

D9.1732552480.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D9.1732552480.diff

diff --git a/src/client/room/room-model.hpp b/src/client/room/room-model.hpp
--- a/src/client/room/room-model.hpp
+++ b/src/client/room/room-model.hpp
@@ -202,6 +202,7 @@
EventList knockedMemberEvents() const;
EventList leftMemberEvents() const;
EventList bannedMemberEvents() const;
+ EventList heroMemberEvents() const;
MegOlmSessionRotateDesc sessionRotateDesc() const;
diff --git a/src/client/room/room-model.cpp b/src/client/room/room-model.cpp
--- a/src/client/room/room-model.cpp
+++ b/src/client/room/room-model.cpp
@@ -331,6 +331,23 @@
return memberEventsByMembership(stateEvents, "ban"s);
}
+ EventList RoomModel::heroMemberEvents() const
+ {
+ return intoImmer(
+ EventList{},
+ zug::filter([heroIds=heroIds](auto val) {
+ auto [k, ev] = val;
+ auto [type, stateKey] = k;
+ return type == "m.room.member"s &&
+ std::find(heroIds.begin(), heroIds.end(), stateKey) != heroIds.end();
+ })
+ | zug::map([](auto val) {
+ auto [_, ev] = val;
+ return ev;
+ }),
+ stateEvents);
+ }
+
static Timestamp defaultRotateMs = 604800000;
static int defaultRotateMsgs = 100;
diff --git a/src/client/room/room.cpp b/src/client/room/room.cpp
--- a/src/client/room/room.cpp
+++ b/src/client/room/room.cpp
@@ -217,18 +217,7 @@
auto Room::heroMemberEvents() const -> lager::reader<immer::flex_vector<Event>>
{
using namespace lager::lenses;
- auto idsCursor = heroIds();
- lager::reader<immer::map<KeyOfState, Event>> statesCursor = stateEvents();
-
- return lager::with(idsCursor, statesCursor)
- .xform(zug::map([](const auto &ids, const auto &states) {
- return intoImmer(
- immer::flex_vector<Event>{},
- zug::map([states](const auto &id) {
- return states[{"m.room.member", id}];
- }),
- ids);
- }));
+ return roomCursor().map(&RoomModel::heroMemberEvents);
}
auto Room::heroDisplayNames() const
diff --git a/src/tests/client/room-test.cpp b/src/tests/client/room-test.cpp
--- a/src/tests/client/room-test.cpp
+++ b/src/tests/client/room-test.cpp
@@ -184,7 +184,20 @@
TEST_CASE("Room::heroMemberEvents()", "[client][room][getter]")
{
- auto room = makeRoomWithDumbContext(exampleRoomWithNameEvent());
+ auto r = exampleRoomWithNameEvent();
+ {
+ auto val = r.heroMemberEvents();
+ REQUIRE(val.size() == 2);
+ REQUIRE(std::any_of(val.begin(), val.end(),
+ [](const auto &v) {
+ return v.id() == "some id2";
+ }));
+ REQUIRE(std::any_of(val.begin(), val.end(),
+ [](const auto &v) {
+ return v.id() == "some id3";
+ }));
+ }
+ auto room = makeRoomWithDumbContext(r);
THEN("it should give out the events") {
auto val = room.heroMemberEvents().make().get();
REQUIRE(val.size() == 2);

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 8:34 AM (11 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39305
Default Alt Text
D9.1732552480.diff (3 KB)

Event Timeline