diff --git a/src/pyj/book_list/boss.pyj b/src/pyj/book_list/boss.pyj index a9ba415e74..8ab85c5099 100644 --- a/src/pyj/book_list/boss.pyj +++ b/src/pyj/book_list/boss.pyj @@ -9,7 +9,7 @@ from gettext import gettext as _ from widgets import get_widget_css from utils import parse_url_params -from book_list.globals import get_session_data, set_boss +from book_list.globals import get_session_data, set_boss, set_current_query from book_list.theme import get_color from book_list.ui import UI @@ -30,8 +30,9 @@ class Boss: self.ui = UI(interface_data, div) window.onerror = self.onerror.bind(self) self.history_count = 0 - self.ui.apply_state() # Render the book list data = parse_url_params() + set_current_query(data) + self.ui.apply_state() # Render the book list if not data.mode or data.mode == 'book_list': if data.panel != self.ui.current_panel: self.ui.show_panel(data.panel, push_state=False) @@ -60,6 +61,7 @@ class Boss: def onpopstate(self, ev): data = parse_url_params() + set_current_query(data) mode = data.mode or 'book_list' self.history_count -= 1 if mode == 'book_list': @@ -94,6 +96,7 @@ class Boss: if sq: query.search = sq query = encode_query(query) or '?' + set_current_query(query) if replace: window.history.replaceState(None, '', query) else: diff --git a/src/pyj/book_list/globals.pyj b/src/pyj/book_list/globals.pyj index ebc1b77bb9..64ddcdb5de 100644 --- a/src/pyj/book_list/globals.pyj +++ b/src/pyj/book_list/globals.pyj @@ -3,6 +3,7 @@ boss = None session_data = None +current_query = {} def get_boss(): return boss @@ -19,3 +20,10 @@ def set_session_data(sd): def get_session_data(): return session_data + +def get_current_query(): + return current_query + +def set_current_query(val): + nonlocal current_query + current_query = val diff --git a/src/pyj/book_list/ui.pyj b/src/pyj/book_list/ui.pyj index bacbb44e0b..c05f0868e8 100644 --- a/src/pyj/book_list/ui.pyj +++ b/src/pyj/book_list/ui.pyj @@ -126,17 +126,17 @@ class UI: self.show_panel(self.ROOT_PANEL) def replace_panel(self, panel_name, force=False): + get_boss().push_state(replace=True) if force or panel_name != self.current_panel: self.current_panel = panel_name or self.ROOT_PANEL self.apply_state() - get_boss().push_state(replace=True) def show_panel(self, panel_name, push_state=True, force=False): + if push_state: + get_boss().push_state() if force or panel_name != self.current_panel: self.current_panel = panel_name or self.ROOT_PANEL self.apply_state() - if push_state: - get_boss().push_state() def refresh_books_view(self): self.books_view.refresh()