mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 11:18:51 +02:00
ircd:Ⓜ️:user::notifications: Improve iteration with room::type.
This commit is contained in:
parent
31fd7e664f
commit
d1f9b11b4c
1 changed files with 14 additions and 19 deletions
|
@ -53,7 +53,6 @@ const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: XXX optimize
|
|
||||||
bool
|
bool
|
||||||
ircd::m::user::notifications::for_each(const opts &opts,
|
ircd::m::user::notifications::for_each(const opts &opts,
|
||||||
const closure_bool &closure)
|
const closure_bool &closure)
|
||||||
|
@ -70,31 +69,27 @@ const
|
||||||
make_type(type_buf, opts)
|
make_type(type_buf, opts)
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto type_match{[&type](const auto &_type)
|
const room::type events
|
||||||
{
|
{
|
||||||
return _type == type;
|
user_room, type
|
||||||
}};
|
|
||||||
|
|
||||||
m::room::events it
|
|
||||||
{
|
|
||||||
user_room
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if(opts.from)
|
return events.for_each([&opts, &closure]
|
||||||
it.seek_idx(opts.from);
|
(const auto &type, const auto &depth, const auto &event_idx)
|
||||||
|
|
||||||
bool ret(true);
|
|
||||||
for(; it && ret && it.event_idx() > opts.to; --it) //TODO: XXX optimize
|
|
||||||
{
|
{
|
||||||
if(!m::query(std::nothrow, it.event_idx(), "type", type_match))
|
if(opts.from && event_idx > opts.from) //TODO: XXX
|
||||||
continue;
|
return true;
|
||||||
|
|
||||||
m::get(std::nothrow, it.event_idx(), "content", [&ret, &it, &closure]
|
if(opts.to && event_idx <= opts.to) //TODO: XXX
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool ret{true};
|
||||||
|
m::get(std::nothrow, event_idx, "content", [&ret, &closure, &event_idx]
|
||||||
(const json::object &content)
|
(const json::object &content)
|
||||||
{
|
{
|
||||||
ret = closure(it.event_idx(), content);
|
ret = closure(event_idx, content);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue