summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-11-01 23:26:21 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-11-01 23:26:21 +0100
commit40ac55ddd9f1ba02e37f189ba7566d8d95699b4c (patch)
tree9c3db7ee1e3a9cd0043795d991dc8a92bc1fe2b4 /src
parentThe hybris of committing a line without linting (diff)
downloadnheko-40ac55ddd9f1ba02e37f189ba7566d8d95699b4c.tar.xz
Highlight higlight tweaks in the timeline
fixes #400
fixes #1136
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.h5
-rw-r--r--src/timeline/TimelineModel.cpp21
-rw-r--r--src/timeline/TimelineModel.h9
3 files changed, 35 insertions, 0 deletions
diff --git a/src/ChatPage.h b/src/ChatPage.h

index 1bb25dc2..6e1095b9 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h
@@ -78,6 +78,11 @@ public: //! Check if the given room is currently open. bool isRoomActive(const QString &room_id); + const std::unique_ptr<mtx::pushrules::PushRuleEvaluator> &pushruleEvaluator() const + { + return pushrules; + } + public slots: bool handleMatrixUri(QString uri); bool handleMatrixUri(const QUrl &uri); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 6cf361aa..b20e36bc 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -526,6 +526,7 @@ TimelineModel::roleNames() const {IsEncrypted, "isEncrypted"}, {IsStateEvent, "isStateEvent"}, {Trustlevel, "trustlevel"}, + {Notificationlevel, "notificationlevel"}, {EncryptionError, "encryptionError"}, {ReplyTo, "replyTo"}, {ThreadId, "threadId"}, @@ -737,6 +738,26 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r return crypto::Trust::Unverified; } + case Notificationlevel: { + const auto &push = ChatPage::instance()->pushruleEvaluator(); + if (push) { + auto actions = push->evaluate({event}, pushrulesRoomContext()); + if (std::find(actions.begin(), + actions.end(), + mtx::pushrules::actions::Action{ + mtx::pushrules::actions::set_tweak_highlight{}}) != actions.end()) { + return qml_mtx_events::NotificationLevel::Highlight; + } + if (std::find(actions.begin(), + actions.end(), + mtx::pushrules::actions::Action{mtx::pushrules::actions::notify{}}) != + actions.end()) { + return qml_mtx_events::NotificationLevel::Notify; + } + } + return qml_mtx_events::NotificationLevel::Nothing; + } + case EncryptionError: return events.decryptionError(event_id(event)); diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 8bf18f19..9cd60e5d 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h
@@ -151,6 +151,14 @@ enum EventState Empty, }; Q_ENUM_NS(EventState) + +enum NotificationLevel +{ + Nothing, + Notify, + Highlight, +}; +Q_ENUM_NS(NotificationLevel) } class StateKeeper @@ -242,6 +250,7 @@ public: IsEncrypted, IsStateEvent, Trustlevel, + Notificationlevel, EncryptionError, ReplyTo, ThreadId,