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 shows: Arc<RwLock<Vec<Show>>>,
|
||||
pub is_done: Arc<RwLock<bool>>,
|
||||
user_id: Option<String>,
|
||||
pub user_id: Option<String>,
|
||||
ev: EventManager,
|
||||
spotify: Arc<Spotify>,
|
||||
pub cfg: Arc<Config>,
|
||||
|
||||
@@ -19,6 +19,7 @@ pub struct Playlist {
|
||||
pub snapshot_id: String,
|
||||
pub num_tracks: usize,
|
||||
pub tracks: Option<Vec<Track>>,
|
||||
pub collaborative: bool
|
||||
}
|
||||
|
||||
impl Playlist {
|
||||
@@ -128,6 +129,7 @@ impl From<&SimplifiedPlaylist> for Playlist {
|
||||
snapshot_id: list.snapshot_id.clone(),
|
||||
num_tracks,
|
||||
tracks: None,
|
||||
collaborative: list.collaborative,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,6 +143,7 @@ impl From<&FullPlaylist> for Playlist {
|
||||
snapshot_id: list.snapshot_id.clone(),
|
||||
num_tracks: list.tracks.total as usize,
|
||||
tracks: None,
|
||||
collaborative: list.collaborative
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,12 @@ impl ContextMenu {
|
||||
track: Track,
|
||||
) -> Modal<Dialog> {
|
||||
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() {
|
||||
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| {
|
||||
|
||||
Reference in New Issue
Block a user