Consistency with other selectable lists
All checks were successful
Cargo CI / Build and Test (pull_request) Successful in 1m59s
Cargo CI / Lint (pull_request) Successful in 1m5s

This commit is contained in:
Wojciech Kozlowski 2024-08-29 16:37:10 +02:00
parent 2c8754ce46
commit 2b92ab73e1
2 changed files with 8 additions and 8 deletions

View File

@ -1,15 +1,15 @@
use musichoard::collection::album::Album;
use ratatui::widgets::{List, ListItem};
use crate::tui::{lib::interface::musicbrainz::Match, ui::display::UiDisplay};
use crate::tui::{app::WidgetState, lib::interface::musicbrainz::Match, ui::display::UiDisplay};
#[derive(Default)]
pub struct AlbumMatchesState<'a> {
pub struct AlbumMatchesState<'a, 'b> {
pub list: List<'a>,
pub state: &'b mut WidgetState,
}
impl<'a> AlbumMatchesState<'a> {
pub fn new(matches: &[Match<Album>]) -> Self {
impl<'a, 'b> AlbumMatchesState<'a, 'b> {
pub fn new(matches: &[Match<Album>], state: &'b mut WidgetState) -> Self {
let list = List::new(
matches
.iter()
@ -18,6 +18,6 @@ impl<'a> AlbumMatchesState<'a> {
.collect::<Vec<ListItem>>(),
);
AlbumMatchesState { list }
AlbumMatchesState { list, state }
}
}

View File

@ -293,8 +293,8 @@ impl Ui {
) {
let area = OverlayBuilder::default().build(frame.size());
let matching_string = UiDisplay::display_matching_info(matching);
let st = matches.map(AlbumMatchesState::new).unwrap_or_default();
Self::render_overlay_list_widget(&matching_string, st.list, state, true, area, frame)
let st = AlbumMatchesState::new(matches.unwrap_or_default(), state);
Self::render_overlay_list_widget(&matching_string, st.list, st.state, true, area, frame)
}
fn render_reload_overlay(frame: &mut Frame) {