Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F116550
D9.1733021105.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
D9.1733021105.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 6:45 PM (14 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41807
Default Alt Text
D9.1733021105.diff (3 KB)
Attached To
Mode
D9: Add heroMemberEvents function to RoomModel
Attached
Detach File
Event Timeline
Log In to Comment