diff --git a/src/chat_gui/contact_list_sorter.cpp b/src/chat_gui/contact_list_sorter.cpp index e58e03c..549dad4 100644 --- a/src/chat_gui/contact_list_sorter.cpp +++ b/src/chat_gui/contact_list_sorter.cpp @@ -2,6 +2,8 @@ #include +#include + ContactListSorter::comperator_fn ContactListSorter::getSortGroupsOverPrivates(void) { return [](const ContactRegistry4& cr, const Contact4 lhs, const Contact4 rhs) -> std::optional { @@ -97,8 +99,8 @@ ContactListSorter::~ContactListSorter(void) { } void ContactListSorter::sort(void) { - // TODO: timer - if (!_dirty) { + const uint64_t now = getTimeMS(); + if ((now > _last_sort && now - _last_sort < 1000*29) && !_dirty) { return; } @@ -119,6 +121,7 @@ void ContactListSorter::sort(void) { entt::insertion_sort{} // o(n) in >90% of cases ); + _last_sort = now; _dirty = false; } diff --git a/src/chat_gui/contact_list_sorter.hpp b/src/chat_gui/contact_list_sorter.hpp index 5505e0b..82f866c 100644 --- a/src/chat_gui/contact_list_sorter.hpp +++ b/src/chat_gui/contact_list_sorter.hpp @@ -30,6 +30,7 @@ class ContactListSorter : public ContactStore4EventI { ContactStore4I::SubscriptionReference _cs_sr; std::vector _sort_stack; + uint64_t _last_sort {0}; bool _dirty {true}; // TODO: timer, to guarantie a sort ever X seconds? // (turns out we dont throw on new messages <.<)