From 1d724ef95146f2588de4bd34ffacff2244c4d68f Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 19 Apr 2024 11:00:39 +0200 Subject: [PATCH] inc version and correct the message behavior --- .../tox_contacts/tox_contact_model2.hpp | 2 +- .../tox_messages/tox_message_manager.cpp | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/solanaceae/tox_contacts/tox_contact_model2.hpp b/solanaceae/tox_contacts/tox_contact_model2.hpp index 7249b16..0af53a2 100644 --- a/solanaceae/tox_contacts/tox_contact_model2.hpp +++ b/solanaceae/tox_contacts/tox_contact_model2.hpp @@ -20,7 +20,7 @@ class ToxContactModel2 : public ContactModel3I, public ToxEventI { float _group_status_timer {0.f}; public: - static constexpr const char* version {"1"}; + static constexpr const char* version {"2"}; ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep); virtual ~ToxContactModel2(void); diff --git a/solanaceae/tox_messages/tox_message_manager.cpp b/solanaceae/tox_messages/tox_message_manager.cpp index 678bae3..96cad6e 100644 --- a/solanaceae/tox_messages/tox_message_manager.cpp +++ b/solanaceae/tox_messages/tox_message_manager.cpp @@ -74,6 +74,8 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo // get current time unix epoch utc uint64_t ts = Message::getTimeMS(); + // TODO: split into multiple messages here, if its too long ? + auto new_msg_e = reg.create(); reg.emplace(new_msg_e, c_self); reg.emplace(new_msg_e, c); @@ -93,6 +95,8 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo // if sent? reg.emplace(new_msg_e, ts); + reg.emplace(new_msg_e).ts[c_self] = ts; + if (_cr.any_of(c)) { const uint32_t friend_number = _cr.get(c).friend_number; @@ -221,6 +225,11 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Friend_Message* e) { reg.emplace(new_msg_e, ts); //reg.emplace(new_msg_e, 0); reg.emplace(new_msg_e, ts); // reactive? + { + auto& rtr = reg.emplace(new_msg_e).ts; + rtr.try_emplace(self_c, ts); + rtr.try_emplace(c, ts); + } reg.emplace(new_msg_e); @@ -312,7 +321,11 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Message* e) { reg.get_or_emplace(new_msg_e).ts.emplace(self_c, ts); } - reg.get_or_emplace(new_msg_e).ts.try_emplace(self_c, ts); + { + auto& rtr = reg.emplace(new_msg_e).ts; + rtr.try_emplace(self_c, ts); + rtr.try_emplace(c, ts); + } _rmm.throwEventConstruct(reg, new_msg_e); return false; // TODO: true? @@ -361,7 +374,11 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Private_Message* e) { // private does not track synced by // but receive state - reg.get_or_emplace(new_msg_e).ts.try_emplace(self_c, ts); + { + auto& rtr = reg.emplace(new_msg_e).ts; + rtr.try_emplace(self_c, ts); + rtr.try_emplace(c, ts); + } _rmm.throwEventConstruct(reg, new_msg_e); return false;