From 046b3f4da6e5b8eec92bd0895048a4df2e916285 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 18 Jul 2020 20:39:31 +0200 Subject: [PATCH] Mark own events as read again after sending --- src/timeline/EventStore.cpp | 15 ++++++++++++--- src/timeline/EventStore.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index b7cf4f96..80e8d474 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -91,7 +91,7 @@ EventStore::EventStore(std::string room_id, QObject *) room_id_, txn_id, e.content, - [this, txn_id](const mtx::responses::EventId &, + [this, txn_id](const mtx::responses::EventId &event_id, mtx::http::RequestErr err) { if (err) { const int status_code = @@ -104,7 +104,7 @@ EventStore::EventStore(std::string room_id, QObject *) emit messageFailed(txn_id); return; } - emit messageSent(txn_id); + emit messageSent(txn_id, event_id.event_id.to_string()); }); }, event->data); @@ -135,8 +135,17 @@ EventStore::EventStore(std::string room_id, QObject *) this, &EventStore::messageSent, this, - [this](std::string txn_id) { + [this](std::string txn_id, std::string event_id) { nhlog::ui()->debug("sent {}", txn_id); + + http::client()->read_event( + room_id_, event_id, [this, event_id](mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn( + "failed to read_event ({}, {})", room_id_, event_id); + } + }); + cache::client()->removePendingStatus(room_id_, txn_id); this->current_txn = ""; this->current_txn_error_count = 0; diff --git a/src/timeline/EventStore.h b/src/timeline/EventStore.h index b4d5bb23..3a78cba8 100644 --- a/src/timeline/EventStore.h +++ b/src/timeline/EventStore.h @@ -91,7 +91,7 @@ signals: void fetchedMore(); void processPending(); - void messageSent(std::string txn_id); + void messageSent(std::string txn_id, std::string event_id); void messageFailed(std::string txn_id); public slots: