Fix #1895368 [[Content server] Removed book show up when going through books](https://bugs.launchpad.net/calibre/+bug/1895368)

This commit is contained in:
Kovid Goyal 2020-09-13 16:34:53 +05:30
parent 1673d646d6
commit ceceff8cc3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 18 additions and 1 deletions

View File

@ -7,7 +7,7 @@ from gettext import gettext as _
from ajax import ajax
from book_list.add import write_access_error
from book_list.library_data import book_after, force_refresh_on_next_load
from book_list.library_data import book_after, force_refresh_on_next_load, remove_book
from book_list.router import back
from book_list.ui import show_panel
from dom import clear
@ -25,6 +25,7 @@ def delete_from_cache(library_id, book_id, title):
def refresh_after_delete(book_id, library_id):
force_refresh_on_next_load()
next_book_id = book_after(book_id)
remove_book(book_id)
if next_book_id:
show_panel('book_details', {'book_id': str(next_book_id), 'library_id': library_id}, True)
else:

View File

@ -107,6 +107,22 @@ def current_book_ids():
return library_data.previous_book_ids.concat(library_data.search_result.book_ids)
def remove_from_array(array, item):
while True:
idx = array.indexOf(item)
if idx < 0:
break
array.splice(idx, 1)
def remove_book(book_id):
book_id = int(book_id)
if library_data.previous_book_ids:
remove_from_array(library_data.previous_book_ids, book_id)
if library_data.search_result?.book_ids:
remove_from_array(library_data.search_result.book_ids, book_id)
def book_after(book_id, delta):
if not delta:
delta = 1