Allow loading image only after explicit interactions
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);
|