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
|
||||
|
||||
@ -26,7 +26,7 @@ const CoreMiddleware = (function(){
|
||||
if (action.description){
|
||||
var description = action.description;
|
||||
} else if (action.data.xhr && action.data.xhr.responseText){
|
||||
var xhr_response = JSON.parse(action.data.xhr.responseText);
|
||||
var xhr_response = JSON.parse(action.data.xhr.responseText);
|
||||
if (xhr_response.error && xhr_response.error.message){
|
||||
var description = xhr_response.error.message;
|
||||
}
|
||||
@ -63,7 +63,7 @@ const CoreMiddleware = (function(){
|
||||
|
||||
var data = Object.assign(
|
||||
{},
|
||||
action.data,
|
||||
action.data,
|
||||
{
|
||||
message: message,
|
||||
description: description,
|
||||
@ -75,7 +75,7 @@ const CoreMiddleware = (function(){
|
||||
/*
|
||||
if (store.getState().ui.allow_reporting){
|
||||
Raven.captureException(
|
||||
new Error(message),
|
||||
new Error(message),
|
||||
{
|
||||
extra: data
|
||||
}
|
||||
@ -185,7 +185,7 @@ const CoreMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'PLAYLIST_TRACKS_ADDED':
|
||||
store.dispatch(uiActions.createNotification({type: 'info', content: 'Added '+action.tracks_uris.length+' tracks to playlist'}))
|
||||
store.dispatch(uiActions.createNotification({type: 'info', content: 'Added '+action.tracks_uris.length+' tracks to playlist'}))
|
||||
switch(helpers.uriSource(action.key)){
|
||||
|
||||
case 'spotify':
|
||||
@ -267,7 +267,7 @@ const CoreMiddleware = (function(){
|
||||
type: 'TRACKS_LOADED',
|
||||
tracks: tracks
|
||||
});
|
||||
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
@ -295,7 +295,7 @@ const CoreMiddleware = (function(){
|
||||
snapshot_id = action.snapshot_id;
|
||||
}
|
||||
|
||||
// Update our playlist
|
||||
// Update our playlist
|
||||
playlist.tracks_uris = tracks_uris;
|
||||
playlist.snapshot_id = snapshot_id;
|
||||
|
||||
@ -321,7 +321,7 @@ const CoreMiddleware = (function(){
|
||||
snapshot_id = action.snapshot_id;
|
||||
}
|
||||
|
||||
// Update our playlist
|
||||
// Update our playlist
|
||||
playlist.tracks_uris = tracks_uris;
|
||||
playlist.snapshot_id = snapshot_id;
|
||||
|
||||
@ -351,7 +351,7 @@ const CoreMiddleware = (function(){
|
||||
type: 'TRACKS_LOADED',
|
||||
tracks: action.tracks
|
||||
});
|
||||
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
@ -360,14 +360,16 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
@ -379,10 +381,12 @@ const CoreMiddleware = (function(){
|
||||
break;
|
||||
|
||||
default:
|
||||
store.dispatch(mopidyActions.getAlbum(action.uri));
|
||||
if (store.getState().mopidy.connected){
|
||||
store.dispatch(mopidyActions.getAlbum(action.uri));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
@ -394,10 +398,12 @@ const CoreMiddleware = (function(){
|
||||
break;
|
||||
|
||||
default:
|
||||
store.dispatch(mopidyActions.getArtist(action.uri));
|
||||
if (store.getState().mopidy.connected){
|
||||
store.dispatch(mopidyActions.getArtist(action.uri));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
@ -409,10 +415,12 @@ const CoreMiddleware = (function(){
|
||||
break;
|
||||
|
||||
default:
|
||||
store.dispatch(mopidyActions.getPlaylist(action.uri));
|
||||
if (store.getState().mopidy.connected){
|
||||
store.dispatch(mopidyActions.getPlaylist(action.uri));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
@ -653,4 +661,4 @@ const CoreMiddleware = (function(){
|
||||
|
||||
})();
|
||||
|
||||
export default CoreMiddleware
|
||||
export default CoreMiddleware
|
||||
|
||||
@ -12,7 +12,7 @@ var spotifyActions = require('../spotify/actions.js')
|
||||
var pusherActions = require('../pusher/actions.js')
|
||||
var lastfmActions = require('../lastfm/actions.js')
|
||||
|
||||
const MopidyMiddleware = (function(){
|
||||
const MopidyMiddleware = (function(){
|
||||
|
||||
// container for the actual Mopidy socket
|
||||
var socket = null;
|
||||
@ -88,7 +88,7 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
case 'event:seeked':
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_TIME_POSITION',
|
||||
type: 'MOPIDY_TIME_POSITION',
|
||||
time_position: data.time_position
|
||||
});
|
||||
break;
|
||||
@ -145,10 +145,10 @@ const MopidyMiddleware = (function(){
|
||||
return new Promise((resolve, reject) => {
|
||||
if (method in ws[model]){
|
||||
var mopidyObject = ws[model][method];
|
||||
var property = method;
|
||||
} else {
|
||||
var property = method;
|
||||
} else {
|
||||
var mopidyObject = ws[model];
|
||||
var property = model;
|
||||
var property = model;
|
||||
}
|
||||
|
||||
// Detect invalid model.method calls, which result in an empty mopidyObject
|
||||
@ -160,7 +160,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
|
||||
store.dispatch(coreActions.handleException(
|
||||
'Mopidy: '+error.message,
|
||||
'Mopidy: '+error.message,
|
||||
error
|
||||
));
|
||||
|
||||
@ -444,7 +444,7 @@ const MopidyMiddleware = (function(){
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_VOLUME',
|
||||
type: 'MOPIDY_VOLUME',
|
||||
volume: response
|
||||
});
|
||||
}
|
||||
@ -456,7 +456,7 @@ const MopidyMiddleware = (function(){
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_VOLUME',
|
||||
type: 'MOPIDY_VOLUME',
|
||||
volume: action.volume
|
||||
});
|
||||
}
|
||||
@ -468,7 +468,7 @@ const MopidyMiddleware = (function(){
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_TIME_POSITION',
|
||||
type: 'MOPIDY_TIME_POSITION',
|
||||
time_position: action.time_position
|
||||
});
|
||||
}
|
||||
@ -540,7 +540,7 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
// playlist already in index
|
||||
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().core.playlists[action.uri].is_mopidy){
|
||||
@ -619,7 +619,7 @@ const MopidyMiddleware = (function(){
|
||||
// start our processor
|
||||
store.dispatch(uiActions.startProcess(
|
||||
'MOPIDY_ENQUEUE_URIS_PROCESSOR',
|
||||
'Adding '+action.uris.length+' URI(s)',
|
||||
'Adding '+action.uris.length+' URI(s)',
|
||||
{
|
||||
batches: batches,
|
||||
remaining: action.uris.length,
|
||||
@ -628,7 +628,7 @@ const MopidyMiddleware = (function(){
|
||||
))
|
||||
break
|
||||
|
||||
case 'MOPIDY_ENQUEUE_URIS_PROCESSOR':
|
||||
case 'MOPIDY_ENQUEUE_URIS_PROCESSOR':
|
||||
|
||||
var last_run = store.getState().ui.processes.MOPIDY_ENQUEUE_URIS_PROCESSOR
|
||||
|
||||
@ -648,7 +648,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
batches.shift()
|
||||
store.dispatch(uiActions.updateProcess(
|
||||
'MOPIDY_ENQUEUE_URIS_PROCESSOR',
|
||||
'MOPIDY_ENQUEUE_URIS_PROCESSOR',
|
||||
'Adding '+total_uris+' URI(s)',
|
||||
{
|
||||
remaining: total_uris
|
||||
@ -710,7 +710,7 @@ const MopidyMiddleware = (function(){
|
||||
setTimeout(
|
||||
function(){
|
||||
store.dispatch(uiActions.runProcess(action.type, {batches: batches}))
|
||||
},
|
||||
},
|
||||
100
|
||||
)
|
||||
},
|
||||
@ -770,9 +770,9 @@ const MopidyMiddleware = (function(){
|
||||
// wait 100ms so the server can trigger track_changed etc
|
||||
// this means our UI feels snappier as the first track shows up quickly
|
||||
setTimeout(
|
||||
function(){
|
||||
function(){
|
||||
store.dispatch(mopidyActions.enqueueURIs(action.uris, action.from_uri, null, 1))
|
||||
},
|
||||
},
|
||||
100
|
||||
)
|
||||
}
|
||||
@ -808,7 +808,7 @@ const MopidyMiddleware = (function(){
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch(coreActions.clearCurrentTrack());
|
||||
|
||||
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'notification',
|
||||
{
|
||||
@ -913,11 +913,11 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
request(socket, store, 'library.search', {query: {album: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||
.then(
|
||||
response => {
|
||||
if (response.length > 0){
|
||||
if (response.length > 0){
|
||||
var albums = [];
|
||||
|
||||
// Merge our proper album response container
|
||||
@ -937,16 +937,16 @@ const MopidyMiddleware = (function(){
|
||||
var albums_uris = helpers.arrayOf('uri',albums)
|
||||
albums_uris = helpers.removeDuplicates(albums_uris)
|
||||
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'ALBUMS_LOADED',
|
||||
albums: albums
|
||||
})
|
||||
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
context: action.data.context,
|
||||
results: albums_uris
|
||||
results: albums_uris
|
||||
})
|
||||
}
|
||||
|
||||
@ -963,7 +963,7 @@ const MopidyMiddleware = (function(){
|
||||
break
|
||||
|
||||
// Artists
|
||||
case 'artists':
|
||||
case 'artists':
|
||||
|
||||
store.dispatch(uiActions.updateProcess(
|
||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||
@ -985,7 +985,7 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
request(socket, store, 'library.search', {query: {artist: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||
.then(
|
||||
response => {
|
||||
response => {
|
||||
if (response.length > 0){
|
||||
var artists_uris = [];
|
||||
|
||||
@ -1018,10 +1018,10 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
context: action.data.context,
|
||||
results: artists_uris
|
||||
results: artists_uris
|
||||
})
|
||||
}
|
||||
|
||||
@ -1113,8 +1113,8 @@ const MopidyMiddleware = (function(){
|
||||
if (response.length > 0 && response[0].tracks !== undefined){
|
||||
var tracks = response[0].tracks;
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
context: action.data.context,
|
||||
results: helpers.formatTracks(tracks)
|
||||
});
|
||||
@ -1148,8 +1148,8 @@ const MopidyMiddleware = (function(){
|
||||
if (response.length > 0 && response[0].tracks !== undefined){
|
||||
var tracks = response[0].tracks;
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
context: 'tracks',
|
||||
results: helpers.formatTracks(tracks)
|
||||
});
|
||||
@ -1176,7 +1176,7 @@ const MopidyMiddleware = (function(){
|
||||
));
|
||||
request(socket, store, 'library.search', {query: {album: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||
.then(
|
||||
response => {
|
||||
response => {
|
||||
if (response.length > 0){
|
||||
var albums = [];
|
||||
|
||||
@ -1197,16 +1197,16 @@ const MopidyMiddleware = (function(){
|
||||
var albums_uris = helpers.arrayOf('uri',albums)
|
||||
albums_uris = helpers.removeDuplicates(albums_uris)
|
||||
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'ALBUMS_LOADED',
|
||||
albums: albums
|
||||
})
|
||||
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
context: 'albums',
|
||||
results: albums_uris
|
||||
results: albums_uris
|
||||
})
|
||||
}
|
||||
|
||||
@ -1232,7 +1232,7 @@ const MopidyMiddleware = (function(){
|
||||
));
|
||||
request(socket, store, 'library.search', {query: {artist: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||
.then(
|
||||
response => {
|
||||
response => {
|
||||
if (response.length > 0){
|
||||
var artists_uris = [];
|
||||
|
||||
@ -1265,10 +1265,10 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
context: 'artists',
|
||||
results: artists_uris
|
||||
results: artists_uris
|
||||
})
|
||||
}
|
||||
|
||||
@ -1396,10 +1396,10 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
)
|
||||
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_LOADED',
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_LOADED',
|
||||
key: playlist.uri,
|
||||
playlist: playlist
|
||||
playlist: playlist
|
||||
});
|
||||
})
|
||||
}
|
||||
@ -1425,13 +1425,13 @@ const MopidyMiddleware = (function(){
|
||||
// tracks? get the full track objects
|
||||
if (playlist.tracks.length > 0){
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_RESOLVE_PLAYLIST_TRACKS',
|
||||
tracks: playlist.tracks,
|
||||
type: 'MOPIDY_RESOLVE_PLAYLIST_TRACKS',
|
||||
tracks: playlist.tracks,
|
||||
key: playlist.uri
|
||||
});
|
||||
}
|
||||
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_LOADED',
|
||||
key: playlist.uri,
|
||||
playlist: playlist
|
||||
@ -1450,13 +1450,13 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
var track = response[uri][0]
|
||||
if (track){
|
||||
|
||||
|
||||
// find the track reference, and drop in the full track data
|
||||
function getByURI(trackReference){
|
||||
return track.uri == trackReference.uri
|
||||
}
|
||||
var trackReferences = tracks.filter(getByURI);
|
||||
|
||||
|
||||
// there could be multiple instances of this track, so accommodate this
|
||||
for(var j = 0; j < trackReferences.length; j++){
|
||||
var key = tracks.indexOf(trackReferences[j] );
|
||||
@ -1466,19 +1466,19 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_TRACKS',
|
||||
tracks: tracks,
|
||||
key: action.key
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_TRACKS',
|
||||
tracks: tracks,
|
||||
key: action.key
|
||||
})
|
||||
})
|
||||
break
|
||||
|
||||
case 'MOPIDY_ADD_PLAYLIST_TRACKS':
|
||||
|
||||
|
||||
request(socket, store, 'playlists.lookup', { uri: action.key })
|
||||
.then(response => {
|
||||
var tracks = [];
|
||||
var tracks = [];
|
||||
for(var i = 0; i < action.tracks_uris.length; i++){
|
||||
tracks.push({
|
||||
__model__: "Track",
|
||||
@ -1495,9 +1495,9 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
request(socket, store, 'playlists.save', { playlist: playlist } )
|
||||
.then(response => {
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_TRACKS_ADDED',
|
||||
key: action.key,
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_TRACKS_ADDED',
|
||||
key: action.key,
|
||||
tracks_uris: action.tracks_uris
|
||||
});
|
||||
})
|
||||
@ -1506,13 +1506,13 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
case 'MOPIDY_REMOVE_PLAYLIST_TRACKS':
|
||||
|
||||
// reverse order our indexes (otherwise removing from top will affect the keys following)
|
||||
// reverse order our indexes (otherwise removing from top will affect the keys following)
|
||||
function descending(a,b){
|
||||
return b-a;
|
||||
}
|
||||
var indexes = Object.assign([], action.tracks_indexes)
|
||||
indexes.sort(descending);
|
||||
|
||||
|
||||
request(socket, store, 'playlists.lookup', { uri: action.key })
|
||||
.then(response => {
|
||||
var playlist = Object.assign({}, response)
|
||||
@ -1522,8 +1522,8 @@ const MopidyMiddleware = (function(){
|
||||
request(socket, store, 'playlists.save', { playlist: playlist } )
|
||||
.then(response => {
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_TRACKS_REMOVED',
|
||||
key: action.key,
|
||||
type: 'PLAYLIST_TRACKS_REMOVED',
|
||||
key: action.key,
|
||||
tracks_indexes: action.tracks_indexes
|
||||
});
|
||||
})
|
||||
@ -1538,8 +1538,8 @@ const MopidyMiddleware = (function(){
|
||||
request(socket, store, 'playlists.save', { playlist: playlist })
|
||||
.then(response => {
|
||||
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_LOADED',
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_LOADED',
|
||||
key: action.key,
|
||||
playlist: playlist
|
||||
});
|
||||
@ -1547,8 +1547,8 @@ const MopidyMiddleware = (function(){
|
||||
// When we rename a playlist, the URI also changes to reflect the name change
|
||||
// We need to update our index, as well as redirect our current page URL
|
||||
if (action.key != response.key){
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_KEY_UPDATED',
|
||||
store.dispatch({
|
||||
type: 'PLAYLIST_KEY_UPDATED',
|
||||
key: action.key,
|
||||
new_key: response.uri
|
||||
});
|
||||
@ -1593,9 +1593,9 @@ const MopidyMiddleware = (function(){
|
||||
playlist = Object.assign({}, playlist, { tracks: tracks })
|
||||
request(socket, store, 'playlists.save', { playlist: playlist } )
|
||||
.then(response => {
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_RESOLVE_PLAYLIST_TRACKS',
|
||||
tracks: playlist.tracks,
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_RESOLVE_PLAYLIST_TRACKS',
|
||||
tracks: playlist.tracks,
|
||||
key: playlist.uri
|
||||
});
|
||||
});
|
||||
@ -1604,7 +1604,7 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
case 'MOPIDY_CREATE_PLAYLIST':
|
||||
request(socket, store, 'playlists.create', { name: action.name, uri_scheme: action.scheme })
|
||||
.then(response => {
|
||||
.then(response => {
|
||||
store.dispatch(uiActions.createNotification({type: 'info', content: 'Created playlist'}))
|
||||
|
||||
store.dispatch({
|
||||
@ -1629,9 +1629,9 @@ const MopidyMiddleware = (function(){
|
||||
type: 'MOPIDY_LIBRARY_PLAYLIST_DELETED',
|
||||
key: action.uri
|
||||
})
|
||||
});
|
||||
});
|
||||
break
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* =============================================================== ALBUM(S) =============
|
||||
@ -1647,15 +1647,15 @@ const MopidyMiddleware = (function(){
|
||||
if (response.length <= 0) return
|
||||
|
||||
var uris = helpers.arrayOf('uri',response)
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_ALBUMS_LOADED',
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_ALBUMS_LOADED',
|
||||
uris: uris
|
||||
});
|
||||
|
||||
// Start our process to load the full album objects
|
||||
store.dispatch(uiActions.startProcess(
|
||||
'MOPIDY_LIBRARY_ALBUMS_PROCESSOR',
|
||||
'Loading '+uris.length+' local albums',
|
||||
'Loading '+uris.length+' local albums',
|
||||
{
|
||||
uris: uris,
|
||||
total: uris.length,
|
||||
@ -1665,9 +1665,9 @@ const MopidyMiddleware = (function(){
|
||||
})
|
||||
|
||||
} else if (last_run.status == 'cancelled'){
|
||||
store.dispatch(uiActions.resumeProcess('MOPIDY_LIBRARY_ALBUMS_PROCESSOR'))
|
||||
store.dispatch(uiActions.resumeProcess('MOPIDY_LIBRARY_ALBUMS_PROCESSOR'))
|
||||
} else if (last_run.status == 'finished'){
|
||||
// TODO: do we want to force a refresh?
|
||||
// TODO: do we want to force a refresh?
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1688,7 +1688,7 @@ const MopidyMiddleware = (function(){
|
||||
if (uris_to_load.length > 0){
|
||||
store.dispatch(uiActions.updateProcess(
|
||||
'MOPIDY_LIBRARY_ALBUMS_PROCESSOR',
|
||||
'Loading '+uris.length+' local albums',
|
||||
'Loading '+uris.length+' local albums',
|
||||
{
|
||||
uris: uris,
|
||||
remaining: uris.length
|
||||
@ -1725,7 +1725,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'ALBUMS_LOADED',
|
||||
albums: albums
|
||||
})
|
||||
@ -1737,7 +1737,7 @@ const MopidyMiddleware = (function(){
|
||||
setTimeout(
|
||||
function(){
|
||||
store.dispatch(uiActions.runProcess(action.processor.name, action.processor.data))
|
||||
},
|
||||
},
|
||||
100
|
||||
)
|
||||
}
|
||||
@ -1745,10 +1745,12 @@ 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(
|
||||
{},
|
||||
{ images: [] },
|
||||
@ -1760,7 +1762,7 @@ const MopidyMiddleware = (function(){
|
||||
tracks_total: response.length
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
var uris = [];
|
||||
for(var i = 0; i < album.tracks.length; i++){
|
||||
uris.push(album.tracks[i].uri );
|
||||
@ -1783,13 +1785,13 @@ const MopidyMiddleware = (function(){
|
||||
if (response.hasOwnProperty(uri)){
|
||||
|
||||
var track = response[uri][0];
|
||||
|
||||
|
||||
// find the track reference, and drop in the full track data
|
||||
function getByURI(trackReference){
|
||||
return track.uri == trackReference.uri
|
||||
}
|
||||
var trackReferences = album.tracks.filter(getByURI);
|
||||
|
||||
|
||||
// there could be multiple instances of this track, so accommodate this
|
||||
for(var j = 0; j < trackReferences.length; j++){
|
||||
var key = album.tracks.indexOf(trackReferences[j] );
|
||||
@ -1798,15 +1800,11 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
store.dispatch({
|
||||
type: 'ALBUM_LOADED',
|
||||
key: album.uri,
|
||||
album: album
|
||||
});
|
||||
store.dispatch(coreActions.albumLoaded(album));
|
||||
})
|
||||
})
|
||||
break;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* =============================================================== ARTIST(S) ============
|
||||
@ -1818,7 +1816,7 @@ const MopidyMiddleware = (function(){
|
||||
if (response.length <= 0) return
|
||||
|
||||
var uris = [];
|
||||
for (var i = 0; i < response.length; i++){
|
||||
for (var i = 0; i < response.length; i++){
|
||||
|
||||
// Convert local URI to actual artist URI
|
||||
// See https://github.com/mopidy/mopidy-local-sqlite/issues/39
|
||||
@ -1826,13 +1824,10 @@ 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',
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
||||
uris: uris
|
||||
});
|
||||
});
|
||||
@ -1842,7 +1837,7 @@ const MopidyMiddleware = (function(){
|
||||
* TODO: Fetch and process library artists
|
||||
*
|
||||
* We can't get specific artist artwork from Mopidy. Perhaps we fetch additional
|
||||
* artist metadata via LastFM? Their API limits will make this quite slow.
|
||||
* artist metadata via LastFM? Their API limits will make this quite slow.
|
||||
case 'MOPIDY_GET_LIBRARY_ARTISTS':
|
||||
|
||||
var last_run = store.getState().ui.processes.MOPIDY_LIBRARY_ARTISTS_PROCESSOR
|
||||
@ -1854,8 +1849,8 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
var uris = helpers.arrayOf('uri',response);
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
||||
uris: uris
|
||||
});
|
||||
|
||||
@ -1864,9 +1859,9 @@ const MopidyMiddleware = (function(){
|
||||
})
|
||||
|
||||
} else if (last_run.status == 'cancelled'){
|
||||
store.dispatch(uiActions.resumeProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'))
|
||||
store.dispatch(uiActions.resumeProcess('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'))
|
||||
} else if (last_run.status == 'finished'){
|
||||
// TODO: do we want to force a refresh?
|
||||
// TODO: do we want to force a refresh?
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1898,7 +1893,7 @@ const MopidyMiddleware = (function(){
|
||||
request(socket, store, 'library.lookup', action.data )
|
||||
.then(response => {
|
||||
if (response.length <= 0) return
|
||||
|
||||
|
||||
var albums = [];
|
||||
for (var i = 0; i < response.length; i++){
|
||||
if (response[i].album){
|
||||
@ -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];
|
||||
@ -1973,11 +1961,8 @@ const MopidyMiddleware = (function(){
|
||||
artists.push(artist);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -1986,13 +1971,13 @@ const MopidyMiddleware = (function(){
|
||||
setTimeout(
|
||||
function(){
|
||||
store.dispatch(uiActions.runProcess(action.processor.name, action.processor.data))
|
||||
},
|
||||
},
|
||||
100
|
||||
)
|
||||
}
|
||||
})
|
||||
break;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* =============================================================== TRACKS ================
|
||||
@ -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 => {
|
||||
@ -2111,7 +2093,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
)
|
||||
break
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* =============================================================== IMAGES ===============
|
||||
@ -2140,7 +2122,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var action_data = {
|
||||
type: (action.context+'_LOADED').toUpperCase()
|
||||
}
|
||||
@ -2150,7 +2132,7 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* =============================================================== LOCAL ================
|
||||
@ -2161,7 +2143,7 @@ const MopidyMiddleware = (function(){
|
||||
store.dispatch({ type: 'MOPIDY_DIRECTORY_LOADED', data: false })
|
||||
request(socket, store, 'library.browse', action.data)
|
||||
.then(response => {
|
||||
store.dispatch({
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_DIRECTORY_LOADED',
|
||||
data: response
|
||||
});
|
||||
@ -2183,4 +2165,4 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
})();
|
||||
|
||||
export default MopidyMiddleware
|
||||
export default MopidyMiddleware
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +56,7 @@ class Album extends React.Component{
|
||||
}
|
||||
}
|
||||
|
||||
setWindowTitle(album = this.props.album){
|
||||
setWindowTitle(album = this.props.album){
|
||||
if (album){
|
||||
var artists = "";
|
||||
for (var i = 0; i < album.artists.length; i++){
|
||||
@ -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,
|
||||
@ -125,7 +102,7 @@ class Album extends React.Component{
|
||||
}
|
||||
|
||||
render(){
|
||||
if (!this.props.album){
|
||||
if (!this.props.album){
|
||||
if (helpers.isLoading(this.props.load_queue,['spotify_albums/'+helpers.getFromUri('albumid',this.props.params.uri)])){
|
||||
return (
|
||||
<div className="body-loader loading">
|
||||
@ -217,10 +194,11 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
coreActions: bindActionCreators(coreActions, dispatch),
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Album)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Album)
|
||||
|
||||
@ -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'
|
||||
@ -53,7 +54,7 @@ class Artist extends React.Component{
|
||||
}
|
||||
}
|
||||
|
||||
setWindowTitle(artist = this.props.artist){
|
||||
setWindowTitle(artist = this.props.artist){
|
||||
if (artist){
|
||||
this.props.uiActions.setWindowTitle(artist.name+" (artist)");
|
||||
} else{
|
||||
@ -126,7 +127,7 @@ class Artist extends React.Component{
|
||||
this.props.uiActions.set({artist_albums_filter: value});
|
||||
}
|
||||
|
||||
renderSubViewMenu(){
|
||||
renderSubViewMenu(){
|
||||
return (
|
||||
<div className="sub-views">
|
||||
<Link className="option" activeClassName="active" to={global.baseURL+'artist/'+this.props.params.uri}><h4>Overview</h4></Link>
|
||||
@ -136,7 +137,7 @@ class Artist extends React.Component{
|
||||
)
|
||||
}
|
||||
|
||||
renderBody(){
|
||||
renderBody(){
|
||||
var scheme = helpers.uriSource(this.props.params.uri);
|
||||
|
||||
var related_artists = []
|
||||
@ -276,18 +277,18 @@ class Artist extends React.Component{
|
||||
<div className="albums">
|
||||
<h4>
|
||||
Albums
|
||||
<DropdownField
|
||||
icon="sort"
|
||||
name="Sort"
|
||||
value={this.props.sort}
|
||||
options={sort_options}
|
||||
<DropdownField
|
||||
icon="sort"
|
||||
name="Sort"
|
||||
value={this.props.sort}
|
||||
options={sort_options}
|
||||
selected_icon={this.props.sort ? (this.props.sort_reverse ? 'keyboard_arrow_up' : 'keyboard_arrow_down') : null}
|
||||
handleChange={value => {this.setSort(value); this.props.uiActions.hideContextMenu() }}
|
||||
/>
|
||||
<DropdownField
|
||||
icon="filter_list"
|
||||
name="Filter"
|
||||
value={this.props.filter}
|
||||
<DropdownField
|
||||
icon="filter_list"
|
||||
name="Filter"
|
||||
value={this.props.filter}
|
||||
options={filter_options}
|
||||
handleChange={value => {this.setFilter(value); this.props.uiActions.hideContextMenu() }}
|
||||
/>
|
||||
@ -325,7 +326,7 @@ class Artist extends React.Component{
|
||||
}
|
||||
|
||||
var is_spotify = (scheme == 'spotify')
|
||||
|
||||
|
||||
if (this.props.artist.tracks_uris && this.props.artist.tracks_uris.length > 0){
|
||||
var uris_to_play = this.props.artist.tracks_uris
|
||||
} else {
|
||||
@ -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),
|
||||
@ -392,4 +394,4 @@ const mapDispatchToProps = (dispatch) => {
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Artist)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Artist)
|
||||
|
||||
@ -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'
|
||||
@ -75,7 +76,7 @@ class Track extends React.Component{
|
||||
}
|
||||
}
|
||||
|
||||
setWindowTitle(track = this.props.track){
|
||||
setWindowTitle(track = this.props.track){
|
||||
if (track){
|
||||
var artists = "";
|
||||
for (var i = 0; i < track.artists.length; i++){
|
||||
@ -102,7 +103,7 @@ class Track extends React.Component{
|
||||
|
||||
/**
|
||||
* TODO: Identify why images being loaded breaks the thumbnail. Is there a new image array format
|
||||
* we need to accommodate?
|
||||
* we need to accommodate?
|
||||
**/
|
||||
loadTrack(props = this.props){
|
||||
switch (helpers.uriSource(props.params.uri)){
|
||||
@ -171,8 +172,8 @@ class Track extends React.Component{
|
||||
{
|
||||
this.props.track.lyrics_results.map(result => {
|
||||
return (
|
||||
<option
|
||||
key={result.path}
|
||||
<option
|
||||
key={result.path}
|
||||
value={result.path}
|
||||
defaultValue={result.path == this.props.track.lyrics_path}
|
||||
>
|
||||
@ -231,10 +232,10 @@ class Track extends React.Component{
|
||||
return (
|
||||
<div className="view track-view content-wrapper">
|
||||
|
||||
{this.props.slim_mode ? <Header
|
||||
icon="music"
|
||||
title="Track"
|
||||
handleContextMenuTrigger={e => this.handleContextMenu(e)}
|
||||
{this.props.slim_mode ? <Header
|
||||
icon="music"
|
||||
title="Track"
|
||||
handleContextMenuTrigger={e => this.handleContextMenu(e)}
|
||||
uiActions={this.props.uiActions} /> : null}
|
||||
|
||||
<div className="thumbnail-wrapper">
|
||||
@ -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),
|
||||
@ -316,4 +317,4 @@ const mapDispatchToProps = (dispatch) => {
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Track)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Track)
|
||||
|
||||
@ -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'
|
||||
@ -37,7 +38,7 @@ class User extends React.Component{
|
||||
}
|
||||
}
|
||||
|
||||
setWindowTitle(user = this.props.user){
|
||||
setWindowTitle(user = this.props.user){
|
||||
if (user){
|
||||
this.props.uiActions.setWindowTitle(user.name+" (user)");
|
||||
} else{
|
||||
@ -71,7 +72,7 @@ class User extends React.Component{
|
||||
render(){
|
||||
var user_id = helpers.getFromUri('userid',this.props.params.uri);
|
||||
|
||||
if (!this.props.user){
|
||||
if (!this.props.user){
|
||||
if (helpers.isLoading(this.props.load_queue,['spotify_users/'+user_id,'spotify_users/'+user_id+'/playlists/?'])){
|
||||
return (
|
||||
<div className="body-loader loading">
|
||||
@ -117,7 +118,7 @@ class User extends React.Component{
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="content-wrapper">
|
||||
<section className="grid-wrapper">
|
||||
<h4>Playlists</h4>
|
||||
@ -143,9 +144,10 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
coreActions: bindActionCreators(coreActions, dispatch),
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(User)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(User)
|
||||
|
||||
Reference in New Issue
Block a user