mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Prune deleted books from recently read by user list
This commit is contained in:
parent
9a1ef22b39
commit
c5427c5ebe
@ -146,6 +146,16 @@ def custom_list_template():
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
def book_exists(x, ctx, rd):
|
||||||
|
try:
|
||||||
|
db = ctx.get_library(rd, x['library_id'])
|
||||||
|
if db is None:
|
||||||
|
raise Exception('')
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
return bool(db.new_api.has_format(x['book_id'], x['format']))
|
||||||
|
|
||||||
|
|
||||||
def basic_interface_data(ctx, rd):
|
def basic_interface_data(ctx, rd):
|
||||||
ans = {
|
ans = {
|
||||||
'username': rd.username,
|
'username': rd.username,
|
||||||
@ -169,7 +179,9 @@ def basic_interface_data(ctx, rd):
|
|||||||
}
|
}
|
||||||
ans['library_map'], ans['default_library_id'] = ctx.library_info(rd)
|
ans['library_map'], ans['default_library_id'] = ctx.library_info(rd)
|
||||||
if ans['username']:
|
if ans['username']:
|
||||||
ans['recently_read_by_user'] = tuple(x for x in last_read_cache().get_recently_read(ans['username']) if x['library_id'] in ans['library_map'])
|
ans['recently_read_by_user'] = tuple(
|
||||||
|
x for x in last_read_cache().get_recently_read(ans['username'])
|
||||||
|
if x['library_id'] in ans['library_map'] and book_exists(x, ctx, rd))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user