From eb6295751d07b8ee173317234daee8acf6b07a5f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 10 Jan 2023 11:31:51 +0100 Subject: Matrix: use room messages for notifications intead of notifications api (synapse cache issue) --- src/Body.cpp | 2 +- src/plugins/Matrix.cpp | 22 ++++++---------------- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 7deea43..8cff959 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -1683,7 +1683,7 @@ namespace QuickMedia { } if(reaction.text) { - reaction.text->set_position(mgl::vec2f(reaction_background.get_position() + mgl::vec2f(body_spacing[body_theme].reaction_background_padding_x, -(float)reaction.text->get_character_size()*0.18f)).floor()); + reaction.text->set_position(mgl::vec2f(reaction_background.get_position() + mgl::vec2f(body_spacing[body_theme].reaction_background_padding_x, -(float)reaction.text->get_character_size()*0.10f)).floor()); } if(draw && reaction.text) { diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 56f4e73..de49409 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -693,11 +693,6 @@ 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; @@ -1672,9 +1667,11 @@ namespace QuickMedia { return; } + const bool cache_updated = get_file_type(get_cache_dir().join("matrix").join("updated-cache-version1")) == FileType::REGULAR; + bool overwrite_cache = !cache_updated; std::ifstream sync_cache_file_stream; sync_cache_file_stream.open(matrix_cache_dir.data.c_str(), std::ifstream::in | std::ifstream::binary); - if(sync_cache_file_stream.good() && get_file_type(get_cache_dir().join("matrix").join("updated-cache-version1")) == FileType::REGULAR) { + if(sync_cache_file_stream.good() && cache_updated) { rapidjson::Document doc; std::string line; while(std::getline(sync_cache_file_stream, line)) { @@ -1792,15 +1789,7 @@ namespace QuickMedia { // TODO: This ignores new rooms that are not part of the previous sync message. Fix this. notification_thread = std::thread([this]() { - get_previous_notifications([this](const MatrixNotification ¬ification) { - if(notification.read) - return; - - MatrixDelegate *delegate = this->delegate; - ui_thread_tasks.push([delegate, notification] { - delegate->add_unread_notification(std::move(notification)); - }); - }); + get_previous_notifications([](const MatrixNotification&) {}); finished_fetching_notifications = true; }); } @@ -1821,7 +1810,8 @@ namespace QuickMedia { // Then the daemon will do the sync and matrix processes will ask that daemon for the cached data // and fetch previous messages etc themselves. if(!matrix_instance_already_running) { - sync_cache_file = fopen(matrix_cache_dir.data.c_str(), "ab"); + sync_cache_file = fopen(matrix_cache_dir.data.c_str(), overwrite_cache ? "wb" : "ab"); + overwrite_cache = false; if(sync_cache_file) { if(json_root.IsObject()) { rapidjson::StringBuffer buffer; -- cgit v1.2.3