aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-25 13:11:25 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-25 13:11:29 +0200
commit26134d3601c3c139aff71123b09bf18ba35b6450 (patch)
tree715e15cc4107a7aaf188b78b322e3fbe6cf5c073
parent38202de4f953fca28aa884246ced0aadf0d25a4d (diff)
Matrix: do not show kick/ban notification when restarting quickmedia (do not show notification on cache load)
-rw-r--r--plugins/Matrix.hpp4
-rw-r--r--src/plugins/Matrix.cpp11
-rw-r--r--src/plugins/youtube/YoutubeMediaProxy.cpp1
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;