mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Clear history only after first page of book is loaded
This commit is contained in:
parent
6e2122df17
commit
a82a2724ce
@ -254,6 +254,7 @@ class ViewerBridge(Bridge):
|
|||||||
show_error = from_js(object, object, object)
|
show_error = from_js(object, object, object)
|
||||||
export_shortcut_map = from_js(object)
|
export_shortcut_map = from_js(object)
|
||||||
print_book = from_js()
|
print_book = from_js()
|
||||||
|
clear_history = from_js()
|
||||||
|
|
||||||
create_view = to_js()
|
create_view = to_js()
|
||||||
start_book_load = to_js()
|
start_book_load = to_js()
|
||||||
@ -430,6 +431,7 @@ class WebView(RestartingWebEngineView):
|
|||||||
self.bridge.show_loading_message.connect(self.show_loading_message)
|
self.bridge.show_loading_message.connect(self.show_loading_message)
|
||||||
self.bridge.show_error.connect(self.show_error)
|
self.bridge.show_error.connect(self.show_error)
|
||||||
self.bridge.print_book.connect(self.print_book)
|
self.bridge.print_book.connect(self.print_book)
|
||||||
|
self.bridge.clear_history.connect(self.clear_history)
|
||||||
self.bridge.export_shortcut_map.connect(self.set_shortcut_map)
|
self.bridge.export_shortcut_map.connect(self.set_shortcut_map)
|
||||||
self.shortcut_map = {}
|
self.shortcut_map = {}
|
||||||
self.bridge.report_cfi.connect(self.call_callback)
|
self.bridge.report_cfi.connect(self.call_callback)
|
||||||
@ -504,7 +506,6 @@ class WebView(RestartingWebEngineView):
|
|||||||
|
|
||||||
def start_book_load(self, initial_cfi=None, initial_toc_node=None, initial_bookpos=None):
|
def start_book_load(self, initial_cfi=None, initial_toc_node=None, initial_bookpos=None):
|
||||||
key = (set_book_path.path,)
|
key = (set_book_path.path,)
|
||||||
self.clear_history()
|
|
||||||
self.execute_when_ready('start_book_load', key, initial_cfi, initial_toc_node, initial_bookpos, set_book_path.pathtoebook)
|
self.execute_when_ready('start_book_load', key, initial_cfi, initial_toc_node, initial_bookpos, set_book_path.pathtoebook)
|
||||||
|
|
||||||
def execute_when_ready(self, action, *args):
|
def execute_when_ready(self, action, *args):
|
||||||
|
@ -365,6 +365,8 @@ class View:
|
|||||||
self.on_next_section({'forward': True})
|
self.on_next_section({'forward': True})
|
||||||
elif data.name is 'previous_section':
|
elif data.name is 'previous_section':
|
||||||
self.on_next_section({'forward': False})
|
self.on_next_section({'forward': False})
|
||||||
|
elif data.name is 'open_book':
|
||||||
|
self.overlay.open_book()
|
||||||
|
|
||||||
def on_selection_change(self, data):
|
def on_selection_change(self, data):
|
||||||
self.currently_showing.selected_text = data.text
|
self.currently_showing.selected_text = data.text
|
||||||
@ -571,6 +573,7 @@ class View:
|
|||||||
self.hide_overlays()
|
self.hide_overlays()
|
||||||
self.iframe.focus()
|
self.iframe.focus()
|
||||||
is_current_book = self.book and self.book.key == book.key
|
is_current_book = self.book and self.book.key == book.key
|
||||||
|
self.book_load_started = True
|
||||||
if not is_current_book:
|
if not is_current_book:
|
||||||
self.iframe_wrapper.reset()
|
self.iframe_wrapper.reset()
|
||||||
self.content_popup_overlay.iframe_wrapper.reset()
|
self.content_popup_overlay.iframe_wrapper.reset()
|
||||||
@ -912,6 +915,10 @@ class View:
|
|||||||
self.set_progress_frac(data.progress_frac, data.file_progress_frac)
|
self.set_progress_frac(data.progress_frac, data.file_progress_frac)
|
||||||
self.update_header_footer()
|
self.update_header_footer()
|
||||||
window.scrollTo(0, 0) # ensure window is at 0 on mobile where the navbar causes issues
|
window.scrollTo(0, 0) # ensure window is at 0 on mobile where the navbar causes issues
|
||||||
|
if self.book_load_started:
|
||||||
|
self.book_load_started = False
|
||||||
|
if ui_operations.clear_history:
|
||||||
|
ui_operations.clear_history()
|
||||||
|
|
||||||
def set_progress_frac(self, progress_frac, file_progress_frac):
|
def set_progress_frac(self, progress_frac, file_progress_frac):
|
||||||
self.current_progress_frac = progress_frac or 0
|
self.current_progress_frac = progress_frac or 0
|
||||||
|
@ -346,6 +346,8 @@ if window is window.top:
|
|||||||
to_python.export_shortcut_map(smap)
|
to_python.export_shortcut_map(smap)
|
||||||
ui_operations.print_book = def():
|
ui_operations.print_book = def():
|
||||||
to_python.print_book()
|
to_python.print_book()
|
||||||
|
ui_operations.clear_history = def():
|
||||||
|
to_python.clear_history()
|
||||||
|
|
||||||
document.body.appendChild(E.div(id='view'))
|
document.body.appendChild(E.div(id='view'))
|
||||||
window.onerror = onerror
|
window.onerror = onerror
|
||||||
|
Loading…
x
Reference in New Issue
Block a user