From 26134d3601c3c139aff71123b09bf18ba35b6450 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 25 Jun 2021 13:11:25 +0200 Subject: Matrix: do not show kick/ban notification when restarting quickmedia (do not show notification on cache load) --- plugins/Matrix.hpp | 4 ++-- src/plugins/Matrix.cpp | 11 ++++++----- src/plugins/youtube/YoutubeMediaProxy.cpp | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 568357a..2e25d69 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -242,7 +242,7 @@ namespace QuickMedia { virtual ~MatrixDelegate() = default; virtual void join_room(RoomData *room) = 0; - virtual void leave_room(RoomData *room, LeaveType leave_type, const std::string &reason) = 0; + virtual void leave_room(RoomData *room, LeaveType leave_type, const std::string &reason, bool is_cache) = 0; // Note: calling |room| methods inside this function is not allowed virtual void room_add_tag(RoomData *room, const std::string &tag) = 0; @@ -276,7 +276,7 @@ namespace QuickMedia { MatrixQuickMedia(Program *program, Matrix *matrix, MatrixRoomsPage *rooms_page, MatrixRoomTagsPage *room_tags_page, MatrixInvitesPage *invites_page, MatrixNotificationsPage *notifications_page); void join_room(RoomData *room) override; - void leave_room(RoomData *room, LeaveType leave_type, const std::string &reason) override; + void leave_room(RoomData *room, LeaveType leave_type, const std::string &reason, bool is_cache) override; void room_add_tag(RoomData *room, const std::string &tag) override; void room_remove_tag(RoomData *room, const std::string &tag) override; void room_add_new_messages(RoomData *room, const Messages &messages, bool is_initial_sync, bool sync_is_cache, MessageDirection message_dir) override; diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 9f5faf0..cd4f637 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -375,11 +375,11 @@ namespace QuickMedia { rooms_page->add_body_item(body_item); } - void MatrixQuickMedia::leave_room(RoomData *room, LeaveType leave_type, const std::string &reason) { + void MatrixQuickMedia::leave_room(RoomData *room, LeaveType leave_type, const std::string &reason, bool is_cache) { room_body_item_by_room.erase(room); rooms_page->remove_body_item_by_room_id(room->id); room_tags_page->remove_body_item_by_room_id(room->id); - if(leave_type != LeaveType::LEAVE) + if(!is_cache && leave_type != LeaveType::LEAVE) show_notification("QuickMedia", reason); } @@ -1752,7 +1752,7 @@ namespace QuickMedia { for(auto &room : rooms) { if(existing_rooms.find(room.get()) == existing_rooms.end()) { RoomData *room_p = room.get(); - ui_thread_tasks.push([this, room_p]{ delegate->leave_room(room_p, LeaveType::LEAVE, ""); }); + ui_thread_tasks.push([this, room_p]{ delegate->leave_room(room_p, LeaveType::LEAVE, "", true); }); remove_room(room->id); } } @@ -2743,7 +2743,8 @@ namespace QuickMedia { if(!reason_str.empty()) desc += ", reason: " + reason_str; - ui_thread_tasks.push([this, room, leave_type, desc{std::move(desc)}]{ delegate->leave_room(room, leave_type, desc); }); + const bool is_cache = sync_is_cache; + ui_thread_tasks.push([this, room, leave_type, desc{std::move(desc)}, is_cache]{ delegate->leave_room(room, leave_type, desc, is_cache); }); remove_room(room_id_str); break; } @@ -3896,7 +3897,7 @@ namespace QuickMedia { if(download_result == DownloadResult::OK) { RoomData *room = get_room_by_id(room_id); if(room) { - ui_thread_tasks.push([this, room]{ delegate->leave_room(room, LeaveType::LEAVE, ""); }); + ui_thread_tasks.push([this, room]{ delegate->leave_room(room, LeaveType::LEAVE, "", false); }); remove_room(room_id); } } diff --git a/src/plugins/youtube/YoutubeMediaProxy.cpp b/src/plugins/youtube/YoutubeMediaProxy.cpp index e8d0383..cba4a1d 100644 --- a/src/plugins/youtube/YoutubeMediaProxy.cpp +++ b/src/plugins/youtube/YoutubeMediaProxy.cpp @@ -447,6 +447,7 @@ namespace QuickMedia { } } + // TODO: Remove this code and instead create the header ourselves and send it to the client. Then pipe the curl output directly to the client input. if(!download_header_finished) { download_header.append(download_read_buffer, downloader_num_read_bytes); size_t header_end = std::string::npos; -- cgit v1.2.3