forgot to check contact

This commit is contained in:
Green Sky 2024-02-28 01:07:17 +01:00
parent eaa316a2aa
commit 52e95ca654
No known key found for this signature in database

View File

@ -701,12 +701,13 @@ FragmentID MessageFragmentStore::fragmentBefore(FragmentID fid) {
} }
const auto& mtsrange = fh.get<FragComp::MessagesTSRange>(); const auto& mtsrange = fh.get<FragComp::MessagesTSRange>();
const auto& m_c_id = fh.get<FragComp::MessagesContact>().id;
const auto& fuid = fh.get<FragComp::ID>(); const auto& fuid = fh.get<FragComp::ID>();
FragmentHandle current; FragmentHandle current;
auto mts_view = fh.registry()->view<FragComp::MessagesTSRange, FragComp::ID>(); auto mts_view = fh.registry()->view<FragComp::MessagesTSRange, FragComp::MessagesContact, FragComp::ID>();
for (const auto& [it_f, it_mtsrange, it_fuid] : mts_view.each()) { for (const auto& [it_f, it_mtsrange, it_m_c_id, it_fuid] : mts_view.each()) {
// before means we compare end, so we dont jump over any // before means we compare end, so we dont jump over any
if (it_mtsrange.end > mtsrange.end) { if (it_mtsrange.end > mtsrange.end) {
@ -721,6 +722,11 @@ FragmentID MessageFragmentStore::fragmentBefore(FragmentID fid) {
} }
} }
// now we check contact (might be less cheap than range check)
if (it_m_c_id.id != m_c_id) {
continue;
}
// here we know that "it" is before // here we know that "it" is before
// now we check for the largest, so the closest // now we check for the largest, so the closest
@ -756,12 +762,13 @@ FragmentID MessageFragmentStore::fragmentAfter(FragmentID fid) {
} }
const auto& mtsrange = fh.get<FragComp::MessagesTSRange>(); const auto& mtsrange = fh.get<FragComp::MessagesTSRange>();
const auto& m_c_id = fh.get<FragComp::MessagesContact>().id;
const auto& fuid = fh.get<FragComp::ID>(); const auto& fuid = fh.get<FragComp::ID>();
FragmentHandle current; FragmentHandle current;
auto mts_view = fh.registry()->view<FragComp::MessagesTSRange, FragComp::ID>(); auto mts_view = fh.registry()->view<FragComp::MessagesTSRange, FragComp::MessagesContact, FragComp::ID>();
for (const auto& [it_f, it_mtsrange, it_fuid] : mts_view.each()) { for (const auto& [it_f, it_mtsrange, it_m_c_id, it_fuid] : mts_view.each()) {
// after means we compare begin // after means we compare begin
if (it_mtsrange.begin < mtsrange.begin) { if (it_mtsrange.begin < mtsrange.begin) {
@ -777,6 +784,11 @@ FragmentID MessageFragmentStore::fragmentAfter(FragmentID fid) {
} }
} }
// now we check contact (might be less cheap than range check)
if (it_m_c_id.id != m_c_id) {
continue;
}
// here we know that "it" is after // here we know that "it" is after
// now we check for the smallest, so the closest // now we check for the smallest, so the closest
@ -834,8 +846,6 @@ bool MessageFragmentStore::onEvent(const Fragment::Events::FragmentConstruct& e)
// TODO: id lookup table, this is very inefficent // TODO: id lookup table, this is very inefficent
for (const auto& [c_it, id_it] : _cr.view<Contact::Components::ID>().each()) { for (const auto& [c_it, id_it] : _cr.view<Contact::Components::ID>().each()) {
if (frag_contact_id == id_it.data) { if (frag_contact_id == id_it.data) {
//h.emplace_or_replace<Message::Components::ContactTo>(c_it);
//return true;
frag_contact = c_it; frag_contact = c_it;
break; break;
} }
@ -850,6 +860,7 @@ bool MessageFragmentStore::onEvent(const Fragment::Events::FragmentConstruct& e)
auto* msg_reg = _rmm.get(frag_contact); auto* msg_reg = _rmm.get(frag_contact);
if (msg_reg == nullptr) { if (msg_reg == nullptr) {
// msg reg not created yet // msg reg not created yet
// TODO: this is an erroious path
return false; return false;
} }