From 9c1912ed93cc0628c578a005f0c06bed7b88f63d Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 13 Dec 2019 01:31:14 +0100 Subject: [PATCH] Fix preview of sent encrypted images --- src/timeline/TimelineModel.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 9da8a19..e49fcf5 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -414,6 +414,7 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj return eventCopy; }, ev); + events.remove(txn_id); events.insert(event_id, ev); @@ -666,7 +667,7 @@ TimelineModel::internalAddEvents( const std::vector &timeline) { std::vector ids; - for (const auto &e : timeline) { + for (auto e : timeline) { QString id = boost::apply_visitor([](const auto &e) -> QString { return eventId(e); }, e); @@ -707,16 +708,16 @@ TimelineModel::internalAddEvents( if (auto event = boost::get>(&e)) { - auto temp = decryptEvent(*event).event; - auto encInfo = boost::apply_visitor( - [](const auto &ev) -> boost::optional { - return eventEncryptionInfo(ev); - }, - temp); - - if (encInfo) - emit newEncryptedImage(encInfo.value()); + e = decryptEvent(*event).event; } + auto encInfo = boost::apply_visitor( + [](const auto &ev) -> boost::optional { + return eventEncryptionInfo(ev); + }, + e); + + if (encInfo) + emit newEncryptedImage(encInfo.value()); this->events.insert(id, e); ids.push_back(id);