mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix syncing for anon users
This commit is contained in:
parent
18c779a1a8
commit
c003690502
@ -113,7 +113,7 @@ def show_recent_stage2(books):
|
||||
to_sync = v'[]'
|
||||
username = get_interface_data().username
|
||||
for book in books:
|
||||
if username and to_sync.length < 10:
|
||||
if to_sync.length < 10:
|
||||
lr = book.last_read[username_key(username)] or new Date(0) # noqa: unused-local
|
||||
to_sync.push(v'[book.key, lr]')
|
||||
authors = book.metadata.authors.join(' & ') if book.metadata.authors else _('Unknown')
|
||||
@ -128,8 +128,7 @@ def show_recent_stage2(books):
|
||||
))
|
||||
if book.cover_name:
|
||||
db.get_file(book, book.cover_name, show_cover.bind(img_id))
|
||||
if username:
|
||||
start_sync(to_sync)
|
||||
start_sync(to_sync)
|
||||
container.appendChild(E.div(style='margin: 1rem 1rem',
|
||||
create_button(
|
||||
_('Browse all downloaded books…'),
|
||||
|
@ -206,18 +206,18 @@ class DB:
|
||||
book.book_hash = manifest.book_hash.hash
|
||||
book.stored_files = {}
|
||||
book.is_complete = False
|
||||
if get_interface_data().username:
|
||||
newest_epoch = newest_pos = None
|
||||
for pos in manifest.last_read_positions:
|
||||
if newest_epoch is None or pos.epoch > newest_epoch:
|
||||
newest_epoch = pos.epoch
|
||||
newest_pos = pos.cfi
|
||||
unkey = username_key(get_interface_data().username)
|
||||
if newest_pos:
|
||||
book.last_read[unkey] = new Date(newest_epoch * 1000)
|
||||
book.last_read_position[unkey] = newest_pos
|
||||
if manifest.annotations_map:
|
||||
book.annotations_map[unkey] = manifest.annotations_map
|
||||
newest_epoch = newest_pos = None
|
||||
for pos in manifest.last_read_positions:
|
||||
if newest_epoch is None or pos.epoch > newest_epoch:
|
||||
newest_epoch = pos.epoch
|
||||
newest_pos = pos.cfi
|
||||
username = get_interface_data().username
|
||||
unkey = username_key(username)
|
||||
if newest_pos and username:
|
||||
book.last_read[unkey] = new Date(newest_epoch * 1000)
|
||||
book.last_read_position[unkey] = newest_pos
|
||||
if manifest.annotations_map:
|
||||
book.annotations_map[unkey] = manifest.annotations_map
|
||||
|
||||
v'delete manifest.metadata'
|
||||
v'delete manifest.last_read_positions'
|
||||
|
Loading…
x
Reference in New Issue
Block a user