summary refs log tree commit diff
path: root/src/timeline/TimelineModel.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-04-23 19:22:25 -0400
committerGitHub <noreply@github.com>2020-04-23 19:22:25 -0400
commit4e3b190ac7e8fc8d87cda6832a623296afd1b90e (patch)
treead0a74770e31310134d3c39198f4675326a14df6 /src/timeline/TimelineModel.cpp
parentTerminate user color calculation, when no solution can be found (diff)
parentChange decrypt setting again (diff)
downloadnheko-4e3b190ac7e8fc8d87cda6832a623296afd1b90e.tar.xz
Merge pull request #173 from Nheko-Reborn/decrypt-sidebar
Decrypt sidebar setting added to user settings
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r--src/timeline/TimelineModel.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp

index bb793945..e3a1a781 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -8,6 +8,7 @@ #include <QFileDialog> #include <QMimeDatabase> #include <QRegularExpression> +#include <QSettings> #include <QStandardPaths> #include "ChatPage.h" @@ -476,14 +477,14 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline) std::vector<QString> ids = internalAddEvents(timeline.events); - if (ids.empty()) - return; - - beginInsertRows(QModelIndex(), 0, static_cast<int>(ids.size() - 1)); - this->eventOrder.insert(this->eventOrder.begin(), ids.rbegin(), ids.rend()); - endInsertRows(); + if (!ids.empty()) { + beginInsertRows(QModelIndex(), 0, static_cast<int>(ids.size() - 1)); + this->eventOrder.insert(this->eventOrder.begin(), ids.rbegin(), ids.rend()); + endInsertRows(); + } - updateLastMessage(); + if (!timeline.events.empty()) + updateLastMessage(); } template<typename T> @@ -501,6 +502,13 @@ isMessage(const mtx::events::Event<T> &) return false; } +template<typename T> +auto +isMessage(const mtx::events::EncryptedEvent<T> &) +{ + return true; +} + void TimelineModel::updateLastMessage() { @@ -508,7 +516,9 @@ TimelineModel::updateLastMessage() auto event = events.value(*it); if (auto e = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( &event)) { - event = decryptEvent(*e).event; + if (decryptDescription) { + event = decryptEvent(*e).event; + } } if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, event))