From 5700d9d17febedec690dc24193bc65607d8d9fda Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 29 Sep 2023 18:13:45 +0200 Subject: [PATCH] set read/unread TODO: sometimes there seems to be a transfer stuck on unread? --- solanaceae/tox_messages/tox_message_manager.cpp | 9 +++++++++ solanaceae/tox_messages/tox_transfer_manager.cpp | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/solanaceae/tox_messages/tox_message_manager.cpp b/solanaceae/tox_messages/tox_message_manager.cpp index fe55423..bcdb453 100644 --- a/solanaceae/tox_messages/tox_message_manager.cpp +++ b/solanaceae/tox_messages/tox_message_manager.cpp @@ -86,6 +86,9 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo reg.emplace(new_msg_e, ts); reg.emplace(new_msg_e, ts); // reactive? + // mark as read + reg.emplace(new_msg_e, ts); // reactive? + // if sent? reg.emplace(new_msg_e, ts); @@ -200,6 +203,8 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Friend_Message* e) { //reg.emplace(new_msg_e, 0); reg.emplace(new_msg_e, ts); // reactive? + reg.emplace(new_msg_e); + _rmm.throwEventConstruct(reg, new_msg_e); return false; // TODO: return true? } @@ -248,6 +253,8 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Message* e) { //reg.emplace(new_msg_e, 0); reg.emplace(new_msg_e, ts); // reactive? + reg.emplace(new_msg_e); + { // by whom auto& synced_by = reg.get_or_emplace(new_msg_e).list; synced_by.emplace(self_c); @@ -296,6 +303,8 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Private_Message* e) { //reg.emplace(new_msg_e, 0); reg.emplace(new_msg_e, ts); // reactive? + reg.emplace(new_msg_e); + // private does not track synced by _rmm.throwEventConstruct(reg, new_msg_e); diff --git a/solanaceae/tox_messages/tox_transfer_manager.cpp b/solanaceae/tox_messages/tox_transfer_manager.cpp index 997f090..14f25cc 100644 --- a/solanaceae/tox_messages/tox_transfer_manager.cpp +++ b/solanaceae/tox_messages/tox_transfer_manager.cpp @@ -125,6 +125,7 @@ Message3Handle ToxTransferManager::toxSendFilePath(const Contact3 c, uint32_t fi reg_ptr->emplace(e, c); reg_ptr->emplace(e, c_self); reg_ptr->emplace(e, ts); // reactive? + reg_ptr->emplace(e, ts); reg_ptr->emplace(e); reg_ptr->emplace(e); @@ -413,6 +414,7 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv* e) { transfer.emplace(self_c); transfer.emplace(c); transfer.emplace(ts); // reactive? + transfer.emplace(); transfer.emplace(); transfer.emplace(); @@ -503,11 +505,16 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv_Chunk* e) { transfer.remove< Message::Components::Transfer::ToxTransferFriend, // TODO: removing file a good idea? - Message::Components::Transfer::File + Message::Components::Transfer::File, + + Message::Components::Read >(); transfer.emplace(); + // re-unread a finished transfer + transfer.emplace(); + _rmm.throwEventUpdate(transfer); } else if (!transfer.all_of() || !transfer.get()->isGood()) { std::cerr << "TTM error: file not good f" << friend_number << " t" << file_number << ", closing\n";