Categories in full index
This commit is contained in:
@ -408,7 +408,7 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
case 'MOPIDY_ADD_PLAYLIST_TRACKS':
|
||||
|
||||
instruct( socket, store, 'playlists.lookup', { uri: action.uri })
|
||||
instruct( socket, store, 'playlists.lookup', { uri: action.key })
|
||||
.then( response => {
|
||||
var tracks = [];
|
||||
for( var i = 0; i < action.tracks_uris.length; i++ ){
|
||||
@ -429,7 +429,7 @@ const MopidyMiddleware = (function(){
|
||||
.then( response => {
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_TRACKS_ADDED',
|
||||
key: action.uri,
|
||||
key: action.key,
|
||||
tracks_uris: action.tracks_uris
|
||||
});
|
||||
})
|
||||
@ -445,7 +445,7 @@ const MopidyMiddleware = (function(){
|
||||
var indexes = Object.assign([], action.tracks_indexes)
|
||||
indexes.sort(descending);
|
||||
|
||||
instruct( socket, store, 'playlists.lookup', { uri: action.uri })
|
||||
instruct( socket, store, 'playlists.lookup', { uri: action.key })
|
||||
.then( response => {
|
||||
var playlist = Object.assign({}, response)
|
||||
for( var i = 0; i < indexes.length; i++ ){
|
||||
@ -455,7 +455,7 @@ const MopidyMiddleware = (function(){
|
||||
.then( response => {
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_TRACKS_REMOVED',
|
||||
key: action.uri,
|
||||
key: action.key,
|
||||
tracks_indexes: action.tracks_indexes
|
||||
});
|
||||
})
|
||||
@ -463,14 +463,14 @@ const MopidyMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'MOPIDY_SAVE_PLAYLIST':
|
||||
instruct( socket, store, 'playlists.lookup', { uri: action.uri })
|
||||
instruct( socket, store, 'playlists.lookup', { uri: action.key })
|
||||
.then( response => {
|
||||
var playlist = Object.assign({}, response, { name: action.name })
|
||||
instruct( socket, store, 'playlists.save', { playlist: playlist } )
|
||||
.then( response => {
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_UPDATED',
|
||||
key: action.uri,
|
||||
key: action.key,
|
||||
playlist: playlist
|
||||
})
|
||||
})
|
||||
@ -478,7 +478,7 @@ const MopidyMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'MOPIDY_REORDER_PLAYLIST_TRACKS':
|
||||
instruct( socket, store, 'playlists.lookup', { uri: action.uri })
|
||||
instruct( socket, store, 'playlists.lookup', { uri: action.key })
|
||||
.then( response => {
|
||||
|
||||
var playlist = Object.assign({}, response)
|
||||
@ -530,7 +530,7 @@ const MopidyMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'MOPIDY_DELETE_PLAYLIST':
|
||||
instruct( socket, store, 'playlists.delete', { uri: action.uri })
|
||||
instruct( socket, store, 'playlists.delete', { uri: action.key })
|
||||
.then( response => {
|
||||
|
||||
// re-load our global playlists
|
||||
|
||||
@ -870,7 +870,25 @@ export function createPlaylist( name, is_public ){
|
||||
|
||||
sendRequest( dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/', 'POST', { name: name, public: is_public } )
|
||||
.then( response => {
|
||||
dispatch( getAllLibraryPlaylists() );
|
||||
|
||||
dispatch({
|
||||
type: 'PLAYLIST_LOADED',
|
||||
key: response.uri,
|
||||
playlist: Object.assign(
|
||||
{},
|
||||
response,
|
||||
{
|
||||
can_edit: true,
|
||||
tracks: [],
|
||||
tracks_more: null,
|
||||
tracks_total: 0
|
||||
})
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: 'LIBRARY_PLAYLISTS_LOADED',
|
||||
uris: [response.uri]
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -950,9 +968,9 @@ export function toggleFollowingPlaylist( uri, method ){
|
||||
sendRequest( dispatch, getState, 'users/'+ helpers.getFromUri('userid',uri) + '/playlists/'+ helpers.getFromUri('playlistid',uri) + '/followers', method )
|
||||
.then( response => {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_PLAYLIST_FOLLOWING',
|
||||
type: 'SPOTIFY_PLAYLIST_FOLLOWING_LOADED',
|
||||
key: uri,
|
||||
data: new_state
|
||||
is_following: new_state
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ const SpotifyMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'SPOTIFY_REMOVE_PLAYLIST_TRACKS':
|
||||
var playlist = state.ui.playlists[action.uri]
|
||||
var playlist = state.ui.playlists[action.key]
|
||||
|
||||
if( !store.getState().spotify.authorized ){
|
||||
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
|
||||
@ -46,7 +46,7 @@ const SpotifyMiddleware = (function(){
|
||||
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
|
||||
return
|
||||
}
|
||||
store.dispatch( spotifyActions.addTracksToPlaylist( action.uri, action.tracks_uris ))
|
||||
store.dispatch( spotifyActions.addTracksToPlaylist( action.key, action.tracks_uris ))
|
||||
break
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ const SpotifyMiddleware = (function(){
|
||||
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
|
||||
return
|
||||
}
|
||||
store.dispatch( spotifyActions.reorderPlaylistTracks( action.uri, action.range_start, action.range_length, action.insert_before, action.snapshot_id ))
|
||||
store.dispatch( spotifyActions.reorderPlaylistTracks( action.key, action.range_start, action.range_length, action.insert_before, action.snapshot_id ))
|
||||
break
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ const SpotifyMiddleware = (function(){
|
||||
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )
|
||||
return
|
||||
}
|
||||
store.dispatch( spotifyActions.savePlaylist( action.uri, action.name, action.is_public ))
|
||||
store.dispatch( spotifyActions.savePlaylist( action.key, action.name, action.is_public ))
|
||||
break
|
||||
|
||||
// when our mopidy server current track changes
|
||||
|
||||
@ -71,14 +71,14 @@ export function set( data ){
|
||||
}
|
||||
}
|
||||
|
||||
export function reorderPlaylistTracks( key, indexes, insert_before, snapshot_id = false ){
|
||||
export function reorderPlaylistTracks( uri, indexes, insert_before, snapshot_id = false ){
|
||||
var range = helpers.createRange( indexes );
|
||||
switch( helpers.uriSource( key ) ){
|
||||
switch( helpers.uriSource( uri ) ){
|
||||
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_REORDER_PLAYLIST_TRACKS',
|
||||
key: key,
|
||||
key: uri,
|
||||
range_start: range.start,
|
||||
range_length: range.length,
|
||||
insert_before: insert_before,
|
||||
@ -88,7 +88,7 @@ export function reorderPlaylistTracks( key, indexes, insert_before, snapshot_id
|
||||
case 'm3u':
|
||||
return {
|
||||
type: 'MOPIDY_REORDER_PLAYLIST_TRACKS',
|
||||
key: key,
|
||||
key: uri,
|
||||
range_start: range.start,
|
||||
range_length: range.length,
|
||||
insert_before: insert_before
|
||||
@ -96,13 +96,13 @@ export function reorderPlaylistTracks( key, indexes, insert_before, snapshot_id
|
||||
}
|
||||
}
|
||||
|
||||
export function savePlaylist( key, name, is_public = false ){
|
||||
switch( helpers.uriSource( key ) ){
|
||||
export function savePlaylist( uri, name, is_public = false ){
|
||||
switch( helpers.uriSource( uri ) ){
|
||||
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_SAVE_PLAYLIST',
|
||||
key: key,
|
||||
key: uri,
|
||||
name: name,
|
||||
is_public: is_public
|
||||
}
|
||||
@ -110,7 +110,7 @@ export function savePlaylist( key, name, is_public = false ){
|
||||
case 'm3u':
|
||||
return {
|
||||
type: 'MOPIDY_SAVE_PLAYLIST',
|
||||
key: key,
|
||||
key: uri,
|
||||
name: name
|
||||
}
|
||||
}
|
||||
@ -137,39 +137,39 @@ export function createPlaylist( scheme, name, is_public = false ){
|
||||
return false
|
||||
}
|
||||
|
||||
export function removeTracksFromPlaylist( key, tracks_indexes ){
|
||||
switch( helpers.uriSource( key ) ){
|
||||
export function removeTracksFromPlaylist( uri, tracks_indexes ){
|
||||
switch( helpers.uriSource( uri ) ){
|
||||
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_REMOVE_PLAYLIST_TRACKS',
|
||||
key: key,
|
||||
key: uri,
|
||||
tracks_indexes: tracks_indexes
|
||||
}
|
||||
|
||||
case 'm3u':
|
||||
return {
|
||||
type: 'MOPIDY_REMOVE_PLAYLIST_TRACKS',
|
||||
key: key,
|
||||
key: uri,
|
||||
tracks_indexes: tracks_indexes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function addTracksToPlaylist( key, tracks_uris ){
|
||||
switch( helpers.uriSource( key ) ){
|
||||
export function addTracksToPlaylist( uri, tracks_uris ){
|
||||
switch( helpers.uriSource( uri ) ){
|
||||
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_ADD_PLAYLIST_TRACKS',
|
||||
key: key,
|
||||
key: uri,
|
||||
tracks_uris: tracks_uris
|
||||
}
|
||||
|
||||
case 'm3u':
|
||||
return {
|
||||
type: 'MOPIDY_ADD_PLAYLIST_TRACKS',
|
||||
key: key,
|
||||
key: uri,
|
||||
tracks_uris: tracks_uris
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ const UIMiddleware = (function(){
|
||||
|
||||
case 'MOPIDY_SAVE_PLAYLIST':
|
||||
case 'SPOTIFY_SAVE_PLAYLIST':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Save', label: action.uri })
|
||||
ReactGA.event({ category: 'Playlist', action: 'Save', label: action.key })
|
||||
next(action)
|
||||
break
|
||||
|
||||
@ -94,7 +94,7 @@ const UIMiddleware = (function(){
|
||||
|
||||
case 'MOPIDY_REORDER_PLAYLIST_TRACKS':
|
||||
case 'SPOTIFY_REORDER_PLAYLIST_TRACKS':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Reorder tracks', label: action.uri })
|
||||
ReactGA.event({ category: 'Playlist', action: 'Reorder tracks', label: action.key })
|
||||
next(action)
|
||||
break
|
||||
|
||||
|
||||
@ -16,15 +16,19 @@ class DiscoverCategory extends React.Component{
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
this.props.spotifyActions.getCategory( this.props.params.id );
|
||||
this.loadCategory()
|
||||
}
|
||||
|
||||
componentWillReceiveProps( nextProps ){
|
||||
if( nextProps.params.id != this.props.params.id ){
|
||||
this.props.spotifyActions.getCategory( nextProps.params.id );
|
||||
this.loadCategory()
|
||||
}
|
||||
}
|
||||
|
||||
loadCategory(){
|
||||
if (!this.props.category || !this.props.category.playlists_uris) this.props.spotifyActions.getCategory( this.props.params.id );
|
||||
}
|
||||
|
||||
loadMore(){
|
||||
if (this.props.category.playlists_more){
|
||||
this.props.spotifyActions.getURL( this.props.category.playlists_more, 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED', 'category:'+this.props.params.id );
|
||||
|
||||
Reference in New Issue
Block a user