mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1895368 [[Content server] Removed book show up when going through books](https://bugs.launchpad.net/calibre/+bug/1895368)
This commit is contained in:
parent
1673d646d6
commit
ceceff8cc3
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user