mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 16:46:50 +01:00
modules/client/rooms/members: Move prefetching ahead of responses; optimize prefetched key.
This commit is contained in:
parent
b106fe4c9d
commit
d1c3570e04
1 changed files with 34 additions and 32 deletions
|
@ -79,26 +79,6 @@ get__members(client &client,
|
||||||
string_view{room_id}
|
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
|
const m::room::members members
|
||||||
{
|
{
|
||||||
room
|
room
|
||||||
|
@ -148,6 +128,26 @@ get__members(client &client,
|
||||||
});
|
});
|
||||||
|
|
||||||
// stream to 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;
|
m::event::fetch event;
|
||||||
members.for_each(membership, [&membership, &membership_match, &at_idx, &chunk, &event]
|
members.for_each(membership, [&membership, &membership_match, &at_idx, &chunk, &event]
|
||||||
(const m::user::id &member, const m::event::idx &event_idx)
|
(const m::user::id &member, const m::event::idx &event_idx)
|
||||||
|
@ -192,6 +192,20 @@ get__joined_members(client &client,
|
||||||
string_view{room_id}
|
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
|
m::resource::response::chunked response
|
||||||
{
|
{
|
||||||
client, http::OK
|
client, http::OK
|
||||||
|
@ -212,18 +226,6 @@ get__joined_members(client &client,
|
||||||
top, "joined"
|
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]
|
members.for_each("join", [&joined, &room]
|
||||||
(const m::user::id &user_id, const m::event::idx &event_idx)
|
(const m::user::id &user_id, const m::event::idx &event_idx)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue