diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-11 21:40:23 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-11 21:40:23 +0200 |
commit | a627a1fedd8d8a727d881f7e6c9e03c731dcfafd (patch) | |
tree | 1387ccbb397989ab1ae5d98accb01eae180548b2 /src | |
parent | 016fa373be76cb8d77b31cb23e60ddbd22c8cf5a (diff) |
Fix join room crash
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/Matrix.cpp | 38 |
1 files changed, 14 insertions, 24 deletions
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<Tab>&) { - 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<Tab>&) { - 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; } |