mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
When re-opening a previously opened library from the home page, preserve the virtual library
This commit is contained in:
parent
508c8578fd
commit
16f0ab75a9
@ -7,7 +7,7 @@ from gettext import gettext as _
|
||||
|
||||
from book_list.cover_grid import BORDER_RADIUS
|
||||
from book_list.globals import get_db
|
||||
from book_list.library_data import sync_library_books
|
||||
from book_list.library_data import sync_library_books, last_virtual_library_for
|
||||
from book_list.router import open_book, update_window_title
|
||||
from book_list.top_bar import create_top_bar
|
||||
from book_list.ui import set_default_panel_handler, show_panel
|
||||
@ -159,7 +159,11 @@ def init(container_id):
|
||||
cl.appendChild(
|
||||
create_button(library_name, icon='library', action=def(ev):
|
||||
lib_id = ev.currentTarget.dataset.lid
|
||||
show_panel('book_list', {'library_id': lib_id})
|
||||
q = {'library_id': lib_id}
|
||||
vlid = last_virtual_library_for(lib_id)
|
||||
if vlid:
|
||||
q.vl = vlid
|
||||
show_panel('book_list', q)
|
||||
))
|
||||
cl.lastChild.style.margin = '1ex 1rem'
|
||||
cl.lastChild.dataset.lid = library_id
|
||||
|
@ -23,6 +23,12 @@ def current_virtual_library():
|
||||
return q.vl or ''
|
||||
|
||||
|
||||
def last_virtual_library_for(library_id):
|
||||
if last_virtual_library_for.library_id is library_id:
|
||||
return last_virtual_library_for.vl or ''
|
||||
return ''
|
||||
|
||||
|
||||
def url_books_query(sd):
|
||||
q = parse_url_params()
|
||||
sd = sd or get_session_data()
|
||||
@ -63,6 +69,13 @@ def update_library_data(data):
|
||||
load_status.error_html = None
|
||||
for key in 'search_result sortable_fields field_metadata metadata'.split(' '):
|
||||
library_data[key] = data[key]
|
||||
sr = library_data.search_result
|
||||
if sr:
|
||||
last_virtual_library_for.library_id = sr.library_id
|
||||
last_virtual_library_for.vl = sr.vl
|
||||
else:
|
||||
last_virtual_library_for.library_id = None
|
||||
last_virtual_library_for.vl = None
|
||||
|
||||
|
||||
def on_data_loaded(end_type, xhr, ev):
|
||||
|
Loading…
x
Reference in New Issue
Block a user