mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Auto-refresh book list after adding books
This commit is contained in:
parent
8a793eb063
commit
72deb18b6f
@ -6,7 +6,7 @@ from elementmaker import E
|
|||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
from ajax import ajax_send_file
|
from ajax import ajax_send_file
|
||||||
from book_list.library_data import loaded_books_query
|
from book_list.library_data import force_refresh_on_next_load, loaded_books_query
|
||||||
from book_list.router import back
|
from book_list.router import back
|
||||||
from book_list.top_bar import create_top_bar
|
from book_list.top_bar import create_top_bar
|
||||||
from book_list.ui import query_as_href, show_panel
|
from book_list.ui import query_as_href, show_panel
|
||||||
@ -94,6 +94,7 @@ def on_complete(container_id, job_id, end_type, xhr, ev):
|
|||||||
data = JSON.parse(xhr.responseText)
|
data = JSON.parse(xhr.responseText)
|
||||||
if data.book_id:
|
if data.book_id:
|
||||||
list_added_book(container, data)
|
list_added_book(container, data)
|
||||||
|
force_refresh_on_next_load()
|
||||||
else:
|
else:
|
||||||
list_duplicate_book(container, container_id, job_id, data, this)
|
list_duplicate_book(container, container_id, job_id, data, this)
|
||||||
elif end_type is 'abort':
|
elif end_type is 'abort':
|
||||||
|
@ -11,7 +11,7 @@ from session import get_interface_data
|
|||||||
from utils import parse_url_params
|
from utils import parse_url_params
|
||||||
|
|
||||||
load_status = {'loading':True, 'ok':False, 'error_html':None, 'current_fetch': None}
|
load_status = {'loading':True, 'ok':False, 'error_html':None, 'current_fetch': None}
|
||||||
library_data = {'metadata':{}, 'previous_book_ids': v'[]'}
|
library_data = {'metadata':{}, 'previous_book_ids': v'[]', 'force_refresh': False}
|
||||||
|
|
||||||
|
|
||||||
def current_library_id():
|
def current_library_id():
|
||||||
@ -156,20 +156,31 @@ def set_book_metadata(book_id, value):
|
|||||||
library_data.metadata[book_id] = value
|
library_data.metadata[book_id] = value
|
||||||
|
|
||||||
|
|
||||||
|
def force_refresh_on_next_load():
|
||||||
|
library_data.force_refresh = True
|
||||||
|
|
||||||
|
|
||||||
def ensure_current_library_data():
|
def ensure_current_library_data():
|
||||||
q = url_books_query()
|
fr = library_data.force_refresh
|
||||||
loaded = loaded_books_query()
|
library_data.force_refresh = False
|
||||||
matches = True
|
|
||||||
|
|
||||||
def is_same(a, b):
|
def is_same(a, b):
|
||||||
if not a and not b:
|
if not a and not b:
|
||||||
return True
|
return True
|
||||||
return a is b
|
return a is b
|
||||||
|
|
||||||
for key in q:
|
|
||||||
if not is_same(q[key], loaded[key]):
|
if fr:
|
||||||
matches = False
|
matches = False
|
||||||
break
|
else:
|
||||||
|
q = url_books_query()
|
||||||
|
loaded = loaded_books_query()
|
||||||
|
matches = True
|
||||||
|
|
||||||
|
for key in q:
|
||||||
|
if not is_same(q[key], loaded[key]):
|
||||||
|
matches = False
|
||||||
|
break
|
||||||
if not matches:
|
if not matches:
|
||||||
fetch_init_data()
|
fetch_init_data()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user