Removing/unfollowing playlists
This commit is contained in:
@ -121,13 +121,13 @@ class ContextMenu extends React.Component{
|
||||
|
||||
switch (helpers.uriType(item.uri)){
|
||||
case 'artist':
|
||||
return (this.props.library_artists && this.props.library_artists.indexOf(item.uri) > -1)
|
||||
return (this.props.spotify_library_artists && this.props.spotify_library_artists.indexOf(item.uri) > -1)
|
||||
break
|
||||
case 'album':
|
||||
return (this.props.library_albums && this.props.library_albums.indexOf(item.uri) > -1)
|
||||
return (this.props.spotify_library_albums && this.props.spotify_library_albums.indexOf(item.uri) > -1)
|
||||
break
|
||||
case 'playlist':
|
||||
return (this.props.library_playlists && this.props.library_playlists.indexOf(item.uri) > -1)
|
||||
return (this.props.spotify_library_playlists && this.props.spotify_library_playlists.indexOf(item.uri) > -1)
|
||||
break
|
||||
}
|
||||
return false
|
||||
@ -195,6 +195,11 @@ class ContextMenu extends React.Component{
|
||||
this.props.coreActions.removeTracksFromPlaylist(this.props.menu.tracklist_uri, this.props.menu.indexes)
|
||||
}
|
||||
|
||||
deletePlaylist(e){
|
||||
this.props.uiActions.hideContextMenu()
|
||||
this.props.coreActions.deletePlaylist(this.props.menu.uris[0])
|
||||
}
|
||||
|
||||
startRadio(e){
|
||||
this.props.uiActions.hideContextMenu()
|
||||
this.props.pusherActions.startRadio(this.props.menu.uris)
|
||||
@ -259,6 +264,19 @@ class ContextMenu extends React.Component{
|
||||
)
|
||||
}
|
||||
|
||||
var list = <span className="menu-item-wrapper"><span className="menu-item grey-text">No writable playlists</span></span>
|
||||
if (playlists.length > 0){
|
||||
list = playlists.map(playlist => {
|
||||
return (
|
||||
<span className="menu-item-wrapper" key={playlist.uri}>
|
||||
<a className="menu-item" onClick={e => this.addTracksToPlaylist(e,playlist.uri) }>
|
||||
<span className="label">{ playlist.name }</span>
|
||||
</a>
|
||||
</span>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={this.state.submenu_expanded ? 'submenu expanded' : 'submenu'}>
|
||||
<span className="menu-item-wrapper">
|
||||
@ -270,17 +288,7 @@ class ContextMenu extends React.Component{
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
{
|
||||
playlists.map( playlist => {
|
||||
return (
|
||||
<span className="menu-item-wrapper" key={playlist.uri}>
|
||||
<a className="menu-item" onClick={e => this.addTracksToPlaylist(e,playlist.uri) }>
|
||||
<span className="label">{ playlist.name }</span>
|
||||
</a>
|
||||
</span>
|
||||
)
|
||||
})
|
||||
}
|
||||
{list}
|
||||
{loader}
|
||||
</div>
|
||||
)
|
||||
@ -476,6 +484,14 @@ class ContextMenu extends React.Component{
|
||||
</span>
|
||||
)
|
||||
|
||||
var delete_playlist = (
|
||||
<span className="menu-item-wrapper">
|
||||
<a className="menu-item" onClick={e => this.deletePlaylist(e)}>
|
||||
<span className="label">Delete</span>
|
||||
</a>
|
||||
</span>
|
||||
)
|
||||
|
||||
var copy_uris = (
|
||||
<span className="menu-item-wrapper">
|
||||
<a className="menu-item" onClick={e => this.copyURIs(e)}>
|
||||
@ -522,6 +538,18 @@ class ContextMenu extends React.Component{
|
||||
)
|
||||
break
|
||||
|
||||
case 'editable-playlist':
|
||||
return (
|
||||
<div>
|
||||
{play_playlist}
|
||||
{context.source == 'spotify' ? go_to_user : null}
|
||||
{copy_uris}
|
||||
{this.canBeInLibrary() ? toggle_in_library : null}
|
||||
{delete_playlist}
|
||||
</div>
|
||||
)
|
||||
break
|
||||
|
||||
case 'queue-track':
|
||||
return (
|
||||
<div>
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
|
||||
import * as helpers from '../../helpers'
|
||||
var spotifyActions = require('../../services/spotify/actions')
|
||||
var mopidyActions = require('../../services/mopidy/actions')
|
||||
|
||||
export function getBroadcasts(){
|
||||
return (dispatch, getState) => {
|
||||
@ -84,7 +86,7 @@ export function reorderPlaylistTracks( uri, indexes, insert_before, snapshot_id
|
||||
}
|
||||
|
||||
export function savePlaylist(uri, name, description = '', is_public = false, is_collaborative = false){
|
||||
switch( helpers.uriSource( uri ) ){
|
||||
switch (helpers.uriSource(uri)){
|
||||
|
||||
case 'spotify':
|
||||
return {
|
||||
@ -107,23 +109,28 @@ export function savePlaylist(uri, name, description = '', is_public = false, is_
|
||||
}
|
||||
|
||||
export function createPlaylist(scheme, name, description = '', is_public = false, is_collaborative = false){
|
||||
switch( scheme ){
|
||||
switch (scheme){
|
||||
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_CREATE_PLAYLIST',
|
||||
name: name,
|
||||
description: (description == '' ? null : description),
|
||||
is_public: is_public,
|
||||
is_collaborative: is_collaborative
|
||||
if (description == ''){
|
||||
description = null
|
||||
}
|
||||
return spotifyActions.createPlaylist( name, description, is_public, is_collaborative )
|
||||
|
||||
case 'm3u':
|
||||
return {
|
||||
type: 'MOPIDY_CREATE_PLAYLIST',
|
||||
scheme: scheme,
|
||||
name: name
|
||||
}
|
||||
default:
|
||||
return mopidyActions.createPlaylist(name, scheme)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export function deletePlaylist(uri){
|
||||
switch (helpers.uriSource(uri)){
|
||||
|
||||
case 'spotify':
|
||||
return spotifyActions.following(uri, 'DELETE')
|
||||
|
||||
default:
|
||||
return mopidyActions.deletePlaylist(uri)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@ -160,6 +160,14 @@ export function getImages( context, uris ){
|
||||
}
|
||||
}
|
||||
|
||||
export function createPlaylist(name, scheme){
|
||||
return {
|
||||
type: 'MOPIDY_CREATE_PLAYLIST',
|
||||
name: name,
|
||||
scheme: scheme
|
||||
}
|
||||
}
|
||||
|
||||
export function deletePlaylist( uri ){
|
||||
return {
|
||||
type: 'MOPIDY_DELETE_PLAYLIST',
|
||||
|
||||
@ -830,18 +830,28 @@ const MopidyMiddleware = (function(){
|
||||
.then( response => {
|
||||
store.dispatch(uiActions.createNotification('Created playlist'))
|
||||
|
||||
// re-load our global playlists
|
||||
//store.dispatch({ type: 'MOPIDY_GET_PLAYLISTS' });
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_LOADED',
|
||||
key: action.uri,
|
||||
playlist: response
|
||||
})
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_PLAYLIST_CREATED',
|
||||
key: action.uri,
|
||||
playlist: response
|
||||
})
|
||||
});
|
||||
break
|
||||
|
||||
case 'MOPIDY_DELETE_PLAYLIST':
|
||||
instruct( socket, store, 'playlists.delete', { uri: action.key })
|
||||
instruct( socket, store, 'playlists.delete', { uri: action.uri })
|
||||
.then( response => {
|
||||
store.dispatch(uiActions.createNotification('Deleted playlist'))
|
||||
|
||||
// re-load our global playlists
|
||||
// store.dispatch({ type: 'MOPIDY_PLAYLISTS' });
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_PLAYLIST_DELETED',
|
||||
key: action.uri
|
||||
})
|
||||
});
|
||||
break
|
||||
|
||||
|
||||
@ -109,6 +109,22 @@ export default function reducer(mopidy = {}, action){
|
||||
}
|
||||
return Object.assign({}, mopidy, { library_playlists: helpers.removeDuplicates(uris) })
|
||||
|
||||
case 'MOPIDY_LIBRARY_PLAYLIST_CREATED':
|
||||
var library_playlists = []
|
||||
if (mopidy.library_playlists){
|
||||
library_playlists = Object.assign([], mopidy.library_playlists)
|
||||
library_playlists.push(action.key)
|
||||
}
|
||||
return Object.assign({}, mopidy, { library_playlists: library_playlists })
|
||||
|
||||
case 'MOPIDY_LIBRARY_PLAYLIST_DELETED':
|
||||
var library_playlists = []
|
||||
if (mopidy.library_playlists){
|
||||
library_playlists = Object.assign([], mopidy.library_playlists)
|
||||
library_playlists.splice(library_playlists.indexOf(action.uri), 1)
|
||||
}
|
||||
return Object.assign({}, mopidy, { library_playlists: library_playlists })
|
||||
|
||||
case 'MOPIDY_LIBRARY_ARTISTS_LOADED':
|
||||
if (mopidy.library_artists){
|
||||
var uris = [...mopidy.library_artists,...action.uris]
|
||||
|
||||
Reference in New Issue
Block a user