diff --git a/src/pyj/book_list/router.pyj b/src/pyj/book_list/router.pyj index a2af5d47d0..5376a4ab5f 100644 --- a/src/pyj/book_list/router.pyj +++ b/src/pyj/book_list/router.pyj @@ -1,11 +1,12 @@ # vim:fileencoding=utf-8 # License: GPL v3 Copyright: 2017, Kovid Goyal -from __python__ import hash_literals, bound_methods +from __python__ import bound_methods, hash_literals -from book_list.constants import read_book_container_id, book_list_container_id +from book_list.constants import book_list_container_id, read_book_container_id from book_list.globals import get_current_query from book_list.library_data import current_library_id -from utils import parse_url_params, encode_query_with_path +from modals import close_all_modals +from utils import encode_query_with_path, parse_url_params mode_handlers = {} default_mode_handler = None @@ -38,6 +39,7 @@ def apply_mode(mode): def apply_url(ignore_handler): + close_all_modals() # needed to close any error dialogs, etc when clicking back or forward in the browser or using push_state() to go to a new page data = parse_url_params() data.mode = data.mode or 'book_list' get_current_query(data) diff --git a/src/pyj/modals.pyj b/src/pyj/modals.pyj index e968f5ae99..f1fe730761 100644 --- a/src/pyj/modals.pyj +++ b/src/pyj/modals.pyj @@ -125,6 +125,11 @@ class ModalContainer: return self.clear_current_modal() + def close_all_modals(self): + while self.current_modal is not None: + self.close_current_modal() + + def create_simple_dialog(title, msg, details, icon, prefix): details = details or '' def create_func(parent): @@ -223,6 +228,11 @@ def create_modal_container(): def show_modal(create_func, on_close=None, show_close=True): return modal_container.show_modal(create_func, on_close, show_close) + +def close_all_modals(): + return modal_container.close_all_modals() + + def error_dialog(title, msg, details=None): create_simple_dialog(title, msg, details, 'bug', _('Error:'))