diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-11-10 11:53:58 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-11-10 11:55:24 +0100 |
commit | 5d2a7d977f9b0a1604e106f4e2b0c2c9b89c3235 (patch) | |
tree | 88622d3dd853a3642ac6f181952af3c7f73aed82 /src/plugins | |
parent | 60f37ebeb130bd58adece6bee06420b40c4e5a05 (diff) |
Matrix: add settings page with join room and logout button
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 82ca583..f79b10c 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -966,6 +966,34 @@ namespace QuickMedia { title = "Invites (0)"; } + PluginResult MatrixSettingsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) { + if(args.url == "join") { + result_tabs.push_back(Tab{create_body(), std::make_unique<MatrixRoomInputPage>(program, matrix), create_search_bar("Enter room id...", SEARCH_DELAY_FILTER)}); + return PluginResult::OK; + } else if(args.url == "logout") { + matrix->logout(); + program->set_go_to_previous_page(); + return PluginResult::OK; + } else { + return PluginResult::ERR; + } + } + + PluginResult MatrixRoomInputPage::submit(const SubmitArgs &args, std::vector<Tab>&) { + if(args.title.empty()) { + show_notification("QuickMedia", "Room id can't be empty", Urgency::CRITICAL); + return PluginResult::OK; + } + + if(matrix->join_room(args.title) == PluginResult::OK) { + show_notification("QuickMedia", "You joined " + args.title, Urgency::NORMAL); + program->set_go_to_previous_page(); + } else { + show_notification("QuickMedia", "Failed to join " + args.title, Urgency::CRITICAL); + } + return PluginResult::OK; + } + MatrixChatPage::MatrixChatPage(Program *program, std::string room_id, MatrixRoomsPage *rooms_page, std::string jump_to_event_id) : Page(program), room_id(std::move(room_id)), rooms_page(rooms_page), jump_to_event_id(std::move(jump_to_event_id)) { |