From a627a1fedd8d8a727d881f7e6c9e03c731dcfafd Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 11 May 2021 21:40:23 +0200 Subject: Fix join room crash --- src/plugins/Matrix.cpp | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'src/plugins/Matrix.cpp') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 2740a8a..8679a54 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -918,23 +918,18 @@ namespace QuickMedia { } PluginResult MatrixInviteDetailsPage::submit(const std::string &title, const std::string&, std::vector&) { - TaskResult task_result = program->run_task_with_loading_screen([this, title]() { - if(title == "Accept") - return matrix->join_room(room_id) == PluginResult::OK; - else if(title == "Decline") - return matrix->leave_room(room_id) == PluginResult::OK; - return false; - }); - - if(task_result == TaskResult::TRUE) { - invites_page->remove_body_item_by_room_id(room_id); - } else if(task_result == TaskResult::FALSE) { - std::string action_str; - if(title == "Accept") - action_str = "accept"; - else if(title == "Decline") - action_str = "decline"; - show_notification("QuickMedia", "Failed to " + action_str + " the room invite", Urgency::CRITICAL); + if(title == "Accept") { + if(matrix->join_room(room_id) == PluginResult::OK) { + invites_page->remove_body_item_by_room_id(room_id); + } else { + show_notification("QuickMedia", "Failed to accept the room invite", Urgency::CRITICAL); + } + } else if(title == "Decline") { + if(matrix->leave_room(room_id) == PluginResult::OK) { + invites_page->remove_body_item_by_room_id(room_id); + } else { + show_notification("QuickMedia", "Failed to decline the room invite", Urgency::CRITICAL); + } } program->set_go_to_previous_page(); @@ -1044,17 +1039,12 @@ namespace QuickMedia { } PluginResult MatrixServerRoomListPage::submit(const std::string &title, const std::string &url, std::vector&) { - TaskResult task_result = program->run_task_with_loading_screen([this, url]() { - return matrix->join_room(url) == PluginResult::OK; - }); - - if(task_result == TaskResult::TRUE) { + if(matrix->join_room(url) == PluginResult::OK) { show_notification("QuickMedia", "You joined " + title, Urgency::NORMAL); program->set_go_to_previous_page(); - } else if(task_result == TaskResult::FALSE) { + } else { show_notification("QuickMedia", "Failed to join " + title, Urgency::CRITICAL); } - return PluginResult::OK; } -- cgit v1.2.3