diff --git a/src/tribler-gui/tribler_gui/tribler_window.py b/src/tribler-gui/tribler_gui/tribler_window.py index 8ce992173ce..f8407a4fe8f 100644 --- a/src/tribler-gui/tribler_gui/tribler_window.py +++ b/src/tribler-gui/tribler_gui/tribler_window.py @@ -1029,10 +1029,14 @@ def clicked_search_bar(self, checked=False): def on_top_search_bar_return_pressed(self): # Initiate a new search query and switch to search loading/results page query = self.top_search_bar.text() - if query: - self.search_results_page.search(query) - self.deselect_all_menu_buttons() - self.stackedWidget.setCurrentIndex(PAGE_SEARCH_RESULTS) + if not query: + return + + if not self.search_results_page.search(query): + return + + self.deselect_all_menu_buttons() + self.stackedWidget.setCurrentIndex(PAGE_SEARCH_RESULTS) def clicked_menu_button_discovered(self): self.deselect_all_menu_buttons() diff --git a/src/tribler-gui/tribler_gui/widgets/searchresultswidget.py b/src/tribler-gui/tribler_gui/widgets/searchresultswidget.py index 14a73661130..32ae8a0dc16 100644 --- a/src/tribler-gui/tribler_gui/widgets/searchresultswidget.py +++ b/src/tribler-gui/tribler_gui/widgets/searchresultswidget.py @@ -101,7 +101,7 @@ def check_can_show(self, query): def search(self, query): if not self.check_can_show(query): - return + return None self.last_search_query = query self.last_search_time = time.time() @@ -113,9 +113,11 @@ def register_request(response): self.timeout_progress_bar.start() self.setCurrentWidget(self.loading_page) - params = {'txt_filter': to_fts_query(query), 'hide_xxx': self.hide_xxx} + if (fts_query := to_fts_query(query)) is None: + return None - TriblerNetworkRequest('remote_query', register_request, method="PUT", url_params=params) + params = {'txt_filter': fts_query, 'hide_xxx': self.hide_xxx} + return TriblerNetworkRequest('remote_query', register_request, method="PUT", url_params=params) def reset(self): if self.currentWidget() == self.results_page: