diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index a73e2bfe36..75d1183674 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -329,7 +329,7 @@ class View: self.modal_overlays = v'[self.selection_bar, self.read_aloud, self.hints]' self.processing_spine_item_display = False self.pending_load = None - self.currently_showing = {'selection': {'empty': True}} + self.currently_showing = {'selection': {'empty': True}, 'on_load':v'[]'} self.book_scrollbar.apply_visibility() self.annotations_manager = AnnotationsManager(self) @@ -1037,7 +1037,7 @@ class View: idx = spine.indexOf(name) self.currently_showing = { 'name':name, 'settings':self.iframe_settings(name), 'initial_position':initial_position, - 'loading':True, 'spine_index': idx, 'selection': {'empty': True}, + 'loading':True, 'spine_index': idx, 'selection': {'empty': True}, 'on_load': v'[]', } self.show_loading() set_current_spine_item(name) @@ -1382,6 +1382,9 @@ class View: ui_operations.content_file_changed(self.currently_showing.name) if self.read_aloud.is_visible: self.read_aloud.play() + for x in self.currently_showing.on_load: + x() + self.currently_showing.on_load = v'[]' def set_progress_frac(self, progress_frac, file_progress_frac, page_counts): self.current_progress_frac = progress_frac or 0 @@ -1454,7 +1457,10 @@ class View: def show_search_result(self, sr): if self.currently_showing.name is sr.file_name: - self.iframe_wrapper.send_message('show_search_result', search_result=sr) + if self.currently_showing.loading: + self.currently_showing.on_load.push(self.show_search_result.bind(None, sr)) + else: + self.iframe_wrapper.send_message('show_search_result', search_result=sr) else: self.show_name(sr.file_name, initial_position={'type':'search_result', 'search_result':sr, 'replace_history':True}) if self.search_result_discovery?.on_discovery is sr.on_discovery: