Polishing spotify actions, removing middleware; Mopidy current track selection
This commit is contained in:
@ -32,6 +32,7 @@ class App extends React.Component{
|
||||
<li><Link to="/queue">Now playing</Link></li>
|
||||
<li><Link to="/library/artists">Library: My artists</Link></li>
|
||||
<li><Link to="/library/albums">Library: My albums</Link></li>
|
||||
<li><Link to="/library/tracks">Library: My tracks</Link></li>
|
||||
<li><Link to="/library/playlists">Library: My playlists</Link></li>
|
||||
<li><Link to="/settings">Settings</Link></li>
|
||||
</ul>
|
||||
|
||||
59
src/js/views/Playlist.js
Executable file
59
src/js/views/Playlist.js
Executable file
@ -0,0 +1,59 @@
|
||||
|
||||
import React, { PropTypes } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
|
||||
import TrackList from '../components/TrackList'
|
||||
import * as spotifyActions from '../services/spotify/actions'
|
||||
import * as mopidyActions from '../services/mopidy/actions'
|
||||
|
||||
class Playlist extends React.Component{
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
// on render
|
||||
componentDidMount(){
|
||||
this.props.spotifyActions.getPlaylist( this.props.params.uri );
|
||||
}
|
||||
|
||||
// when props changed
|
||||
componentWillReceiveProps( nextProps ){
|
||||
if( nextProps.params.uri != this.props.params.uri ){
|
||||
this.props.spotifyActions.getPlaylist( nextProps.params.uri );
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
if( this.props.spotify.playlist ){
|
||||
return (
|
||||
<div>
|
||||
<h3>{ this.props.spotify.playlist.name }</h3>
|
||||
<TrackList tracks={this.props.spotify.playlist.tracks.items} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export our component
|
||||
*
|
||||
* We also integrate our global store, using connect()
|
||||
**/
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return state;
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Playlist)
|
||||
@ -4,10 +4,10 @@ import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { Link } from 'react-router'
|
||||
|
||||
import AlbumGrid from '../components/AlbumGrid'
|
||||
import AlbumGrid from '../../components/AlbumGrid'
|
||||
|
||||
import * as mopidyActions from '../services/mopidy/actions'
|
||||
import * as spotifyActions from '../services/spotify/actions'
|
||||
import * as mopidyActions from '../../services/mopidy/actions'
|
||||
import * as spotifyActions from '../../services/spotify/actions'
|
||||
|
||||
class LibraryAlbums extends React.Component{
|
||||
|
||||
@ -4,8 +4,8 @@ import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { Link } from 'react-router'
|
||||
|
||||
import * as mopidyActions from '../services/mopidy/actions'
|
||||
import * as spotifyActions from '../services/spotify/actions'
|
||||
import * as mopidyActions from '../../services/mopidy/actions'
|
||||
import * as spotifyActions from '../../services/spotify/actions'
|
||||
|
||||
class LibraryArtists extends React.Component{
|
||||
|
||||
59
src/js/views/library/LibraryPlaylists.js
Executable file
59
src/js/views/library/LibraryPlaylists.js
Executable file
@ -0,0 +1,59 @@
|
||||
|
||||
import React, { PropTypes } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { Link } from 'react-router'
|
||||
|
||||
import * as mopidyActions from '../../services/mopidy/actions'
|
||||
import * as spotifyActions from '../../services/spotify/actions'
|
||||
|
||||
class LibraryPlaylists extends React.Component{
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
// on render
|
||||
componentDidMount(){
|
||||
this.props.spotifyActions.getLibraryPlaylists();
|
||||
}
|
||||
|
||||
render(){
|
||||
if( this.props.spotify.libraryPlaylists ){
|
||||
return (
|
||||
<div>
|
||||
<h3>My playlists</h3>
|
||||
<ul>
|
||||
{
|
||||
this.props.spotify.libraryPlaylists.items.map( (playlist, index) => {
|
||||
var link = '/playlist/' + playlist.uri;
|
||||
return <li key={index}><Link to={link}>{ playlist.name }</Link></li>
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export our component
|
||||
*
|
||||
* We also integrate our global store, using connect()
|
||||
**/
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return state;
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(LibraryPlaylists)
|
||||
@ -4,10 +4,10 @@ import { connect } from 'react-redux'
|
||||
import { bindActionCreators } from 'redux'
|
||||
import { Link } from 'react-router'
|
||||
|
||||
import TrackList from '../components/TrackList'
|
||||
import TrackList from '../../components/TrackList'
|
||||
|
||||
import * as mopidyActions from '../services/mopidy/actions'
|
||||
import * as spotifyActions from '../services/spotify/actions'
|
||||
import * as mopidyActions from '../../services/mopidy/actions'
|
||||
import * as spotifyActions from '../../services/spotify/actions'
|
||||
|
||||
class LibraryTracks extends React.Component{
|
||||
|
||||
@ -21,11 +21,11 @@ class LibraryTracks extends React.Component{
|
||||
}
|
||||
|
||||
render(){
|
||||
if( this.props.spotify.libraryAlbums ){
|
||||
if( this.props.spotify.libraryTracks ){
|
||||
return (
|
||||
<div>
|
||||
<h3>My tracks</h3>
|
||||
<TrackList tracks={this.props.spotify.libraryTracks.tracks} />
|
||||
<TrackList tracks={this.props.spotify.libraryTracks.items} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user