Unifying loader syntaxes
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -98,7 +98,7 @@
|
||||
|
||||
// Release details
|
||||
// These are automatically injected to built HTML
|
||||
var build = "1534063312";
|
||||
var build = "1534105233";
|
||||
var version = "3.23.2";
|
||||
|
||||
// Construct the script tag
|
||||
|
||||
@ -360,11 +360,13 @@ const CoreMiddleware = (function(){
|
||||
switch (helpers.uriSource(action.uri)){
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getTrack(action.uri));
|
||||
//store.dispatch(spotifyActions.following(action.uri));
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
break;
|
||||
|
||||
default:
|
||||
store.dispatch(mopidyActions.getTrack(action.uri));
|
||||
if (store.getState().mopidy.connected){
|
||||
store.dispatch(mopidyActions.getTrack(action.uri));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -379,7 +381,9 @@ const CoreMiddleware = (function(){
|
||||
break;
|
||||
|
||||
default:
|
||||
store.dispatch(mopidyActions.getAlbum(action.uri));
|
||||
if (store.getState().mopidy.connected){
|
||||
store.dispatch(mopidyActions.getAlbum(action.uri));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -394,7 +398,9 @@ const CoreMiddleware = (function(){
|
||||
break;
|
||||
|
||||
default:
|
||||
store.dispatch(mopidyActions.getArtist(action.uri));
|
||||
if (store.getState().mopidy.connected){
|
||||
store.dispatch(mopidyActions.getArtist(action.uri));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -409,7 +415,9 @@ const CoreMiddleware = (function(){
|
||||
break;
|
||||
|
||||
default:
|
||||
store.dispatch(mopidyActions.getPlaylist(action.uri));
|
||||
if (store.getState().mopidy.connected){
|
||||
store.dispatch(mopidyActions.getPlaylist(action.uri));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -1745,9 +1745,11 @@ const MopidyMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'MOPIDY_GET_ALBUM':
|
||||
request(socket, store, 'library.lookup', action.data )
|
||||
request(socket, store, 'library.lookup', action.data)
|
||||
.then(response => {
|
||||
if (response.length <= 0) return
|
||||
if (response.length <= 0){
|
||||
return;
|
||||
}
|
||||
|
||||
var album = Object.assign(
|
||||
{},
|
||||
@ -1798,11 +1800,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
store.dispatch({
|
||||
type: 'ALBUM_LOADED',
|
||||
key: album.uri,
|
||||
album: album
|
||||
});
|
||||
store.dispatch(coreActions.albumLoaded(album));
|
||||
})
|
||||
})
|
||||
break;
|
||||
@ -1826,10 +1824,7 @@ const MopidyMiddleware = (function(){
|
||||
uris.push(response[i].uri);
|
||||
}
|
||||
|
||||
store.dispatch({
|
||||
type: 'ARTISTS_LOADED',
|
||||
artists: response
|
||||
});
|
||||
store.dispatch(coreActions.artistsLoaded(response));
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
||||
@ -1921,10 +1916,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
}
|
||||
if (albums){
|
||||
store.dispatch({
|
||||
type: 'ALBUMS_LOADED',
|
||||
albums: albums
|
||||
});
|
||||
store.dispatch(coreActions.albumsLoaded(albums));
|
||||
}
|
||||
|
||||
var artist = Object.assign(
|
||||
@ -1936,11 +1928,7 @@ const MopidyMiddleware = (function(){
|
||||
tracks: response.slice(0,10)
|
||||
}
|
||||
);
|
||||
store.dispatch({
|
||||
type: 'ARTIST_LOADED',
|
||||
key: artist.uri,
|
||||
artist: artist
|
||||
});
|
||||
store.dispatch(coreActions.artistLoaded(artist));
|
||||
|
||||
// load artwork from LastFM
|
||||
var existing_artist = store.getState().core.artists[artist.uri];
|
||||
@ -1974,10 +1962,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
store.dispatch({
|
||||
type: 'ARTISTS_LOADED',
|
||||
artists: artists
|
||||
});
|
||||
store.dispatch(coreActions.artistsLoaded(artists));
|
||||
|
||||
// Re-run any consequential processes in 100ms. This allows a small window for other
|
||||
// server requests before our next batch. It's a little crude but it means the server isn't
|
||||
@ -2097,10 +2082,7 @@ const MopidyMiddleware = (function(){
|
||||
response => {
|
||||
if (response.length > 0){
|
||||
var track = Object.assign({}, response[0]);
|
||||
store.dispatch({
|
||||
type: 'TRACKS_LOADED',
|
||||
tracks: [track]
|
||||
});
|
||||
store.dispatch(coreActions.trackLoaded(track));
|
||||
}
|
||||
},
|
||||
error => {
|
||||
|
||||
@ -16,6 +16,7 @@ import ContextMenuTrigger from '../components/ContextMenuTrigger'
|
||||
import Icon from '../components/Icon'
|
||||
|
||||
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'
|
||||
@ -28,7 +29,7 @@ class Album extends React.Component{
|
||||
|
||||
componentDidMount(){
|
||||
this.setWindowTitle();
|
||||
this.loadAlbum();
|
||||
this.props.coreActions.loadAlbum(this.props.params.uri);
|
||||
}
|
||||
|
||||
handleContextMenu(e){
|
||||
@ -41,12 +42,12 @@ class Album extends React.Component{
|
||||
|
||||
// if our URI has changed, fetch new album
|
||||
if (nextProps.params.uri != this.props.params.uri){
|
||||
this.loadAlbum(nextProps);
|
||||
this.props.coreActions.loadAlbum(nextProps.params.uri);
|
||||
|
||||
// if mopidy has just connected AND we're a local album, go get
|
||||
}else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
|
||||
if (helpers.uriSource(this.props.params.uri ) != 'spotify'){
|
||||
this.loadAlbum(nextProps);
|
||||
} else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
|
||||
if (helpers.uriSource(nextProps.params.uri) != 'spotify'){
|
||||
this.props.coreActions.loadAlbum(nextProps.params.uri);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,30 +81,6 @@ class Album extends React.Component{
|
||||
this.props.uiActions.showContextMenu(data);
|
||||
}
|
||||
|
||||
loadAlbum(props = this.props){
|
||||
switch(helpers.uriSource(props.params.uri)){
|
||||
|
||||
case 'spotify':
|
||||
if (props.album && props.album.tracks && props.album.artists_uris){
|
||||
console.info('Loading album from index')
|
||||
} else {
|
||||
this.props.spotifyActions.getAlbum(props.params.uri);
|
||||
}
|
||||
this.props.spotifyActions.following(props.params.uri);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (props.mopidy_connected){
|
||||
if (props.album && props.album.tracks){
|
||||
console.info('Loading album from index')
|
||||
} else {
|
||||
this.props.mopidyActions.getAlbum(props.params.uri);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
loadMore(){
|
||||
this.props.spotifyActions.getMore(
|
||||
this.props.album.tracks_more,
|
||||
@ -217,6 +194,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)
|
||||
|
||||
@ -18,6 +18,7 @@ import DropdownField from '../components/Fields/DropdownField'
|
||||
import Icon from '../components/Icon'
|
||||
|
||||
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 pusherActions from '../services/pusher/actions'
|
||||
@ -384,6 +385,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
coreActions: bindActionCreators(coreActions, dispatch),
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
pusherActions: bindActionCreators(pusherActions, dispatch),
|
||||
|
||||
@ -19,6 +19,7 @@ import Icon from '../components/Icon'
|
||||
import Popularity from '../components/Popularity'
|
||||
|
||||
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'
|
||||
@ -307,7 +308,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
coreActions: bindActionCreators(coreActions, dispatch),
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
lastfmActions: bindActionCreators(lastfmActions, dispatch),
|
||||
|
||||
@ -12,6 +12,7 @@ import ContextMenuTrigger from '../components/ContextMenuTrigger'
|
||||
import Icon from '../components/Icon'
|
||||
|
||||
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'
|
||||
@ -143,6 +144,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
coreActions: bindActionCreators(coreActions, dispatch),
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user