Removing tracks from playlists on a global stage
This commit is contained in:
@ -29,6 +29,8 @@ class ContextMenu extends React.Component{
|
||||
case 'editable-playlist':
|
||||
items = [
|
||||
{ handleClick: 'playItems', label: 'Play' },
|
||||
{ handleClick: 'playItemsNext', label: 'Play next' },
|
||||
{ handleClick: 'addToQueue', label: 'Add to queue' },
|
||||
{ handleClick: 'removeFromPlaylist', label: 'Remove' }
|
||||
];
|
||||
break;
|
||||
@ -113,7 +115,7 @@ class ContextMenu extends React.Component{
|
||||
}
|
||||
|
||||
removeFromPlaylist(){
|
||||
console.log('removeFromPlaylist')
|
||||
this.props.uiActions.removeTracksFromPlaylist( this.props.context_menu.data.selected_tracks_indexes )
|
||||
this.props.uiActions.hideContextMenu();
|
||||
}
|
||||
|
||||
|
||||
@ -92,8 +92,10 @@ class TrackList extends React.Component{
|
||||
}
|
||||
|
||||
handleContextMenu(e, index){
|
||||
var selected_tracks = this.selectedTracks()
|
||||
var data = {
|
||||
selected_tracks: this.selectedTracks()
|
||||
selected_tracks: selected_tracks,
|
||||
selected_tracks_indexes: this.tracksIndexes( selected_tracks )
|
||||
}
|
||||
this.props.uiActions.showContextMenu( e, this.props.context, data )
|
||||
}
|
||||
@ -105,6 +107,14 @@ class TrackList extends React.Component{
|
||||
return this.state.tracks.filter(isSelected)
|
||||
}
|
||||
|
||||
tracksIndexes(tracks){
|
||||
var indexes = []
|
||||
for( var i = 0; i < tracks.length; i++ ){
|
||||
indexes.push( this.props.tracks.indexOf(tracks[i]))
|
||||
}
|
||||
return indexes
|
||||
}
|
||||
|
||||
playTracks(){
|
||||
|
||||
var tracks = this.selectedTracks();
|
||||
@ -123,12 +133,12 @@ class TrackList extends React.Component{
|
||||
}
|
||||
|
||||
removeTracks(){
|
||||
|
||||
var tracks = this.selectedTracks();
|
||||
|
||||
// if we've got a specific action, run it
|
||||
// if this tracklist handles removal, handle it
|
||||
if( typeof(this.props.removeTracks) !== 'undefined' ){
|
||||
return this.props.removeTracks( tracks );
|
||||
var tracks = this.selectedTracks();
|
||||
var tracks_indexes = this.tracksIndexes(tracks);
|
||||
return this.props.removeTracks( tracks_indexes );
|
||||
}
|
||||
|
||||
// by default, do nothing
|
||||
|
||||
Reference in New Issue
Block a user