mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Browser viewer: Fix a regression that caused loading more than one book in the same session or using the back/forward browser buttons to require refreshing the browser.
This commit is contained in:
parent
f4a6f0117d
commit
26f3761ea3
@ -298,7 +298,7 @@ class View:
|
|||||||
}
|
}
|
||||||
return LOADING_DOC.replace(r, def(match, field): return data[field];)
|
return LOADING_DOC.replace(r, def(match, field): return data[field];)
|
||||||
|
|
||||||
def init_iframe(self, iframe_script):
|
def init_iframe(self):
|
||||||
if self.main_srcdoc is None:
|
if self.main_srcdoc is None:
|
||||||
return
|
return
|
||||||
if not self.main_srcdoc:
|
if not self.main_srcdoc:
|
||||||
@ -307,6 +307,14 @@ class View:
|
|||||||
self.iframe.srcdoc = self.main_srcdoc()
|
self.iframe.srcdoc = self.main_srcdoc()
|
||||||
self.main_srcdoc = None
|
self.main_srcdoc = None
|
||||||
|
|
||||||
|
def reset_iframe(self):
|
||||||
|
# Reset the iframe to ensure that all state from previous books is
|
||||||
|
# cleared
|
||||||
|
self.iframe_ready = False
|
||||||
|
if self.main_srcdoc is None:
|
||||||
|
self.main_srcdoc = def():
|
||||||
|
return self.iframe.srcdoc
|
||||||
|
|
||||||
def send_message(self, action, **data):
|
def send_message(self, action, **data):
|
||||||
data.action = action
|
data.action = action
|
||||||
msg = {'data':data, 'encrypted':self.encrypted_communications}
|
msg = {'data':data, 'encrypted':self.encrypted_communications}
|
||||||
@ -390,16 +398,19 @@ class View:
|
|||||||
cfi = '/' + rest
|
cfi = '/' + rest
|
||||||
return name, cfi
|
return name, cfi
|
||||||
|
|
||||||
def display_book(self, book):
|
def hide_overlays(self):
|
||||||
self.overlay.hide()
|
self.overlay.hide()
|
||||||
self.search_overlay.hide()
|
self.search_overlay.hide()
|
||||||
self.content_popup_overlay.hide()
|
self.content_popup_overlay.hide()
|
||||||
|
|
||||||
|
def display_book(self, book):
|
||||||
|
self.hide_overlays()
|
||||||
|
is_current_book = self.book and self.book.key == book.key
|
||||||
|
if not is_current_book:
|
||||||
|
self.reset_iframe()
|
||||||
self.book = current_book.book = book
|
self.book = current_book.book = book
|
||||||
self.ui.db.update_last_read_time(book)
|
self.ui.db.update_last_read_time(book)
|
||||||
self.loaded_resources = {}
|
self.loaded_resources = {}
|
||||||
# Ensure the iframe is cleared so that no state is persisted between
|
|
||||||
# book loads
|
|
||||||
self.iframe_ready = False
|
|
||||||
pos = {'replace_history':True}
|
pos = {'replace_history':True}
|
||||||
unkey = username_key(get_interface_data().username)
|
unkey = username_key(get_interface_data().username)
|
||||||
name = book.manifest.spine[0]
|
name = book.manifest.spine[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user