set read/unread

TODO: sometimes there seems to be a transfer stuck on unread?
This commit is contained in:
Green Sky 2023-09-29 18:13:45 +02:00
parent dd596bdad8
commit 5700d9d17f
No known key found for this signature in database
2 changed files with 17 additions and 1 deletions

View File

@ -86,6 +86,9 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
reg.emplace<Message::Components::TimestampWritten>(new_msg_e, ts);
reg.emplace<Message::Components::Timestamp>(new_msg_e, ts); // reactive?
// mark as read
reg.emplace<Message::Components::Read>(new_msg_e, ts); // reactive?
// if sent?
reg.emplace<Message::Components::TimestampProcessed>(new_msg_e, ts);
@ -200,6 +203,8 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Friend_Message* e) {
//reg.emplace<Components::TimestampWritten>(new_msg_e, 0);
reg.emplace<Message::Components::Timestamp>(new_msg_e, ts); // reactive?
reg.emplace<Message::Components::TagUnread>(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<Components::TimestampWritten>(new_msg_e, 0);
reg.emplace<Message::Components::Timestamp>(new_msg_e, ts); // reactive?
reg.emplace<Message::Components::TagUnread>(new_msg_e);
{ // by whom
auto& synced_by = reg.get_or_emplace<Message::Components::SyncedBy>(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<Components::TimestampWritten>(new_msg_e, 0);
reg.emplace<Message::Components::Timestamp>(new_msg_e, ts); // reactive?
reg.emplace<Message::Components::TagUnread>(new_msg_e);
// private does not track synced by
_rmm.throwEventConstruct(reg, new_msg_e);

View File

@ -125,6 +125,7 @@ Message3Handle ToxTransferManager::toxSendFilePath(const Contact3 c, uint32_t fi
reg_ptr->emplace<Message::Components::ContactTo>(e, c);
reg_ptr->emplace<Message::Components::ContactFrom>(e, c_self);
reg_ptr->emplace<Message::Components::Timestamp>(e, ts); // reactive?
reg_ptr->emplace<Message::Components::Read>(e, ts);
reg_ptr->emplace<Message::Components::Transfer::TagHaveAll>(e);
reg_ptr->emplace<Message::Components::Transfer::TagSending>(e);
@ -413,6 +414,7 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv* e) {
transfer.emplace<Message::Components::ContactTo>(self_c);
transfer.emplace<Message::Components::ContactFrom>(c);
transfer.emplace<Message::Components::Timestamp>(ts); // reactive?
transfer.emplace<Message::Components::TagUnread>();
transfer.emplace<Message::Components::Transfer::TagReceiving>();
transfer.emplace<Message::Components::Transfer::TagPaused>();
@ -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<Message::Components::Transfer::TagHaveAll>();
// re-unread a finished transfer
transfer.emplace<Message::Components::TagUnread>();
_rmm.throwEventUpdate(transfer);
} else if (!transfer.all_of<Message::Components::Transfer::File>() || !transfer.get<Message::Components::Transfer::File>()->isGood()) {
std::cerr << "TTM error: file not good f" << friend_number << " t" << file_number << ", closing\n";