Weening out old full props; Dropzone add to playlist

This commit is contained in:
James Barnsley
2016-11-19 13:06:08 +13:00
parent d8e430858c
commit 96ad8a75c1
18 changed files with 70 additions and 94 deletions

View File

@ -3,7 +3,6 @@ import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import FontAwesome from 'react-fontawesome'
let helpers = require('../helpers.js')
import TrackList from '../components/TrackList'
import Thumbnail from '../components/Thumbnail'
@ -14,6 +13,7 @@ import FollowButton from '../components/FollowButton'
import Dater from '../components/Dater'
import LazyLoadListener from '../components/LazyLoadListener'
import * as helpers from '../helpers'
import * as mopidyActions from '../services/mopidy/actions'
import * as spotifyActions from '../services/spotify/actions'
@ -75,7 +75,7 @@ class Album extends React.Component{
<div className="actions">
<button className="large primary" onClick={ e => this.play() }>Play</button>
<FollowButton uri={this.props.params.uri} addText="Add to library" removeText="Remove from library" />
{ helpers.uriSource(this.props.params.uri) == 'spotify' ? <FollowButton uri={this.props.params.uri} addText="Add to library" removeText="Remove from library" /> : null }
</div>
<ul className="details">

View File

@ -72,7 +72,7 @@ class Artist extends React.Component{
<div className="actions">
<button className="large primary" onClick={ e => this.play() }>Start radio</button>
<FollowButton uri={this.props.params.uri} removeText="Unfollow" addText="Follow" />
{ helpers.uriSource(this.props.params.uri) == 'spotify' ? <FollowButton uri={this.props.params.uri} removeText="Unfollow" addText="Follow" /> : null }
</div>
<ul className="details">

View File

@ -8,7 +8,6 @@ import TrackList from '../components/TrackList'
import Track from '../components/Track'
import FullPlayer from '../components/FullPlayer'
import ArtistSentence from '../components/ArtistSentence'
import AlbumLink from '../components/AlbumLink'
import Header from '../components/Header'
import * as uiActions from '../services/ui/actions'

View File

@ -5,6 +5,7 @@ import { bindActionCreators } from 'redux'
import Header from '../../components/Header'
import * as helpers from '../../helpers'
import * as spotifyActions from '../../services/spotify/actions'
class Discover extends React.Component{
@ -13,28 +14,13 @@ class Discover extends React.Component{
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 className="view discover-view">
<Header icon="compass" title="Discover" />
<h1>To come</h1>
</div>
);
}
return null;
return (
<div className="view discover-view">
<Header icon="compass" title="Discover" />
<h1>To come</h1>
</div>
)
}
}
@ -46,7 +32,9 @@ class Discover extends React.Component{
**/
const mapStateToProps = (state, ownProps) => {
return state;
return {
}
}
const mapDispatchToProps = (dispatch) => {

View File

@ -22,8 +22,8 @@ class LibraryAlbums extends React.Component{
}
loadMore(){
if( !this.props.spotify.library_albums_more ) return
this.props.spotifyActions.getURL( this.props.spotify.library_albums_more, 'SPOTIFY_LIBRARY_ALBUMS_LOADED_MORE' );
if( !this.props.albums_more ) return
this.props.spotifyActions.getURL( this.props.albums_more, 'SPOTIFY_LIBRARY_ALBUMS_LOADED_MORE' );
}
render(){
@ -34,7 +34,7 @@ class LibraryAlbums extends React.Component{
title="My albums"
/>
<section className="grid-wrapper">
{ this.props.spotify.library_albums ? <AlbumGrid albums={this.props.spotify.library_albums} /> : null }
{ this.props.albums ? <AlbumGrid albums={this.props.albums} /> : null }
</section>
<LazyLoadListener loadMore={ () => this.loadMore() }/>
</div>
@ -50,7 +50,10 @@ class LibraryAlbums extends React.Component{
**/
const mapStateToProps = (state, ownProps) => {
return state;
return {
albums: state.spotify.library_albums,
albums_more: state.spotify.library_albums_more,
}
}
const mapDispatchToProps = (dispatch) => {

View File

@ -23,8 +23,8 @@ class LibraryArtists extends React.Component{
}
loadMore(){
if( !this.props.spotify.library_artists_more ) return
this.props.spotifyActions.getURL( this.props.spotify.library_artists_more, 'SPOTIFY_LIBRARY_ARTISTS_LOADED_MORE' );
if( !this.props.artists_more ) return
this.props.spotifyActions.getURL( this.props.artists_more, 'SPOTIFY_LIBRARY_ARTISTS_LOADED_MORE' );
}
render(){
@ -32,7 +32,7 @@ class LibraryArtists extends React.Component{
<div className="view library-artists-view">
<Header icon="mic" title="My artists" />
<section className="grid-wrapper">
{ this.props.spotify.library_artists ? <ArtistGrid artists={this.props.spotify.library_artists} /> : null }
{ this.props.artists ? <ArtistGrid artists={this.props.artists} /> : null }
</section>
<LazyLoadListener loadMore={ () => this.loadMore() }/>
</div>
@ -48,7 +48,10 @@ class LibraryArtists extends React.Component{
**/
const mapStateToProps = (state, ownProps) => {
return state;
return {
artists: state.spotify.library_artists,
artists_more: state.spotify.library_artists_more
}
}
const mapDispatchToProps = (dispatch) => {

View File

@ -21,25 +21,25 @@ class LibraryLocalAlbums extends React.Component{
}
componentWillReceiveProps( nextProps ){
if( !this.props.mopidy.connected && nextProps.mopidy.connected ){
if( !this.props.mopidy_connected && nextProps.mopidy_connected ){
this.loadAlbums(nextProps);
}
}
loadAlbums(props = this.props){
if( props.mopidy.connected ){
if( props.mopidy_connected ){
this.props.mopidyActions.getAlbums();
}
}
render(){
if( !this.props.mopidy.albums ) return null
if( !this.props.albums ) return null
return (
<div className="view library-local-view">
<Header icon="music" title="Local albums" />
<div>
<List columns={[{ name: 'name', width: '100'}]} rows={this.props.mopidy.albums} link_prefix="/album/" />
<List columns={[{ name: 'name', width: '100'}]} rows={this.props.albums} link_prefix="/album/" />
</div>
</div>
);
@ -54,7 +54,10 @@ class LibraryLocalAlbums extends React.Component{
**/
const mapStateToProps = (state, ownProps) => {
return state;
return {
mopidy_connected: state.mopidy.connected,
albums: state.mopidy.albums
}
}
const mapDispatchToProps = (dispatch) => {

View File

@ -21,25 +21,25 @@ class LibraryLocalArtists extends React.Component{
}
componentWillReceiveProps( nextProps ){
if( !this.props.mopidy.connected && nextProps.mopidy.connected ){
if( !this.props.mopidy_connected && nextProps.mopidy_connected ){
this.loadArtists(nextProps);
}
}
loadArtists(props = this.props){
if( props.mopidy.connected ){
if( props.mopidy_connected ){
this.props.mopidyActions.getArtists();
}
}
render(){
if( !this.props.mopidy.artists ) return null
if( !this.props.artists ) return null
return (
<div className="view library-local-view">
<Header icon="music" title="Local artists" />
<section className="list-wrapper">
<List columns={[{ name: 'name', width: '100'}]} rows={this.props.mopidy.artists} link_prefix="/artist/" />
<List columns={[{ name: 'name', width: '100'}]} rows={this.props.artists} link_prefix="/artist/" />
</section>
</div>
);
@ -54,7 +54,10 @@ class LibraryLocalArtists extends React.Component{
**/
const mapStateToProps = (state, ownProps) => {
return state;
return {
mopidy_connected: state.mopidy.connected,
artists: state.mopidy.artists
}
}
const mapDispatchToProps = (dispatch) => {

View File

@ -24,7 +24,7 @@ class LibraryLocalDirectory extends React.Component{
componentWillReceiveProps( nextProps ){
// mopidy goes online
if( !this.props.mopidy.connected && nextProps.mopidy.connected ){
if( !this.props.mopidy_connected && nextProps.mopidy_connected ){
this.loadDirectory( nextProps );
}
@ -35,19 +35,19 @@ class LibraryLocalDirectory extends React.Component{
}
loadDirectory( props = this.props ){
if( props.mopidy.connected ){
if( props.mopidy_connected ){
this.props.mopidyActions.getDirectory( props.params.uri );
}
}
render(){
if( !this.props.mopidy.directory ) return null
if( !this.props.directory ) return null
return (
<div className="view library-local-view">
<Header icon="music" title="Local files" />
<section className="list-wrapper">
<List columns={[{ name: 'name', width: '100'}]} rows={this.props.mopidy.directory} link_prefix="/library/local/directory/" />
<List columns={[{ name: 'name', width: '100'}]} rows={this.props.directory} link_prefix="/library/local/directory/" />
</section>
</div>
);
@ -62,7 +62,10 @@ class LibraryLocalDirectory extends React.Component{
**/
const mapStateToProps = (state, ownProps) => {
return state;
return {
mopidy_connected: state.mopidy.connected,
directory: state.mopidy.directory
}
}
const mapDispatchToProps = (dispatch) => {

View File

@ -23,8 +23,8 @@ class LibraryTracks extends React.Component{
}
loadMore(){
if( !this.props.spotify.library_tracks_more ) return
this.props.spotifyActions.getURL( this.props.spotify.library_tracks_more, 'SPOTIFY_LIBRARY_TRACKS_LOADED_MORE' );
if( !this.props.tracks_more ) return
this.props.spotifyActions.getURL( this.props.tracks_more, 'SPOTIFY_LIBRARY_TRACKS_LOADED_MORE' );
}
render(){
@ -32,7 +32,7 @@ class LibraryTracks extends React.Component{
<div className="view library-tracks-view">
<Header icon="music" title="My tracks" />
<section className="list-wrapper">
{ this.props.spotify.library_tracks ? <TrackList tracks={this.props.spotify.library_tracks} /> : null }
{ this.props.tracks ? <TrackList tracks={this.props.tracks} /> : null }
</section>
<LazyLoadListener loadMore={ () => this.loadMore() }/>
</div>
@ -48,7 +48,10 @@ class LibraryTracks extends React.Component{
**/
const mapStateToProps = (state, ownProps) => {
return state;
return {
tracks: state.spotify.library_tracks,
tracks_more: state.spotify.library_tracks_more
}
}
const mapDispatchToProps = (dispatch) => {