From f7583202510f0e6d379be29556bb20dc738e3918 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 Aug 2020 21:20:32 +0530 Subject: [PATCH] Fix re-opening a book in the content server viewer not preserving last read position Fixes #1891328 --- src/pyj/read_book/overlay.pyj | 6 +++++- src/pyj/read_book/ui.pyj | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index d551818232..d03163ffaf 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -303,7 +303,10 @@ class MainOverlay: # {{{ class_=MAIN_OVERLAY_ACTIONS_CLASS ) if not runtime.is_standalone_viewer: - home_action = ac(_('Home'), _('Return to the home page'), def(): home();, 'home') + home_action = ac(_('Home'), _('Return to the home page'), def(): + home() + ui_operations.close_book() + , 'home') library_action = ac(_('Library'), _('Return to the library page'), self.overlay.show_library, 'library') actions_div.insertBefore(E.ul(home_action, library_action), actions_div.firstChild) full_screen_actions = [] @@ -769,6 +772,7 @@ class Overlay: self.hide_current_panel() book = self.view.book show_panel('book_list', {'library_id': book.key[0], 'book_id': book.key[1] + ''}, replace=False) + ui_operations.close_book() def show_font_size_chooser(self): self.hide_current_panel() diff --git a/src/pyj/read_book/ui.pyj b/src/pyj/read_book/ui.pyj index c5f655e31a..476f2d087b 100644 --- a/src/pyj/read_book/ui.pyj +++ b/src/pyj/read_book/ui.pyj @@ -80,6 +80,7 @@ class ReadUI: ui_operations.wait_for_messages_from = self.wait_for_messages_from.bind(self) ui_operations.stop_waiting_for_messages_from = self.stop_waiting_for_messages_from.bind(self) ui_operations.update_metadata = self.update_metadata.bind(self) + ui_operations.close_book = self.close_book.bind(self) ui_operations.open_url = def(url): window.open(url, '_blank') ui_operations.copy_selection = def(text): @@ -155,6 +156,9 @@ class ReadUI: div = document.getElementById(self.progress_id) div.lastChild.textContent = msg or '' + def close_book(self): + self.base_url_data = {} + def load_book(self, library_id, book_id, fmt, metadata, force_reload): self.base_url_data = {'library_id': library_id, 'book_id':book_id, 'fmt':fmt} if not self.db.initialized: