More migration to coreActions

This commit is contained in:
James Barnsley
2017-08-02 21:11:22 +12:00
parent 0c134459ea
commit 48c37b3ddf
9 changed files with 23 additions and 19 deletions

View File

@ -5,12 +5,13 @@ import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import FontAwesome from 'react-fontawesome'
import TrackList from './TrackList'
import * as helpers from '../helpers'
import * as coreActions from '../services/core/actions'
import * as uiActions from '../services/ui/actions'
import * as pusherActions from '../services/pusher/actions'
import * as mopidyActions from '../services/mopidy/actions'
import * as spotifyActions from '../services/spotify/actions'
import TrackList from './TrackList'
class ContextMenu extends React.Component{
@ -186,12 +187,12 @@ class ContextMenu extends React.Component{
addTracksToPlaylist(e, playlist_uri){
this.props.uiActions.hideContextMenu()
this.props.uiActions.addTracksToPlaylist(playlist_uri, this.props.menu.uris)
this.props.coreActions.addTracksToPlaylist(playlist_uri, this.props.menu.uris)
}
removeFromPlaylist(e){
this.props.uiActions.hideContextMenu()
this.props.uiActions.removeTracksFromPlaylist(this.props.menu.tracklist_uri, this.props.menu.indexes)
this.props.coreActions.removeTracksFromPlaylist(this.props.menu.tracklist_uri, this.props.menu.indexes)
}
startRadio(e){
@ -587,6 +588,7 @@ const mapStateToProps = (state, ownProps) => {
const mapDispatchToProps = (dispatch) => {
return {
coreActions: bindActionCreators(coreActions, dispatch),
uiActions: bindActionCreators(uiActions, dispatch),
pusherActions: bindActionCreators(pusherActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch),

View File

@ -261,11 +261,11 @@ const MopidyMiddleware = (function(){
}
// playlist already in index
if (store.getState().ui.playlists.hasOwnProperty(action.uri)){
if (store.getState().core.playlists.hasOwnProperty(action.uri)){
// make sure we didn't get this playlist from Mopidy-Spotify
// if we did, we'd have a cached version on server so no need to fetch
if (!store.getState().ui.playlists[action.uri].is_mopidy){
if (!store.getState().core.playlists[action.uri].is_mopidy){
store.dispatch(uiActions.startProcess('MOPIDY_ENQUEUE_URIS', 'Fetching tracks'))
store.dispatch(spotifyActions.getAllPlaylistTracks(action.uri))
break
@ -410,7 +410,7 @@ const MopidyMiddleware = (function(){
case 'MOPIDY_PLAY_URIS':
// Stop the radio
if (store.getState().ui.radio && store.getState().ui.radio.enabled){
if (store.getState().core.radio && store.getState().core.radio.enabled){
store.dispatch(pusherActions.stopRadio())
}

View File

@ -69,7 +69,7 @@ const SpotifyMiddleware = (function(){
break
case 'SPOTIFY_REMOVE_PLAYLIST_TRACKS':
var playlist = state.ui.playlists[action.key]
var playlist = state.core.playlists[action.key]
if( !store.getState().spotify.authorized ){
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )

View File

@ -16,6 +16,7 @@ import Header from '../components/Header'
import ContextMenuTrigger from '../components/ContextMenuTrigger'
import * as helpers from '../helpers'
import * as coreActions from '../services/core/actions'
import * as uiActions from '../services/ui/actions'
import * as mopidyActions from '../services/mopidy/actions'
import * as spotifyActions from '../services/spotify/actions'
@ -96,11 +97,11 @@ class Playlist extends React.Component{
}
reorderTracks( indexes, index ){
this.props.uiActions.reorderPlaylistTracks( this.props.playlist.uri, indexes, index, this.props.playlist.snapshot_id )
this.props.coreActions.reorderPlaylistTracks( this.props.playlist.uri, indexes, index, this.props.playlist.snapshot_id )
}
removeTracks( tracks_indexes ){
this.props.uiActions.removeTracksFromPlaylist( this.props.playlist.uri, tracks_indexes )
this.props.coreActions.removeTracksFromPlaylist( this.props.playlist.uri, tracks_indexes )
}
inLibrary(){
@ -223,6 +224,7 @@ const mapStateToProps = (state, ownProps) => {
const mapDispatchToProps = (dispatch) => {
return {
coreActions: bindActionCreators(coreActions, dispatch),
uiActions: bindActionCreators(uiActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch)

View File

@ -60,7 +60,7 @@ class DiscoverCategories extends React.Component{
const mapStateToProps = (state, ownProps) => {
return {
categories: state.ui.categories,
categories: state.core.categories,
load_queue: state.ui.load_queue
}
}

View File

@ -84,7 +84,7 @@ const mapStateToProps = (state, ownProps) => {
return {
load_queue: state.ui.load_queue,
playlists: state.core.playlists,
category: (state.ui.categories && typeof(state.ui.categories['category:'+ownProps.params.id]) !== 'undefined' ? state.ui.categories['category:'+ownProps.params.id] : false )
category: (state.core.categories && state.core.categories['category:'+ownProps.params.id] !== undefined ? state.core.categories['category:'+ownProps.params.id] : false )
}
}

View File

@ -129,9 +129,9 @@ const mapStateToProps = (state, ownProps) => {
return {
load_queue: state.ui.load_queue,
albums: state.core.albums,
new_releases: state.ui.new_releases,
new_releases_more: state.ui.new_releases_more,
new_releases_total: state.ui.new_releases_total
new_releases: state.core.new_releases,
new_releases_more: state.core.new_releases_more,
new_releases_total: state.core.new_releases_total
}
}

View File

@ -267,7 +267,7 @@ const mapStateToProps = (state, ownProps) => {
albums: (state.core.albums ? state.core.albums : []),
artists: (state.core.artists ? state.core.artists : []),
tracks: (state.core.tracks ? state.core.tracks : []),
genres: (state.ui.genres ? state.ui.genres : []),
genres: (state.core.genres ? state.core.genres : []),
authorized: state.spotify.authorized,
load_queue: state.ui.load_queue,
quick_search_results: (state.spotify.quick_search_results ? state.spotify.quick_search_results : {artists: [], tracks: []}),

View File

@ -231,10 +231,10 @@ const mapStateToProps = (state, ownProps) => {
slim_mode: state.ui.slim_mode,
load_queue: state.ui.load_queue,
me_id: (state.spotify.me ? state.spotify.me.id : (state.ui.config && state.ui.config.spotify_username ? state.ui.config.spotify_username : false)),
view: state.core.library_playlists_view,
filter: (state.core.library_playlists_filter ? state.core.library_playlists_filter : 'all'),
sort: (state.core.library_playlists_sort ? state.core.library_playlists_sort : 'name'),
sort_reverse: (state.core.library_playlists_sort_reverse ? true : false),
view: state.ui.library_playlists_view,
filter: (state.ui.library_playlists_filter ? state.ui.library_playlists_filter : 'all'),
sort: (state.ui.library_playlists_sort ? state.ui.library_playlists_sort : 'name'),
sort_reverse: (state.ui.library_playlists_sort_reverse ? true : false),
library_playlists: state.core.library_playlists,
playlists: state.core.playlists
}