aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Matrix.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-21 01:36:00 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-21 01:36:00 +0200
commit0b0ab1e5a451cdd6ae5fd2166314037c1997d292 (patch)
tree58887c84994572acfeb923445cca46fa7a8eaac7 /src/plugins/Matrix.cpp
parentdaa6574a80a37d50dad3c6f5ca94a4f974451729 (diff)
Jump to room when submitting notification
Diffstat (limited to 'src/plugins/Matrix.cpp')
-rw-r--r--src/plugins/Matrix.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 1e1e41b..0577948 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -519,9 +519,9 @@ namespace QuickMedia {
body_items.push_back(std::move(new_body_item));
}
- void body_set_selected_item(Body *body, BodyItem *selected_item) {
+ void body_set_selected_item_by_url(Body *body, const std::string &url) {
for(size_t i = 0; i < body->items.size(); ++i) {
- if(body->items[i]->url == selected_item->url) {
+ if(body->items[i]->url == url) {
body->select_first_item();
body->set_selected_item(i, false);
return;
@@ -641,7 +641,9 @@ namespace QuickMedia {
}
}
- MatrixRoomsPage::MatrixRoomsPage(Program *program, Body *body, std::string title, MatrixRoomTagsPage *room_tags_page) : Page(program), body(body), title(std::move(title)), room_tags_page(room_tags_page) {
+ MatrixRoomsPage::MatrixRoomsPage(Program *program, Body *body, std::string title, MatrixRoomTagsPage *room_tags_page, SearchBar *search_bar) :
+ Page(program), body(body), title(std::move(title)), room_tags_page(room_tags_page), search_bar(search_bar)
+ {
if(room_tags_page)
room_tags_page->set_current_rooms_page(this);
}
@@ -652,8 +654,7 @@ namespace QuickMedia {
}
PluginResult MatrixRoomsPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- auto chat_page = std::make_unique<MatrixChatPage>(program, url, this);
- result_tabs.push_back(Tab{nullptr, std::move(chat_page), nullptr});
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MatrixChatPage>(program, url, this), nullptr});
return PluginResult::OK;
}
@@ -715,6 +716,11 @@ namespace QuickMedia {
matrix_delegate->set_room_as_read(room);
}
+ void MatrixRoomsPage::clear_search() {
+ search_bar->clear();
+ body->filter_search_fuzzy("");
+ }
+
void MatrixRoomsPage::clear_data() {
body->clear_items();
if(current_chat_page)
@@ -729,9 +735,10 @@ namespace QuickMedia {
//BodyItem *selected_item = body->get_selected();
sort_room_body_items(body->items);
//body_set_selected_item(body.get(), selected_item);
- auto rooms_page = std::make_unique<MatrixRoomsPage>(program, body_ptr, tag_data.tag_item->get_title(), this);
+ auto search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
+ auto rooms_page = std::make_unique<MatrixRoomsPage>(program, body_ptr, tag_data.tag_item->get_title(), this, search_bar.get());
rooms_page->matrix_delegate = matrix_delegate;
- result_tabs.push_back(Tab{std::move(body), std::move(rooms_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
+ result_tabs.push_back(Tab{std::move(body), std::move(rooms_page), std::move(search_bar)});
return PluginResult::OK;
}
@@ -1066,8 +1073,18 @@ namespace QuickMedia {
return body_item;
}
- MatrixNotificationsPage::MatrixNotificationsPage(Program *program, Matrix *matrix, Body *notifications_body) :
- LazyFetchPage(program), matrix(matrix), notifications_body(notifications_body) {}
+ MatrixNotificationsPage::MatrixNotificationsPage(Program *program, Matrix *matrix, Body *notifications_body, MatrixRoomsPage *all_rooms_page) :
+ LazyFetchPage(program), matrix(matrix), notifications_body(notifications_body), all_rooms_page(all_rooms_page) {}
+
+ PluginResult MatrixNotificationsPage::submit(const std::string&, const std::string&, std::vector<Tab> &result_tabs) {
+ BodyItem *selected_item = notifications_body->get_selected();
+ if(!selected_item)
+ return PluginResult::OK;
+
+ NotificationsExtraData *extra_data = static_cast<NotificationsExtraData*>(selected_item->extra.get());
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MatrixChatPage>(program, extra_data->room->id, all_rooms_page), nullptr});
+ return PluginResult::OK;
+ }
PluginResult MatrixNotificationsPage::get_page(const std::string&, int, BodyItems &result_items) {
return matrix->get_previous_notifications([this, &result_items](const MatrixNotification &notification) {