aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Matrix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Matrix.cpp')
-rw-r--r--src/plugins/Matrix.cpp22
1 files changed, 6 insertions, 16 deletions
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 &notification) {
- 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;