0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

modules/client/rooms/members: Move prefetching ahead of responses; optimize prefetched key.

This commit is contained in:
Jason Volk 2023-02-11 13:07:18 -08:00
parent b106fe4c9d
commit d1c3570e04

View file

@ -79,26 +79,6 @@ get__members(client &client,
string_view{room_id}
};
m::resource::response::chunked response
{
client, http::OK
};
json::stack out
{
response.buf, response.flusher()
};
json::stack::object top
{
out
};
json::stack::array chunk
{
top, "chunk"
};
const m::room::members members
{
room
@ -148,6 +128,26 @@ get__members(client &client,
});
// stream to client
m::resource::response::chunked response
{
client, http::OK
};
json::stack out
{
response.buf, response.flusher()
};
json::stack::object top
{
out
};
json::stack::array chunk
{
top, "chunk"
};
m::event::fetch event;
members.for_each(membership, [&membership, &membership_match, &at_idx, &chunk, &event]
(const m::user::id &member, const m::event::idx &event_idx)
@ -192,6 +192,20 @@ get__joined_members(client &client,
string_view{room_id}
};
const m::room::members members
{
room
};
// prefetch loop
members.for_each("join", []
(const m::user::id &user_id, const m::event::idx &event_idx)
{
m::prefetch(event_idx, "content");
return true;
});
// stream to client
m::resource::response::chunked response
{
client, http::OK
@ -212,18 +226,6 @@ get__joined_members(client &client,
top, "joined"
};
const m::room::members members
{
room
};
members.for_each("join", []
(const m::user::id &user_id, const m::event::idx &event_idx)
{
m::prefetch(event_idx);
return true;
});
members.for_each("join", [&joined, &room]
(const m::user::id &user_id, const m::event::idx &event_idx)
{