Skip to content

Commit

Permalink
Fix search URL action not changing library if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Nov 21, 2020
1 parent 606bf90 commit 33dbbb2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/calibre/gui2/ui.py
Expand Up @@ -673,12 +673,7 @@ def decode_library_id(x):
def doit():
self.library_view.select_rows((book_id,))

if library_id != getattr(self.current_db.new_api, 'server_library_id', None):
self.library_moved(library_path)
QTimer.singleShot(0, doit)
else:
doit()

self.perform_url_action(library_id, library_path, doit)
elif action == 'view-book':
parts = tuple(filter(None, path.split('/')))
if len(parts) != 3:
Expand All @@ -701,12 +696,7 @@ def doit():
at = at[0]
view.view_format_by_id(book_id, fmt.upper(), open_at=at)

if library_id != getattr(self.current_db.new_api, 'server_library_id', None):
self.library_moved(library_path)
QTimer.singleShot(0, doit)
else:
doit()

self.perform_url_action(library_id, library_path, doit)
elif action == 'search':
parts = tuple(filter(None, path.split('/')))
if len(parts) != 1:
Expand All @@ -723,7 +713,17 @@ def doit():
if sq:
sq = sq[0]
sq = sq or ''
self.search.set_search_string(sq)

def doit():
self.search.set_search_string(sq)
self.perform_url_action(library_id, library_path, doit)

def perform_url_action(self, library_id, library_path, func):
if library_id != getattr(self.current_db.new_api, 'server_library_id', None):
self.library_moved(library_path)
QTimer.singleShot(0, func)
else:
func()

def message_from_another_instance(self, msg):
if isinstance(msg, bytes):
Expand Down

0 comments on commit 33dbbb2

Please sign in to comment.