Change how decrypt value is retrieved from settings

This commit is contained in:
Joseph Donofry 2020-04-23 19:05:44 -04:00
parent b00e624fb0
commit 994edb836c
4 changed files with 13 additions and 3 deletions

2
.gitignore vendored
View file

@ -6,6 +6,7 @@ cscope*
/.ccls-cache /.ccls-cache
/.exrc /.exrc
.gdb_history .gdb_history
.hunter
# GTAGS # GTAGS
GTAGS GTAGS
@ -72,6 +73,7 @@ install_manifest.txt
# Icon must end with two \r # Icon must end with two \r
Icon Icon
# Thumbnails # Thumbnails
._* ._*

View file

@ -514,6 +514,12 @@ TimelineModel::updateLastMessage()
{ {
// Get the user setting to show decrypted messages in side bar // Get the user setting to show decrypted messages in side bar
bool decrypt = QSettings().value("user/decrypt_sidebar", true).toBool(); bool decrypt = QSettings().value("user/decrypt_sidebar", true).toBool();
updateLastMessage(decrypt);
}
void
TimelineModel::updateLastMessage(bool decrypt)
{
for (auto it = eventOrder.begin(); it != eventOrder.end(); ++it) { for (auto it = eventOrder.begin(); it != eventOrder.end(); ++it) {
auto event = events.value(*it); auto event = events.value(*it);
if (auto e = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( if (auto e = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(

View file

@ -189,7 +189,7 @@ public:
Q_INVOKABLE void cacheMedia(QString eventId); Q_INVOKABLE void cacheMedia(QString eventId);
Q_INVOKABLE bool saveMedia(QString eventId) const; Q_INVOKABLE bool saveMedia(QString eventId) const;
void updateLastMessage(); void updateLastMessage(bool);
void addEvents(const mtx::responses::Timeline &events); void addEvents(const mtx::responses::Timeline &events);
template<class T> template<class T>
void sendMessage(const T &msg); void sendMessage(const T &msg);
@ -259,6 +259,7 @@ private:
const mtx::responses::ClaimKeys &res, const mtx::responses::ClaimKeys &res,
mtx::http::RequestErr err); mtx::http::RequestErr err);
void readEvent(const std::string &id); void readEvent(const std::string &id);
void updateLastMessage();
QHash<QString, mtx::events::collections::TimelineEvents> events; QHash<QString, mtx::events::collections::TimelineEvents> events;
QSet<QString> read; QSet<QString> read;

View file

@ -19,12 +19,13 @@ Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents)
void void
TimelineViewManager::updateEncryptedDescriptions() TimelineViewManager::updateEncryptedDescriptions()
{ {
auto decrypt = settings->isDecryptSidebarEnabled();
QHash<QString, QSharedPointer<TimelineModel>>::iterator i; QHash<QString, QSharedPointer<TimelineModel>>::iterator i;
for (i = models.begin(); i != models.end(); ++i) { for (i = models.begin(); i != models.end(); ++i) {
auto ptr = i.value(); auto ptr = i.value();
if (!ptr.isNull()) { if (!ptr.isNull()) {
ptr->updateLastMessage(); ptr->updateLastMessage(decrypt);
} }
} }
} }