Cleanup previous PR

This commit is contained in:
Kovid Goyal 2023-04-10 15:26:42 +05:30
parent e653df9794
commit 94eee05a2e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 7 deletions

View File

@ -2368,7 +2368,7 @@ class Cache:
def get_all_link_maps_for_book(self, book_id):
'''
Returns all links for all fields referenced by book identified by book_id.
If book_id is None or doesn't exist then the method returns {}.
If book_id doesn't exist then the method returns {}.
Example: Assume author A has link X, author B has link Y, tag S has link
F, and tag T has link G. If book 1 has author A and tag T,
@ -2380,7 +2380,7 @@ class Cache:
:return: {field: {field_value, link_value}, ... for all fields with a field_value having a non-empty link value for that book
'''
if not self.has_id(book_id):
if not self._has_id(book_id):
# Works for book_id is None.
return {}
cached = self.link_maps_cache.get(book_id)

View File

@ -392,8 +392,8 @@ def add_item_specific_entries(menu, data, book_info, copy_menu, search_menu):
ac.setText(_('Remove %s from this book') % escape_for_menu(author))
menu.addAction(ac)
# See if we need to add a click associated link menu line for the author
link_map = get_gui().current_db.new_api.get_all_link_maps_for_book(data.get('book_id', None))
link = link_map.get("authors", {}).get(author, None)
link_map = get_gui().current_db.new_api.get_all_link_maps_for_book(data.get('book_id', -1))
link = link_map.get("authors", {}).get(author)
if link:
menu.addAction(QIcon.ic('external-link'), _('Open associated link'),
lambda : book_info.link_clicked.emit(link))
@ -442,8 +442,8 @@ def add_item_specific_entries(menu, data, book_info, copy_menu, search_menu):
ac.setText(_('Remove %s from this book') % escape_for_menu(remove_name or data.get('original_value') or value))
menu.addAction(ac)
# See if we need to add a click associated link menu line
link_map = get_gui().current_db.new_api.get_all_link_maps_for_book(data.get('book_id', None))
link = link_map.get(field, {}).get(value, None)
link_map = get_gui().current_db.new_api.get_all_link_maps_for_book(data.get('book_id', -1))
link = link_map.get(field, {}).get(value)
if link:
menu.addAction(QIcon.ic('external-link'), _('Open associated link'),
lambda : book_info.link_clicked.emit(link))
@ -520,7 +520,7 @@ def details_context_menu_event(view, ev, book_info, add_popup_action=False, edit
ac.current_url = url
ac.setText(_('Copy link location'))
menu.addAction(ac)
menu.addAction(QIcon.ic('external-link'), _('Open this link'), lambda : book_info.link_clicked.emit(url))
menu.addAction(QIcon.ic('external-link'), _('Open associated link'), lambda : book_info.link_clicked.emit(url))
if not copy_links_added:
create_copy_links(copy_menu)