summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/EventAccessors.cpp20
-rw-r--r--src/EventAccessors.h2
-rw-r--r--src/timeline/TimelineModel.cpp14
3 files changed, 36 insertions, 0 deletions
diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp

index 6264af58..20cdb63c 100644 --- a/src/EventAccessors.cpp +++ b/src/EventAccessors.cpp
@@ -207,6 +207,20 @@ struct EventInReplyTo } }; +struct EventTransactionId +{ + template<class T> + std::string operator()(const mtx::events::RoomEvent<T> &e) + { + return e.unsigned_data.transaction_id; + } + template<class T> + std::string operator()(const mtx::events::Event<T> &e) + { + return e.unsigned_data.transaction_id; + } +}; + struct EventMediaHeight { template<class Content> @@ -344,6 +358,12 @@ mtx::accessors::in_reply_to_event(const mtx::events::collections::TimelineEvents return std::visit(EventInReplyTo{}, event); } +std::string +mtx::accessors::transaction_id(const mtx::events::collections::TimelineEvents &event) +{ + return std::visit(EventTransactionId{}, event); +} + int64_t mtx::accessors::filesize(const mtx::events::collections::TimelineEvents &event) { diff --git a/src/EventAccessors.h b/src/EventAccessors.h
index 5c03861d..cf79f68f 100644 --- a/src/EventAccessors.h +++ b/src/EventAccessors.h
@@ -50,6 +50,8 @@ std::string mimetype(const mtx::events::collections::TimelineEvents &event); std::string in_reply_to_event(const mtx::events::collections::TimelineEvents &event); +std::string +transaction_id(const mtx::events::collections::TimelineEvents &event); int64_t filesize(const mtx::events::collections::TimelineEvents &event); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 104d564b..432cd329 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -538,6 +538,20 @@ TimelineModel::internalAddEvents( continue; } + QString txid = QString::fromStdString(mtx::accessors::transaction_id(e)); + if (this->pending.removeOne(txid)) { + this->events.insert(id, e); + this->events.remove(txid); + int idx = idToIndex(txid); + if (idx < 0) { + nhlog::ui()->warn("Received index out of range"); + continue; + } + eventOrder[idx] = id; + emit dataChanged(index(idx, 0), index(idx, 0)); + continue; + } + if (auto redaction = std::get_if<mtx::events::RedactionEvent<mtx::events::msg::Redaction>>(&e)) { QString redacts = QString::fromStdString(redaction->redacts);