From 442fc29582b5581111e3ffd286f4f3d282877f3c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 16 Dec 2022 21:13:38 +0100 Subject: Fix bug where image are not removed from loading when not visible Matrix: fix invites not showing notification --- src/plugins/Matrix.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index fae8451..c93a22b 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -684,7 +684,7 @@ namespace QuickMedia { if(silenced_invite) body_item->add_reaction("Silenced", nullptr); invites_page->add_body_item(std::move(body_item)); - if(invite.new_invite && !silenced_invite) { + if(!silenced_invite) { show_notification("QuickMedia matrix - " + invite.room_name, "You were invited to " + invite.room_name + " by " + invited_by_display_name + " (" + invite.invited_by->user_id + ")"); } } @@ -1147,7 +1147,7 @@ namespace QuickMedia { } void MatrixInvitesPage::add_body_item(std::shared_ptr body_item) { - body->insert_item_by_timestamp(std::move(body_item)); + body->insert_item_by_timestamp_reverse(std::move(body_item)); if(body->get_num_items() != prev_invite_count) { prev_invite_count = body->get_num_items(); title = "Invites (" + std::to_string(body->get_num_items()) + ")"; @@ -1773,6 +1773,8 @@ namespace QuickMedia { goto sync_end; } + add_new_invites(); + next_batch_json = &GetMember(json_root, "next_batch"); if(next_batch_json->IsString()) { set_next_batch(next_batch_json->GetString(), true); @@ -2037,6 +2039,14 @@ namespace QuickMedia { } } + void Matrix::add_new_invites() { + std::lock_guard lock(invite_mutex); + for(auto &[room_id, invite] : invites) { + ui_thread_tasks.push([this, room_id{std::move(room_id)}, invite{std::move(invite)}]{ delegate->add_invite(room_id, std::move(invite)); }); + } + invites.clear(); + } + PluginResult Matrix::parse_sync_response(const rapidjson::Document &root, bool initial_sync) { if(!root.IsObject()) return PluginResult::ERR; @@ -3673,8 +3683,7 @@ namespace QuickMedia { invite.timestamp = timestamp; std::string room_id_str(room_id.GetString(), room_id.GetStringLength()); - if(set_invite(room_id_str, invite)) - ui_thread_tasks.push([this, room_id_str{std::move(room_id_str)}, invite{std::move(invite)}]{ delegate->add_invite(room_id_str, std::move(invite)); }); + set_invite(room_id_str, invite); break; } @@ -3918,6 +3927,16 @@ namespace QuickMedia { case '\n': case '\r': case '\t': + case '?': + case ',': + case ')': + case '(': + case '[': + case ']': + case '{': + case '}': + case '!': + case ';': case '@': { user_id_finished = true; user_id_end = i; -- cgit v1.2.3