adopt comp name changes

This commit is contained in:
Green Sky 2024-04-20 13:47:54 +02:00
parent 1d724ef951
commit 560eab1f6c
No known key found for this signature in database
2 changed files with 22 additions and 5 deletions

View File

@ -95,7 +95,7 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
// if sent? // if sent?
reg.emplace<Message::Components::TimestampProcessed>(new_msg_e, ts); reg.emplace<Message::Components::TimestampProcessed>(new_msg_e, ts);
reg.emplace<Message::Components::Remote::TimestampReceived>(new_msg_e).ts[c_self] = ts; reg.emplace<Message::Components::ReceivedBy>(new_msg_e).ts[c_self] = ts;
if (_cr.any_of<Contact::Components::ToxFriendEphemeral>(c)) { if (_cr.any_of<Contact::Components::ToxFriendEphemeral>(c)) {
const uint32_t friend_number = _cr.get<Contact::Components::ToxFriendEphemeral>(c).friend_number; const uint32_t friend_number = _cr.get<Contact::Components::ToxFriendEphemeral>(c).friend_number;
@ -226,7 +226,7 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Friend_Message* e) {
//reg.emplace<Components::TimestampWritten>(new_msg_e, 0); //reg.emplace<Components::TimestampWritten>(new_msg_e, 0);
reg.emplace<Message::Components::Timestamp>(new_msg_e, ts); // reactive? reg.emplace<Message::Components::Timestamp>(new_msg_e, ts); // reactive?
{ {
auto& rtr = reg.emplace<Message::Components::Remote::TimestampReceived>(new_msg_e).ts; auto& rtr = reg.emplace<Message::Components::ReceivedBy>(new_msg_e).ts;
rtr.try_emplace(self_c, ts); rtr.try_emplace(self_c, ts);
rtr.try_emplace(c, ts); rtr.try_emplace(c, ts);
} }
@ -261,7 +261,7 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Friend_Read_Receipt* e) {
for (const auto& [m, msg_id_comp] : reg.view<Message::Components::ToxFriendMessageID>().each()) { for (const auto& [m, msg_id_comp] : reg.view<Message::Components::ToxFriendMessageID>().each()) {
if (msg_id_comp.id == msg_id) { if (msg_id_comp.id == msg_id) {
// found it // found it
auto& rtr = reg.get_or_emplace<Message::Components::Remote::TimestampReceived>(m); auto& rtr = reg.get_or_emplace<Message::Components::ReceivedBy>(m);
// insert but dont overwrite // insert but dont overwrite
rtr.ts.try_emplace(c, ts); rtr.ts.try_emplace(c, ts);
break; break;
@ -322,7 +322,7 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Message* e) {
} }
{ {
auto& rtr = reg.emplace<Message::Components::Remote::TimestampReceived>(new_msg_e).ts; auto& rtr = reg.emplace<Message::Components::ReceivedBy>(new_msg_e).ts;
rtr.try_emplace(self_c, ts); rtr.try_emplace(self_c, ts);
rtr.try_emplace(c, ts); rtr.try_emplace(c, ts);
} }
@ -375,7 +375,7 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Private_Message* e) {
// private does not track synced by // private does not track synced by
// but receive state // but receive state
{ {
auto& rtr = reg.emplace<Message::Components::Remote::TimestampReceived>(new_msg_e).ts; auto& rtr = reg.emplace<Message::Components::ReceivedBy>(new_msg_e).ts;
rtr.try_emplace(self_c, ts); rtr.try_emplace(self_c, ts);
rtr.try_emplace(c, ts); rtr.try_emplace(c, ts);
} }
@ -383,3 +383,4 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Private_Message* e) {
_rmm.throwEventConstruct(reg, new_msg_e); _rmm.throwEventConstruct(reg, new_msg_e);
return false; return false;
} }

View File

@ -126,6 +126,7 @@ Message3Handle ToxTransferManager::toxSendFilePath(const Contact3 c, uint32_t fi
reg_ptr->emplace<Message::Components::ContactFrom>(e, c_self); reg_ptr->emplace<Message::Components::ContactFrom>(e, c_self);
reg_ptr->emplace<Message::Components::Timestamp>(e, ts); // reactive? reg_ptr->emplace<Message::Components::Timestamp>(e, ts); // reactive?
reg_ptr->emplace<Message::Components::Read>(e, ts); reg_ptr->emplace<Message::Components::Read>(e, ts);
reg_ptr->emplace<Message::Components::ReceivedBy>(e).ts.try_emplace(c_self, ts);
reg_ptr->emplace<Message::Components::Transfer::TagHaveAll>(e); reg_ptr->emplace<Message::Components::Transfer::TagHaveAll>(e);
reg_ptr->emplace<Message::Components::Transfer::TagSending>(e); reg_ptr->emplace<Message::Components::Transfer::TagSending>(e);
@ -472,6 +473,12 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv* e) {
transfer.emplace<Message::Components::Timestamp>(ts); // reactive? transfer.emplace<Message::Components::Timestamp>(ts); // reactive?
transfer.emplace<Message::Components::TagUnread>(); transfer.emplace<Message::Components::TagUnread>();
{
auto& rb = transfer.emplace<Message::Components::ReceivedBy>().ts;
//rb.try_emplace(self_c, ts); // only on completion
rb.try_emplace(c, ts);
}
transfer.emplace<Message::Components::Transfer::TagReceiving>(); transfer.emplace<Message::Components::Transfer::TagReceiving>();
transfer.emplace<Message::Components::Transfer::TagPaused>(); transfer.emplace<Message::Components::Transfer::TagPaused>();
transfer.emplace<Message::Components::Transfer::ToxTransferFriend>(friend_number, file_number); transfer.emplace<Message::Components::Transfer::ToxTransferFriend>(friend_number, file_number);
@ -551,6 +558,8 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv_Chunk* e) {
} }
if (data_size == 0) { if (data_size == 0) {
uint64_t ts = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
std::cout << "TTM finished friend " << friend_number << " transfer " << file_number << ", closing\n"; std::cout << "TTM finished friend " << friend_number << " transfer " << file_number << ", closing\n";
// update lookup table // update lookup table
@ -564,6 +573,13 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv_Chunk* e) {
Message::Components::Read Message::Components::Read
>(); >();
auto c = _tcm.getContactFriend(friend_number);
if (static_cast<bool>(c)) {
auto self_c = _cr.get<Contact::Components::Self>(c).self;
auto& rb = transfer.get_or_emplace<Message::Components::ReceivedBy>().ts;
rb.try_emplace(self_c, ts); // on completion
}
transfer.emplace<Message::Components::Transfer::TagHaveAll>(); transfer.emplace<Message::Components::Transfer::TagHaveAll>();
// re-unread a finished transfer // re-unread a finished transfer