summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2024-08-21 00:14:34 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2024-08-21 00:29:11 +0200
commitd1eb35197546a491ce3503c7c2582980e90b6c52 (patch)
treef563e0a6d99e423970d9bfd954f24123bb8608ed /src/timeline
parentWarn about room name and topic not being encrypted (diff)
downloadnheko-d1eb35197546a491ce3503c7c2582980e90b6c52.tar.xz
Allow loading image only after explicit interactions
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/TimelineModel.cpp22
-rw-r--r--src/timeline/TimelineModel.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp

index 48b58ee5..eea345b5 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -3387,4 +3387,26 @@ TimelineModel::parentSpace() return parentSummary.get(); } +bool +TimelineModel::showImage() const +{ + auto show = UserSettings::instance()->showImage(); + + switch (show) { + case UserSettings::ShowImage::Always: + return true; + case UserSettings::ShowImage::OnlyPrivate: { + auto accessRules = cache::client() + ->getStateEvent<mtx::events::state::JoinRules>(room_id_.toStdString()) + .value_or(mtx::events::StateEvent<mtx::events::state::JoinRules>{}) + .content; + + return accessRules.join_rule != mtx::events::state::JoinRule::Public; + } + case UserSettings::ShowImage::Never: + default: + return false; + } +} + #include "moc_TimelineModel.cpp" diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 3a189e39..9f96c62d 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h
@@ -323,6 +323,7 @@ public: const mtx::events::StateEvent<mtx::events::msc2545::ImagePack> &event) const; Q_INVOKABLE QString formatPolicyRule(const QString &id) const; Q_INVOKABLE QVariantMap formatRedactedEvent(const QString &id); + Q_INVOKABLE bool showImage() const; Q_INVOKABLE void viewRawMessage(const QString &id); Q_INVOKABLE void forwardMessage(const QString &eventId, QString roomId);