Only show playlists where the user is allowed to add tracks when trying to add tracks (#329)
* Only show playlists where the user is allowed to add tracks * Expose user_id from library and use it to reduce api calls
This commit is contained in:
@@ -33,7 +33,7 @@ pub struct Library {
|
|||||||
pub playlists: Arc<RwLock<Vec<Playlist>>>,
|
pub playlists: Arc<RwLock<Vec<Playlist>>>,
|
||||||
pub shows: Arc<RwLock<Vec<Show>>>,
|
pub shows: Arc<RwLock<Vec<Show>>>,
|
||||||
pub is_done: Arc<RwLock<bool>>,
|
pub is_done: Arc<RwLock<bool>>,
|
||||||
user_id: Option<String>,
|
pub user_id: Option<String>,
|
||||||
ev: EventManager,
|
ev: EventManager,
|
||||||
spotify: Arc<Spotify>,
|
spotify: Arc<Spotify>,
|
||||||
pub cfg: Arc<Config>,
|
pub cfg: Arc<Config>,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ pub struct Playlist {
|
|||||||
pub snapshot_id: String,
|
pub snapshot_id: String,
|
||||||
pub num_tracks: usize,
|
pub num_tracks: usize,
|
||||||
pub tracks: Option<Vec<Track>>,
|
pub tracks: Option<Vec<Track>>,
|
||||||
|
pub collaborative: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Playlist {
|
impl Playlist {
|
||||||
@@ -128,6 +129,7 @@ impl From<&SimplifiedPlaylist> for Playlist {
|
|||||||
snapshot_id: list.snapshot_id.clone(),
|
snapshot_id: list.snapshot_id.clone(),
|
||||||
num_tracks,
|
num_tracks,
|
||||||
tracks: None,
|
tracks: None,
|
||||||
|
collaborative: list.collaborative,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,6 +143,7 @@ impl From<&FullPlaylist> for Playlist {
|
|||||||
snapshot_id: list.snapshot_id.clone(),
|
snapshot_id: list.snapshot_id.clone(),
|
||||||
num_tracks: list.tracks.total as usize,
|
num_tracks: list.tracks.total as usize,
|
||||||
tracks: None,
|
tracks: None,
|
||||||
|
collaborative: list.collaborative
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,12 @@ impl ContextMenu {
|
|||||||
track: Track,
|
track: Track,
|
||||||
) -> Modal<Dialog> {
|
) -> Modal<Dialog> {
|
||||||
let mut list_select: SelectView<Playlist> = SelectView::new().autojump();
|
let mut list_select: SelectView<Playlist> = SelectView::new().autojump();
|
||||||
|
let current_user_id = library.user_id.as_ref().unwrap();
|
||||||
|
|
||||||
for list in library.items().iter() {
|
for list in library.items().iter() {
|
||||||
list_select.add_item(list.name.clone(), list.clone());
|
if current_user_id == &list.owner_id || list.collaborative {
|
||||||
|
list_select.add_item(list.name.clone(), list.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list_select.set_on_submit(move |s, selected| {
|
list_select.set_on_submit(move |s, selected| {
|
||||||
|
|||||||
Reference in New Issue
Block a user