aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-06-19 04:46:27 +0200
committerdec05eba <dec05eba@protonmail.com>2022-06-19 04:46:27 +0200
commit295ab1f44b76bf88606a217fd6a014cbdf5a915d (patch)
tree665fb8f0f67e46f05a0c84157c6c01e59a7150c6 /src
parent42891df4c3c184b7123ba44693c489f489de10e3 (diff)
Fix submit on async reload page, fix submit on search suggestion page empty text
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp60
1 files changed, 34 insertions, 26 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index dad215f..29ada07 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1942,7 +1942,7 @@ namespace QuickMedia {
if(tab_associated_data.fetching_next_page_running)
window.draw(gradient_points, 4, mgl::PrimitiveType::Quads); // TODO: mgl::PrimitiveType::Quads doesn't work with egl
- if(!tab_associated_data.search_result_text.get_string().empty() && !tabs[selected_tab].page->search_is_suggestion()) {
+ if(!tab_associated_data.search_result_text.get_string().empty() && !tabs[selected_tab].page->search_is_suggestion(tab_associated_data.search_text_empty)) {
auto search_result_text_bounds = tab_associated_data.search_result_text.get_bounds();
tab_associated_data.search_result_text.set_position(mgl::vec2f(
std::floor(body_pos.x + body_size.x * 0.5f - search_result_text_bounds.size.x * 0.5f),
@@ -2070,7 +2070,7 @@ namespace QuickMedia {
BodyItems new_body_items;
const bool search_suggestion_submitted = tab_associated_data[selected_tab].search_suggestion_submitted;
- if((tabs[selected_tab].page->is_single_page() || (tabs[selected_tab].page->search_is_suggestion() && !search_suggestion_submitted))
+ if((tabs[selected_tab].page->is_single_page() || (tabs[selected_tab].page->search_is_suggestion(tab_associated_data[selected_tab].search_text_empty) && !search_suggestion_submitted))
&& tab_associated_data[selected_tab].fetch_future.valid())
{
tabs[selected_tab].page->cancel_operation();
@@ -2087,7 +2087,7 @@ namespace QuickMedia {
submit_args.userdata = selected_item ? selected_item->userdata : nullptr;
submit_args.extra = selected_item ? selected_item->extra : nullptr;
- if(tabs[selected_tab].page->search_is_suggestion() && !search_suggestion_submitted) {
+ if(tabs[selected_tab].page->search_is_suggestion(tab_associated_data[selected_tab].search_text_empty) && !search_suggestion_submitted) {
tabs[selected_tab].body->card_view = tab_associated_data[selected_tab].card_view;
PluginResult plugin_result = tabs[selected_tab].page->submit_suggestion(submit_args, new_body_items);
return plugin_result == PluginResult::OK;
@@ -2125,7 +2125,7 @@ namespace QuickMedia {
}
}
- if(tabs[selected_tab].page->is_single_page() && !tabs[selected_tab].page->search_is_suggestion()) {
+ if(tabs[selected_tab].page->is_single_page() && !tabs[selected_tab].page->search_is_suggestion(tab_associated_data[selected_tab].search_text_empty)) {
if(tabs[selected_tab].search_bar) tabs[selected_tab].search_bar->clear();
if(new_tabs.size() == 1 && !new_tabs[0].page) {
tabs[selected_tab].body = std::move(new_tabs[0].body);
@@ -2136,7 +2136,7 @@ namespace QuickMedia {
}
}
- if(tabs[selected_tab].page->search_is_suggestion() && !search_suggestion_submitted) {
+ if(tabs[selected_tab].page->search_is_suggestion(tab_associated_data[selected_tab].search_text_empty) && !search_suggestion_submitted) {
if(tabs[selected_tab].search_bar)
tabs[selected_tab].search_bar->set_text(selected_item ? selected_item->get_title() : search_text, false);
tabs[selected_tab].body->set_items(std::move(new_body_items));
@@ -2153,14 +2153,6 @@ namespace QuickMedia {
for(size_t i = 0; i < tabs.size(); ++i) {
tabs[i].body->clear_cache();
- const bool lazy_update = tabs[i].page->search_is_filter() || (tabs[i].search_bar && tabs[i].search_bar->get_text().empty());
- if(tabs[i].page->is_lazy_fetch_page() && static_cast<LazyFetchPage*>(tabs[i].page.get())->reload_on_page_change() && lazy_update) {
- tab_associated_data[i].lazy_fetch_finished = false;
- tab_associated_data[i].fetched_page = 0;
- const BodyItem *selected_item = tabs[i].body->get_selected();
- tab_associated_data[i].body_item_url_before_refresh = selected_item ? selected_item->url : "";
- tabs[i].body->clear_items();
- }
}
if(tabs[selected_tab].page->allow_submit_no_selection()) {
@@ -2293,6 +2285,17 @@ namespace QuickMedia {
page_loop(new_tabs, 0, after_submit_handler);
}
+ for(size_t i = 0; i < tabs.size(); ++i) {
+ const bool lazy_update = tabs[i].page->search_is_filter() || (tabs[i].search_bar && tabs[i].search_bar->get_text().empty());
+ if(tabs[i].page->is_lazy_fetch_page() && static_cast<LazyFetchPage*>(tabs[i].page.get())->reload_on_page_change() && lazy_update) {
+ tab_associated_data[i].lazy_fetch_finished = false;
+ tab_associated_data[i].fetched_page = 0;
+ const BodyItem *selected_item = tabs[i].body->get_selected();
+ tab_associated_data[i].body_item_url_before_refresh = selected_item ? selected_item->url : "";
+ tabs[i].body->clear_items();
+ }
+ }
+
for(Tab &tab : tabs) {
tab.page->on_navigate_to_page(tab.body.get());
}
@@ -2309,7 +2312,7 @@ namespace QuickMedia {
&& !tab_associated_data[selected_tab].fetching_next_page_failed
&& (!tabs[selected_tab].search_bar || !tabs[selected_tab].page->search_is_filter() || tabs[selected_tab].search_bar->is_empty())
&& tabs[selected_tab].body->get_num_visible_items() > 0
- && (!tabs[selected_tab].page->search_is_suggestion() || tab_associated_data[selected_tab].search_suggestion_submitted)
+ && (!tabs[selected_tab].page->search_is_suggestion(tab_associated_data[selected_tab].search_text_empty) || tab_associated_data[selected_tab].search_suggestion_submitted)
&& tabs[selected_tab].page->is_ready()
&& (!tabs[selected_tab].page->is_lazy_fetch_page() || tab_associated_data[selected_tab].lazy_fetch_finished))
{
@@ -2612,10 +2615,10 @@ namespace QuickMedia {
if(associated_data.search_text_updated && associated_data.fetch_status == FetchStatus::NONE && !associated_data.fetching_next_page_running) {
std::string update_search_text = associated_data.update_search_text;
- if(!tabs[i].page->search_is_suggestion() || associated_data.search_suggestion_submitted)
+ if(!tabs[i].page->search_is_suggestion(associated_data.search_text_empty) || associated_data.search_suggestion_submitted)
tabs[i].body->clear_items();
- if(tabs[i].page->search_is_suggestion() && tabs[i].body) {
+ if(tabs[i].page->search_is_suggestion(associated_data.search_text_empty) && tabs[i].body) {
if(update_search_text.empty())
tabs[i].body->card_view = tab_associated_data[selected_tab].card_view;
else
@@ -2647,6 +2650,7 @@ namespace QuickMedia {
}
associated_data.fetched_page = 0;
associated_data.fetching_next_page_failed = false;
+ associated_data.search_text_empty = associated_data.update_search_text.empty();
if(fetch_result.result != PluginResult::OK)
associated_data.search_result_text.set_string("Search failed!");
else if(tabs[i].body->get_num_items() == 0)
@@ -3163,11 +3167,13 @@ namespace QuickMedia {
SubmitArgs submit_args;
if(parent_body) {
BodyItem *selected = parent_body->get_selected();
- submit_args.title = selected->get_title();
- submit_args.url = selected->url;
- submit_args.thumbnail_url = selected->thumbnail_url;
- submit_args.userdata = selected->userdata;
- submit_args.extra = selected->extra;
+ if(selected) {
+ submit_args.title = selected->get_title();
+ submit_args.url = selected->url;
+ submit_args.thumbnail_url = selected->thumbnail_url;
+ submit_args.userdata = selected->userdata;
+ submit_args.extra = selected->extra;
+ }
}
std::string err_str;
@@ -7879,11 +7885,13 @@ namespace QuickMedia {
std::vector<Tab> new_tabs;
TaskResult task_result = run_task_with_loading_screen([&]() {
SubmitArgs submit_args;
- submit_args.title = selected->get_title();
- submit_args.url = selected->url;
- submit_args.thumbnail_url = selected->thumbnail_url;
- submit_args.userdata = selected->userdata;
- submit_args.extra = selected->extra;
+ if(selected) {
+ submit_args.title = selected->get_title();
+ submit_args.url = selected->url;
+ submit_args.thumbnail_url = selected->thumbnail_url;
+ submit_args.userdata = selected->userdata;
+ submit_args.extra = selected->extra;
+ }
return file_manager_page->submit(submit_args, new_tabs) == PluginResult::OK;
});