aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Matrix.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index de49409..0da73eb 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -693,6 +693,11 @@ namespace QuickMedia {
invites_page->remove_body_item_by_room_id(room_id);
}
+ void MatrixQuickMedia::add_unread_notification(MatrixNotification notification) {
+ if(notifications_shown.insert(notification.event_id).second)
+ show_notification("QuickMedia matrix - " + notification.sender_user_id + " (" + notification.room->get_name() + ")", notification.body);
+ }
+
void MatrixQuickMedia::add_user(MatrixEventUserInfo user_info) {
auto &users = users_by_room[user_info.room];
const bool new_user = users.insert(std::make_pair(user_info.user_id, user_info)).second;
@@ -1783,13 +1788,22 @@ namespace QuickMedia {
}
if(first_sync) {
+ bool initial_sync_show_notifications = initial_sync;
first_sync = false;
initial_sync = false;
filter_encoded = url_param_encode(CONTINUE_FILTER); // TODO: limit messages in this continue filter?
// TODO: This ignores new rooms that are not part of the previous sync message. Fix this.
- notification_thread = std::thread([this]() {
- get_previous_notifications([](const MatrixNotification&) {});
+ notification_thread = std::thread([this, initial_sync_show_notifications]() {
+ get_previous_notifications([this, initial_sync_show_notifications](const MatrixNotification &notification) {
+ if(!initial_sync_show_notifications || notification.read)
+ return;
+
+ MatrixDelegate *delegate = this->delegate;
+ ui_thread_tasks.push([delegate, notification] {
+ delegate->add_unread_notification(std::move(notification));
+ });
+ });
finished_fetching_notifications = true;
});
}