@@ -34,6 +34,7 @@ pub struct Library {
|
|||||||
pub shows: Arc<RwLock<Vec<Show>>>,
|
pub shows: Arc<RwLock<Vec<Show>>>,
|
||||||
pub is_done: Arc<RwLock<bool>>,
|
pub is_done: Arc<RwLock<bool>>,
|
||||||
pub user_id: Option<String>,
|
pub user_id: Option<String>,
|
||||||
|
pub display_name: Option<String>,
|
||||||
ev: EventManager,
|
ev: EventManager,
|
||||||
spotify: Arc<Spotify>,
|
spotify: Arc<Spotify>,
|
||||||
pub cfg: Arc<Config>,
|
pub cfg: Arc<Config>,
|
||||||
@@ -41,7 +42,9 @@ pub struct Library {
|
|||||||
|
|
||||||
impl Library {
|
impl Library {
|
||||||
pub fn new(ev: &EventManager, spotify: Arc<Spotify>, cfg: Arc<Config>) -> Self {
|
pub fn new(ev: &EventManager, spotify: Arc<Spotify>, cfg: Arc<Config>) -> Self {
|
||||||
let user_id = spotify.current_user().map(|u| u.id);
|
let current_user = spotify.current_user();
|
||||||
|
let user_id = current_user.as_ref().map(|u| u.id.clone());
|
||||||
|
let display_name = current_user.as_ref().and_then(|u| u.display_name.clone());
|
||||||
|
|
||||||
let library = Self {
|
let library = Self {
|
||||||
tracks: Arc::new(RwLock::new(Vec::new())),
|
tracks: Arc::new(RwLock::new(Vec::new())),
|
||||||
@@ -51,6 +54,7 @@ impl Library {
|
|||||||
shows: Arc::new(RwLock::new(Vec::new())),
|
shows: Arc::new(RwLock::new(Vec::new())),
|
||||||
is_done: Arc::new(RwLock::new(false)),
|
is_done: Arc::new(RwLock::new(false)),
|
||||||
user_id,
|
user_id,
|
||||||
|
display_name,
|
||||||
ev: ev.clone(),
|
ev: ev.clone(),
|
||||||
spotify,
|
spotify,
|
||||||
cfg,
|
cfg,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use crate::ui::tabview::TabView;
|
|||||||
|
|
||||||
pub struct LibraryView {
|
pub struct LibraryView {
|
||||||
tabs: TabView,
|
tabs: TabView,
|
||||||
|
display_name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LibraryView {
|
impl LibraryView {
|
||||||
@@ -45,7 +46,10 @@ impl LibraryView {
|
|||||||
ListView::new(library.shows.clone(), queue, library.clone()),
|
ListView::new(library.shows.clone(), queue, library.clone()),
|
||||||
);
|
);
|
||||||
|
|
||||||
Self { tabs }
|
Self {
|
||||||
|
tabs,
|
||||||
|
display_name: library.display_name.clone(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +59,11 @@ impl ViewWrapper for LibraryView {
|
|||||||
|
|
||||||
impl ViewExt for LibraryView {
|
impl ViewExt for LibraryView {
|
||||||
fn title(&self) -> String {
|
fn title(&self) -> String {
|
||||||
"Library".to_string()
|
if let Some(name) = &self.display_name {
|
||||||
|
format!("Library of {}", name)
|
||||||
|
} else {
|
||||||
|
"Library".to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
||||||
|
|||||||
Reference in New Issue
Block a user