From bcc6c518be3956557a7046260c9aafc60468646d Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Wed, 15 Jun 2022 15:24:07 +0200 Subject: [PATCH] Fix edits not updating in replies --- src/timeline/EventStore.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index 79bd028a..264cde77 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -384,6 +384,7 @@ EventStore::handleSync(const mtx::responses::Timeline &events) for (const auto &event : events.events) { std::set relates_to; + std::string edited_event; if (auto redaction = std::get_if>(&event)) { // fixup reactions @@ -402,8 +403,12 @@ EventStore::handleSync(const mtx::responses::Timeline &events) relates_to.insert(redaction->redacts); } else { - for (const auto &r : mtx::accessors::relations(event).relations) + for (const auto &r : mtx::accessors::relations(event).relations) { relates_to.insert(r.event_id); + + if (r.rel_type == mtx::common::RelationType::Replace) + edited_event = r.event_id; + } } for (const auto &relates_to_id : relates_to) { @@ -425,6 +430,16 @@ EventStore::handleSync(const mtx::responses::Timeline &events) } } + if (!edited_event.empty()) { + for (const auto &downstream_event : + cache::client()->relatedEvents(room_id_, edited_event)) { + auto idx = cache::client()->getTimelineIndex(room_id_, downstream_event); + if (idx) { + emit dataChanged(toExternalIdx(*idx), toExternalIdx(*idx)); + } + } + } + // decrypting and checking some encrypted messages if (auto encrypted = std::get_if>(&event)) {