implimented first itteration of drill down
This commit is contained in:
83
src/main.rs
83
src/main.rs
@@ -432,10 +432,50 @@ fn handle_key(app: &mut App, code: KeyCode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
View::Library { title, items, selected, .. } => {
|
||||
if items.is_empty() { return; }
|
||||
let it = &items[*selected];
|
||||
|
||||
let ty = it.item_type.as_deref().unwrap_or("");
|
||||
|
||||
// Shows -> Seasons -> Episodes
|
||||
if ty == "Series" {
|
||||
let q = core::jellyfin::LibraryQuery::all()
|
||||
.with_parent(it.id.clone())
|
||||
.with_item_types("Season");
|
||||
open_children(app, format!("{} > {}", title, it.name), q);
|
||||
return;
|
||||
}
|
||||
if ty == "Season" {
|
||||
let q = core::jellyfin::LibraryQuery::all()
|
||||
.with_parent(it.id.clone())
|
||||
.with_item_types("Episode");
|
||||
open_children(app, format!("{} > {}", title, it.name), q);
|
||||
return;
|
||||
}
|
||||
|
||||
// MusicArtist -> MusicAlbum -> Audio
|
||||
if ty == "MusicArtist" {
|
||||
let q = core::jellyfin::LibraryQuery::all()
|
||||
.with_parent(it.id.clone())
|
||||
.with_item_types("MusicAlbum");
|
||||
open_children(app, format!("{} > {}", title, it.name), q);
|
||||
return;
|
||||
}
|
||||
if ty == "MusicAlbum" {
|
||||
let q = core::jellyfin::LibraryQuery::all()
|
||||
.with_parent(it.id.clone())
|
||||
.with_item_types("Audio");
|
||||
open_children(app, format!("{} > {}", title, it.name), q);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise: later we can make Enter “play”, “details”, etc.
|
||||
app.status = format!("No drilldown for type: {}", ty);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
KeyCode::Esc | KeyCode::Backspace => {
|
||||
if app.view_stack.len() > 1 {
|
||||
app.view_stack.pop();
|
||||
@@ -443,7 +483,6 @@ fn handle_key(app: &mut App, code: KeyCode) {
|
||||
app.selected = 0;
|
||||
}
|
||||
}
|
||||
|
||||
KeyCode::Up | KeyCode::Char('k') => {
|
||||
match app.view_stack.last_mut().unwrap() {
|
||||
View::Categories => {
|
||||
@@ -475,7 +514,6 @@ fn handle_key(app: &mut App, code: KeyCode) {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
KeyCode::Down | KeyCode::Char('j') => {
|
||||
match app.view_stack.last_mut().unwrap() {
|
||||
View::Categories => {
|
||||
@@ -510,7 +548,6 @@ fn handle_key(app: &mut App, code: KeyCode) {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
KeyCode::Char('/') => {
|
||||
let scope = match app.current_view() {
|
||||
View::Categories => SearchScope::All,
|
||||
@@ -527,12 +564,10 @@ fn handle_key(app: &mut App, code: KeyCode) {
|
||||
input: String::new(),
|
||||
});
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn load_next_library_page(app: &mut App) {
|
||||
// pull info + mark loading
|
||||
let (query, next_start, total, page_size) = match app.view_stack.last_mut() {
|
||||
@@ -580,7 +615,6 @@ fn finish_loading(app: &mut App) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn maybe_prefetch(app: &mut App) {
|
||||
const PREFETCH_ROWS: usize = 0;
|
||||
|
||||
@@ -615,7 +649,6 @@ fn ensure_loaded_to_end(app: &mut App) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn ui(frame: &mut Frame, app: &App) {
|
||||
let area = frame.area();
|
||||
let panes = layout(area);
|
||||
@@ -805,6 +838,40 @@ fn render_library(
|
||||
);
|
||||
}
|
||||
|
||||
fn open_children(app: &mut App, title: String, query: core::jellyfin::LibraryQuery) {
|
||||
let cfg = match &app.config {
|
||||
Some(c) => c.clone(),
|
||||
None => { app.status = "No config loaded".into(); return; }
|
||||
};
|
||||
let user_id = match cfg.user_id.as_deref() {
|
||||
Some(u) => u,
|
||||
None => { app.status = "Missing user_id in config (login again)".into(); return; }
|
||||
};
|
||||
let client = match core::jellyfin::JellyfinClient::from_config(&cfg) {
|
||||
Ok(c) => c,
|
||||
Err(e) => { app.status = e; return; }
|
||||
};
|
||||
|
||||
app.status = format!("Fetching {}...", title);
|
||||
|
||||
match client.list_items(user_id, query.clone(), 0, PAGE_SIZE) {
|
||||
Ok(page) => {
|
||||
app.view_stack.push(View::Library {
|
||||
title,
|
||||
query,
|
||||
items: page.items,
|
||||
selected: 0,
|
||||
start_index: 0,
|
||||
total: page.total,
|
||||
page_size: PAGE_SIZE,
|
||||
loading: false,
|
||||
});
|
||||
app.status = "Loaded".into();
|
||||
}
|
||||
Err(e) => app.status = format!("Fetch failed: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
struct Panes {
|
||||
top: Rect,
|
||||
left_main: Rect,
|
||||
|
||||
Reference in New Issue
Block a user