feat: add a refresh toggle

This commit is contained in:
2026-01-05 22:46:05 +01:00
parent 124a962d72
commit 0cf9884c6c

View File

@@ -47,6 +47,7 @@ class Auditui(App):
("n", "sort", "Sort by name"), ("n", "sort", "Sort by name"),
("p", "sort_by_progress", "Sort by progress"), ("p", "sort_by_progress", "Sort by progress"),
("a", "show_all", "All/Unfinished"), ("a", "show_all", "All/Unfinished"),
("r", "refresh", "Refresh"),
("enter", "play_selected", "Play"), ("enter", "play_selected", "Play"),
("space", "toggle_playback", "Pause/Resume"), ("space", "toggle_playback", "Pause/Resume"),
("left", "seek_backward", "-30s"), ("left", "seek_backward", "-30s"),
@@ -227,7 +228,10 @@ class Auditui(App):
self._search_text_cache.clear() self._search_text_cache.clear()
self._prime_search_cache(items) self._prime_search_cache(items)
self.update_status(f"Loaded {len(items)} books") self.update_status(f"Loaded {len(items)} books")
self.show_unfinished() if self.show_all_mode:
self.show_all()
else:
self.show_unfinished()
def on_library_error(self, error: str) -> None: def on_library_error(self, error: str) -> None:
"""Handle library fetch error.""" """Handle library fetch error."""
@@ -295,6 +299,14 @@ class Auditui(App):
else: else:
self.show_all() self.show_all()
def action_refresh(self) -> None:
"""Refresh the library data from the API."""
if not self.client:
self.update_status("Not authenticated. Cannot refresh.")
return
self.update_status("Refreshing library...")
self.fetch_library()
def action_play_selected(self) -> None: def action_play_selected(self) -> None:
"""Start playing the selected book.""" """Start playing the selected book."""
if not self.download_manager: if not self.download_manager: