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
|
// Release details
|
||||||
// These are automatically injected to built HTML
|
// These are automatically injected to built HTML
|
||||||
var build = "1534063312";
|
var build = "1534105233";
|
||||||
var version = "3.23.2";
|
var version = "3.23.2";
|
||||||
|
|
||||||
// Construct the script tag
|
// Construct the script tag
|
||||||
|
|||||||
@ -26,7 +26,7 @@ const CoreMiddleware = (function(){
|
|||||||
if (action.description){
|
if (action.description){
|
||||||
var description = action.description;
|
var description = action.description;
|
||||||
} else if (action.data.xhr && action.data.xhr.responseText){
|
} 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){
|
if (xhr_response.error && xhr_response.error.message){
|
||||||
var description = xhr_response.error.message;
|
var description = xhr_response.error.message;
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ const CoreMiddleware = (function(){
|
|||||||
|
|
||||||
var data = Object.assign(
|
var data = Object.assign(
|
||||||
{},
|
{},
|
||||||
action.data,
|
action.data,
|
||||||
{
|
{
|
||||||
message: message,
|
message: message,
|
||||||
description: description,
|
description: description,
|
||||||
@ -75,7 +75,7 @@ const CoreMiddleware = (function(){
|
|||||||
/*
|
/*
|
||||||
if (store.getState().ui.allow_reporting){
|
if (store.getState().ui.allow_reporting){
|
||||||
Raven.captureException(
|
Raven.captureException(
|
||||||
new Error(message),
|
new Error(message),
|
||||||
{
|
{
|
||||||
extra: data
|
extra: data
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ const CoreMiddleware = (function(){
|
|||||||
break
|
break
|
||||||
|
|
||||||
case 'PLAYLIST_TRACKS_ADDED':
|
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)){
|
switch(helpers.uriSource(action.key)){
|
||||||
|
|
||||||
case 'spotify':
|
case 'spotify':
|
||||||
@ -267,7 +267,7 @@ const CoreMiddleware = (function(){
|
|||||||
type: 'TRACKS_LOADED',
|
type: 'TRACKS_LOADED',
|
||||||
tracks: tracks
|
tracks: tracks
|
||||||
});
|
});
|
||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ const CoreMiddleware = (function(){
|
|||||||
snapshot_id = action.snapshot_id;
|
snapshot_id = action.snapshot_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update our playlist
|
// Update our playlist
|
||||||
playlist.tracks_uris = tracks_uris;
|
playlist.tracks_uris = tracks_uris;
|
||||||
playlist.snapshot_id = snapshot_id;
|
playlist.snapshot_id = snapshot_id;
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ const CoreMiddleware = (function(){
|
|||||||
snapshot_id = action.snapshot_id;
|
snapshot_id = action.snapshot_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update our playlist
|
// Update our playlist
|
||||||
playlist.tracks_uris = tracks_uris;
|
playlist.tracks_uris = tracks_uris;
|
||||||
playlist.snapshot_id = snapshot_id;
|
playlist.snapshot_id = snapshot_id;
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ const CoreMiddleware = (function(){
|
|||||||
type: 'TRACKS_LOADED',
|
type: 'TRACKS_LOADED',
|
||||||
tracks: action.tracks
|
tracks: action.tracks
|
||||||
});
|
});
|
||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -360,14 +360,16 @@ const CoreMiddleware = (function(){
|
|||||||
switch (helpers.uriSource(action.uri)){
|
switch (helpers.uriSource(action.uri)){
|
||||||
case 'spotify':
|
case 'spotify':
|
||||||
store.dispatch(spotifyActions.getTrack(action.uri));
|
store.dispatch(spotifyActions.getTrack(action.uri));
|
||||||
//store.dispatch(spotifyActions.following(action.uri));
|
store.dispatch(spotifyActions.following(action.uri));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
store.dispatch(mopidyActions.getTrack(action.uri));
|
if (store.getState().mopidy.connected){
|
||||||
|
store.dispatch(mopidyActions.getTrack(action.uri));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -379,10 +381,12 @@ const CoreMiddleware = (function(){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
store.dispatch(mopidyActions.getAlbum(action.uri));
|
if (store.getState().mopidy.connected){
|
||||||
|
store.dispatch(mopidyActions.getAlbum(action.uri));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -394,10 +398,12 @@ const CoreMiddleware = (function(){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
store.dispatch(mopidyActions.getArtist(action.uri));
|
if (store.getState().mopidy.connected){
|
||||||
|
store.dispatch(mopidyActions.getArtist(action.uri));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -409,10 +415,12 @@ const CoreMiddleware = (function(){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
store.dispatch(mopidyActions.getPlaylist(action.uri));
|
if (store.getState().mopidy.connected){
|
||||||
|
store.dispatch(mopidyActions.getPlaylist(action.uri));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
break;
|
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 pusherActions = require('../pusher/actions.js')
|
||||||
var lastfmActions = require('../lastfm/actions.js')
|
var lastfmActions = require('../lastfm/actions.js')
|
||||||
|
|
||||||
const MopidyMiddleware = (function(){
|
const MopidyMiddleware = (function(){
|
||||||
|
|
||||||
// container for the actual Mopidy socket
|
// container for the actual Mopidy socket
|
||||||
var socket = null;
|
var socket = null;
|
||||||
@ -88,7 +88,7 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
case 'event:seeked':
|
case 'event:seeked':
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_TIME_POSITION',
|
type: 'MOPIDY_TIME_POSITION',
|
||||||
time_position: data.time_position
|
time_position: data.time_position
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -145,10 +145,10 @@ const MopidyMiddleware = (function(){
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (method in ws[model]){
|
if (method in ws[model]){
|
||||||
var mopidyObject = ws[model][method];
|
var mopidyObject = ws[model][method];
|
||||||
var property = method;
|
var property = method;
|
||||||
} else {
|
} else {
|
||||||
var mopidyObject = ws[model];
|
var mopidyObject = ws[model];
|
||||||
var property = model;
|
var property = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect invalid model.method calls, which result in an empty mopidyObject
|
// Detect invalid model.method calls, which result in an empty mopidyObject
|
||||||
@ -160,7 +160,7 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch(coreActions.handleException(
|
store.dispatch(coreActions.handleException(
|
||||||
'Mopidy: '+error.message,
|
'Mopidy: '+error.message,
|
||||||
error
|
error
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ const MopidyMiddleware = (function(){
|
|||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_VOLUME',
|
type: 'MOPIDY_VOLUME',
|
||||||
volume: response
|
volume: response
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -456,7 +456,7 @@ const MopidyMiddleware = (function(){
|
|||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_VOLUME',
|
type: 'MOPIDY_VOLUME',
|
||||||
volume: action.volume
|
volume: action.volume
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ const MopidyMiddleware = (function(){
|
|||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_TIME_POSITION',
|
type: 'MOPIDY_TIME_POSITION',
|
||||||
time_position: action.time_position
|
time_position: action.time_position
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -540,7 +540,7 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
// playlist already in index
|
// playlist already in index
|
||||||
if (store.getState().core.playlists.hasOwnProperty(action.uri)){
|
if (store.getState().core.playlists.hasOwnProperty(action.uri)){
|
||||||
|
|
||||||
// make sure we didn't get this playlist from Mopidy-Spotify
|
// 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 we did, we'd have a cached version on server so no need to fetch
|
||||||
if (!store.getState().core.playlists[action.uri].is_mopidy){
|
if (!store.getState().core.playlists[action.uri].is_mopidy){
|
||||||
@ -619,7 +619,7 @@ const MopidyMiddleware = (function(){
|
|||||||
// start our processor
|
// start our processor
|
||||||
store.dispatch(uiActions.startProcess(
|
store.dispatch(uiActions.startProcess(
|
||||||
'MOPIDY_ENQUEUE_URIS_PROCESSOR',
|
'MOPIDY_ENQUEUE_URIS_PROCESSOR',
|
||||||
'Adding '+action.uris.length+' URI(s)',
|
'Adding '+action.uris.length+' URI(s)',
|
||||||
{
|
{
|
||||||
batches: batches,
|
batches: batches,
|
||||||
remaining: action.uris.length,
|
remaining: action.uris.length,
|
||||||
@ -628,7 +628,7 @@ const MopidyMiddleware = (function(){
|
|||||||
))
|
))
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'MOPIDY_ENQUEUE_URIS_PROCESSOR':
|
case 'MOPIDY_ENQUEUE_URIS_PROCESSOR':
|
||||||
|
|
||||||
var last_run = store.getState().ui.processes.MOPIDY_ENQUEUE_URIS_PROCESSOR
|
var last_run = store.getState().ui.processes.MOPIDY_ENQUEUE_URIS_PROCESSOR
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
batches.shift()
|
batches.shift()
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_ENQUEUE_URIS_PROCESSOR',
|
'MOPIDY_ENQUEUE_URIS_PROCESSOR',
|
||||||
'Adding '+total_uris+' URI(s)',
|
'Adding '+total_uris+' URI(s)',
|
||||||
{
|
{
|
||||||
remaining: total_uris
|
remaining: total_uris
|
||||||
@ -710,7 +710,7 @@ const MopidyMiddleware = (function(){
|
|||||||
setTimeout(
|
setTimeout(
|
||||||
function(){
|
function(){
|
||||||
store.dispatch(uiActions.runProcess(action.type, {batches: batches}))
|
store.dispatch(uiActions.runProcess(action.type, {batches: batches}))
|
||||||
},
|
},
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -770,9 +770,9 @@ const MopidyMiddleware = (function(){
|
|||||||
// wait 100ms so the server can trigger track_changed etc
|
// wait 100ms so the server can trigger track_changed etc
|
||||||
// this means our UI feels snappier as the first track shows up quickly
|
// this means our UI feels snappier as the first track shows up quickly
|
||||||
setTimeout(
|
setTimeout(
|
||||||
function(){
|
function(){
|
||||||
store.dispatch(mopidyActions.enqueueURIs(action.uris, action.from_uri, null, 1))
|
store.dispatch(mopidyActions.enqueueURIs(action.uris, action.from_uri, null, 1))
|
||||||
},
|
},
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -808,7 +808,7 @@ const MopidyMiddleware = (function(){
|
|||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
store.dispatch(coreActions.clearCurrentTrack());
|
store.dispatch(coreActions.clearCurrentTrack());
|
||||||
|
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'notification',
|
'notification',
|
||||||
{
|
{
|
||||||
@ -913,11 +913,11 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
request(socket, store, 'library.search', {query: {album: [action.data.query]}, uris: [action.data.uri_scheme]})
|
request(socket, store, 'library.search', {query: {album: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
if (response.length > 0){
|
if (response.length > 0){
|
||||||
var albums = [];
|
var albums = [];
|
||||||
|
|
||||||
// Merge our proper album response container
|
// Merge our proper album response container
|
||||||
@ -937,16 +937,16 @@ const MopidyMiddleware = (function(){
|
|||||||
var albums_uris = helpers.arrayOf('uri',albums)
|
var albums_uris = helpers.arrayOf('uri',albums)
|
||||||
albums_uris = helpers.removeDuplicates(albums_uris)
|
albums_uris = helpers.removeDuplicates(albums_uris)
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'ALBUMS_LOADED',
|
type: 'ALBUMS_LOADED',
|
||||||
albums: albums
|
albums: albums
|
||||||
})
|
})
|
||||||
|
|
||||||
// and plug in their URIs
|
// and plug in their URIs
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||||
context: action.data.context,
|
context: action.data.context,
|
||||||
results: albums_uris
|
results: albums_uris
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -963,7 +963,7 @@ const MopidyMiddleware = (function(){
|
|||||||
break
|
break
|
||||||
|
|
||||||
// Artists
|
// Artists
|
||||||
case 'artists':
|
case 'artists':
|
||||||
|
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
'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]})
|
request(socket, store, 'library.search', {query: {artist: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
if (response.length > 0){
|
if (response.length > 0){
|
||||||
var artists_uris = [];
|
var artists_uris = [];
|
||||||
|
|
||||||
@ -1018,10 +1018,10 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// and plug in their URIs
|
// and plug in their URIs
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||||
context: action.data.context,
|
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){
|
if (response.length > 0 && response[0].tracks !== undefined){
|
||||||
var tracks = response[0].tracks;
|
var tracks = response[0].tracks;
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||||
context: action.data.context,
|
context: action.data.context,
|
||||||
results: helpers.formatTracks(tracks)
|
results: helpers.formatTracks(tracks)
|
||||||
});
|
});
|
||||||
@ -1148,8 +1148,8 @@ const MopidyMiddleware = (function(){
|
|||||||
if (response.length > 0 && response[0].tracks !== undefined){
|
if (response.length > 0 && response[0].tracks !== undefined){
|
||||||
var tracks = response[0].tracks;
|
var tracks = response[0].tracks;
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||||
context: 'tracks',
|
context: 'tracks',
|
||||||
results: helpers.formatTracks(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]})
|
request(socket, store, 'library.search', {query: {album: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
if (response.length > 0){
|
if (response.length > 0){
|
||||||
var albums = [];
|
var albums = [];
|
||||||
|
|
||||||
@ -1197,16 +1197,16 @@ const MopidyMiddleware = (function(){
|
|||||||
var albums_uris = helpers.arrayOf('uri',albums)
|
var albums_uris = helpers.arrayOf('uri',albums)
|
||||||
albums_uris = helpers.removeDuplicates(albums_uris)
|
albums_uris = helpers.removeDuplicates(albums_uris)
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'ALBUMS_LOADED',
|
type: 'ALBUMS_LOADED',
|
||||||
albums: albums
|
albums: albums
|
||||||
})
|
})
|
||||||
|
|
||||||
// and plug in their URIs
|
// and plug in their URIs
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||||
context: 'albums',
|
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]})
|
request(socket, store, 'library.search', {query: {artist: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
if (response.length > 0){
|
if (response.length > 0){
|
||||||
var artists_uris = [];
|
var artists_uris = [];
|
||||||
|
|
||||||
@ -1265,10 +1265,10 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// and plug in their URIs
|
// and plug in their URIs
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||||
context: 'artists',
|
context: 'artists',
|
||||||
results: artists_uris
|
results: artists_uris
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1396,10 +1396,10 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'PLAYLIST_LOADED',
|
type: 'PLAYLIST_LOADED',
|
||||||
key: playlist.uri,
|
key: playlist.uri,
|
||||||
playlist: playlist
|
playlist: playlist
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1425,13 +1425,13 @@ const MopidyMiddleware = (function(){
|
|||||||
// tracks? get the full track objects
|
// tracks? get the full track objects
|
||||||
if (playlist.tracks.length > 0){
|
if (playlist.tracks.length > 0){
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_RESOLVE_PLAYLIST_TRACKS',
|
type: 'MOPIDY_RESOLVE_PLAYLIST_TRACKS',
|
||||||
tracks: playlist.tracks,
|
tracks: playlist.tracks,
|
||||||
key: playlist.uri
|
key: playlist.uri
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'PLAYLIST_LOADED',
|
type: 'PLAYLIST_LOADED',
|
||||||
key: playlist.uri,
|
key: playlist.uri,
|
||||||
playlist: playlist
|
playlist: playlist
|
||||||
@ -1450,13 +1450,13 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
var track = response[uri][0]
|
var track = response[uri][0]
|
||||||
if (track){
|
if (track){
|
||||||
|
|
||||||
// find the track reference, and drop in the full track data
|
// find the track reference, and drop in the full track data
|
||||||
function getByURI(trackReference){
|
function getByURI(trackReference){
|
||||||
return track.uri == trackReference.uri
|
return track.uri == trackReference.uri
|
||||||
}
|
}
|
||||||
var trackReferences = tracks.filter(getByURI);
|
var trackReferences = tracks.filter(getByURI);
|
||||||
|
|
||||||
// there could be multiple instances of this track, so accommodate this
|
// there could be multiple instances of this track, so accommodate this
|
||||||
for(var j = 0; j < trackReferences.length; j++){
|
for(var j = 0; j < trackReferences.length; j++){
|
||||||
var key = tracks.indexOf(trackReferences[j] );
|
var key = tracks.indexOf(trackReferences[j] );
|
||||||
@ -1466,19 +1466,19 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'PLAYLIST_TRACKS',
|
type: 'PLAYLIST_TRACKS',
|
||||||
tracks: tracks,
|
tracks: tracks,
|
||||||
key: action.key
|
key: action.key
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'MOPIDY_ADD_PLAYLIST_TRACKS':
|
case 'MOPIDY_ADD_PLAYLIST_TRACKS':
|
||||||
|
|
||||||
request(socket, store, 'playlists.lookup', { uri: action.key })
|
request(socket, store, 'playlists.lookup', { uri: action.key })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
var tracks = [];
|
var tracks = [];
|
||||||
for(var i = 0; i < action.tracks_uris.length; i++){
|
for(var i = 0; i < action.tracks_uris.length; i++){
|
||||||
tracks.push({
|
tracks.push({
|
||||||
__model__: "Track",
|
__model__: "Track",
|
||||||
@ -1495,9 +1495,9 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
request(socket, store, 'playlists.save', { playlist: playlist } )
|
request(socket, store, 'playlists.save', { playlist: playlist } )
|
||||||
.then(response => {
|
.then(response => {
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'PLAYLIST_TRACKS_ADDED',
|
type: 'PLAYLIST_TRACKS_ADDED',
|
||||||
key: action.key,
|
key: action.key,
|
||||||
tracks_uris: action.tracks_uris
|
tracks_uris: action.tracks_uris
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -1506,13 +1506,13 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
case 'MOPIDY_REMOVE_PLAYLIST_TRACKS':
|
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){
|
function descending(a,b){
|
||||||
return b-a;
|
return b-a;
|
||||||
}
|
}
|
||||||
var indexes = Object.assign([], action.tracks_indexes)
|
var indexes = Object.assign([], action.tracks_indexes)
|
||||||
indexes.sort(descending);
|
indexes.sort(descending);
|
||||||
|
|
||||||
request(socket, store, 'playlists.lookup', { uri: action.key })
|
request(socket, store, 'playlists.lookup', { uri: action.key })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
var playlist = Object.assign({}, response)
|
var playlist = Object.assign({}, response)
|
||||||
@ -1522,8 +1522,8 @@ const MopidyMiddleware = (function(){
|
|||||||
request(socket, store, 'playlists.save', { playlist: playlist } )
|
request(socket, store, 'playlists.save', { playlist: playlist } )
|
||||||
.then(response => {
|
.then(response => {
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'PLAYLIST_TRACKS_REMOVED',
|
type: 'PLAYLIST_TRACKS_REMOVED',
|
||||||
key: action.key,
|
key: action.key,
|
||||||
tracks_indexes: action.tracks_indexes
|
tracks_indexes: action.tracks_indexes
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -1538,8 +1538,8 @@ const MopidyMiddleware = (function(){
|
|||||||
request(socket, store, 'playlists.save', { playlist: playlist })
|
request(socket, store, 'playlists.save', { playlist: playlist })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'PLAYLIST_LOADED',
|
type: 'PLAYLIST_LOADED',
|
||||||
key: action.key,
|
key: action.key,
|
||||||
playlist: playlist
|
playlist: playlist
|
||||||
});
|
});
|
||||||
@ -1547,8 +1547,8 @@ const MopidyMiddleware = (function(){
|
|||||||
// When we rename a playlist, the URI also changes to reflect the name change
|
// 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
|
// We need to update our index, as well as redirect our current page URL
|
||||||
if (action.key != response.key){
|
if (action.key != response.key){
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'PLAYLIST_KEY_UPDATED',
|
type: 'PLAYLIST_KEY_UPDATED',
|
||||||
key: action.key,
|
key: action.key,
|
||||||
new_key: response.uri
|
new_key: response.uri
|
||||||
});
|
});
|
||||||
@ -1593,9 +1593,9 @@ const MopidyMiddleware = (function(){
|
|||||||
playlist = Object.assign({}, playlist, { tracks: tracks })
|
playlist = Object.assign({}, playlist, { tracks: tracks })
|
||||||
request(socket, store, 'playlists.save', { playlist: playlist } )
|
request(socket, store, 'playlists.save', { playlist: playlist } )
|
||||||
.then(response => {
|
.then(response => {
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_RESOLVE_PLAYLIST_TRACKS',
|
type: 'MOPIDY_RESOLVE_PLAYLIST_TRACKS',
|
||||||
tracks: playlist.tracks,
|
tracks: playlist.tracks,
|
||||||
key: playlist.uri
|
key: playlist.uri
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1604,7 +1604,7 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
case 'MOPIDY_CREATE_PLAYLIST':
|
case 'MOPIDY_CREATE_PLAYLIST':
|
||||||
request(socket, store, 'playlists.create', { name: action.name, uri_scheme: action.scheme })
|
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(uiActions.createNotification({type: 'info', content: 'Created playlist'}))
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
@ -1629,9 +1629,9 @@ const MopidyMiddleware = (function(){
|
|||||||
type: 'MOPIDY_LIBRARY_PLAYLIST_DELETED',
|
type: 'MOPIDY_LIBRARY_PLAYLIST_DELETED',
|
||||||
key: action.uri
|
key: action.uri
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =============================================================== ALBUM(S) =============
|
* =============================================================== ALBUM(S) =============
|
||||||
@ -1647,15 +1647,15 @@ const MopidyMiddleware = (function(){
|
|||||||
if (response.length <= 0) return
|
if (response.length <= 0) return
|
||||||
|
|
||||||
var uris = helpers.arrayOf('uri',response)
|
var uris = helpers.arrayOf('uri',response)
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_LIBRARY_ALBUMS_LOADED',
|
type: 'MOPIDY_LIBRARY_ALBUMS_LOADED',
|
||||||
uris: uris
|
uris: uris
|
||||||
});
|
});
|
||||||
|
|
||||||
// Start our process to load the full album objects
|
// Start our process to load the full album objects
|
||||||
store.dispatch(uiActions.startProcess(
|
store.dispatch(uiActions.startProcess(
|
||||||
'MOPIDY_LIBRARY_ALBUMS_PROCESSOR',
|
'MOPIDY_LIBRARY_ALBUMS_PROCESSOR',
|
||||||
'Loading '+uris.length+' local albums',
|
'Loading '+uris.length+' local albums',
|
||||||
{
|
{
|
||||||
uris: uris,
|
uris: uris,
|
||||||
total: uris.length,
|
total: uris.length,
|
||||||
@ -1665,9 +1665,9 @@ const MopidyMiddleware = (function(){
|
|||||||
})
|
})
|
||||||
|
|
||||||
} else if (last_run.status == 'cancelled'){
|
} 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'){
|
} else if (last_run.status == 'finished'){
|
||||||
// TODO: do we want to force a refresh?
|
// TODO: do we want to force a refresh?
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1688,7 +1688,7 @@ const MopidyMiddleware = (function(){
|
|||||||
if (uris_to_load.length > 0){
|
if (uris_to_load.length > 0){
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_LIBRARY_ALBUMS_PROCESSOR',
|
'MOPIDY_LIBRARY_ALBUMS_PROCESSOR',
|
||||||
'Loading '+uris.length+' local albums',
|
'Loading '+uris.length+' local albums',
|
||||||
{
|
{
|
||||||
uris: uris,
|
uris: uris,
|
||||||
remaining: uris.length
|
remaining: uris.length
|
||||||
@ -1725,7 +1725,7 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'ALBUMS_LOADED',
|
type: 'ALBUMS_LOADED',
|
||||||
albums: albums
|
albums: albums
|
||||||
})
|
})
|
||||||
@ -1737,7 +1737,7 @@ const MopidyMiddleware = (function(){
|
|||||||
setTimeout(
|
setTimeout(
|
||||||
function(){
|
function(){
|
||||||
store.dispatch(uiActions.runProcess(action.processor.name, action.processor.data))
|
store.dispatch(uiActions.runProcess(action.processor.name, action.processor.data))
|
||||||
},
|
},
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -1745,10 +1745,12 @@ const MopidyMiddleware = (function(){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'MOPIDY_GET_ALBUM':
|
case 'MOPIDY_GET_ALBUM':
|
||||||
request(socket, store, 'library.lookup', action.data )
|
request(socket, store, 'library.lookup', action.data)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.length <= 0) return
|
if (response.length <= 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var album = Object.assign(
|
var album = Object.assign(
|
||||||
{},
|
{},
|
||||||
{ images: [] },
|
{ images: [] },
|
||||||
@ -1760,7 +1762,7 @@ const MopidyMiddleware = (function(){
|
|||||||
tracks_total: response.length
|
tracks_total: response.length
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
var uris = [];
|
var uris = [];
|
||||||
for(var i = 0; i < album.tracks.length; i++){
|
for(var i = 0; i < album.tracks.length; i++){
|
||||||
uris.push(album.tracks[i].uri );
|
uris.push(album.tracks[i].uri );
|
||||||
@ -1783,13 +1785,13 @@ const MopidyMiddleware = (function(){
|
|||||||
if (response.hasOwnProperty(uri)){
|
if (response.hasOwnProperty(uri)){
|
||||||
|
|
||||||
var track = response[uri][0];
|
var track = response[uri][0];
|
||||||
|
|
||||||
// find the track reference, and drop in the full track data
|
// find the track reference, and drop in the full track data
|
||||||
function getByURI(trackReference){
|
function getByURI(trackReference){
|
||||||
return track.uri == trackReference.uri
|
return track.uri == trackReference.uri
|
||||||
}
|
}
|
||||||
var trackReferences = album.tracks.filter(getByURI);
|
var trackReferences = album.tracks.filter(getByURI);
|
||||||
|
|
||||||
// there could be multiple instances of this track, so accommodate this
|
// there could be multiple instances of this track, so accommodate this
|
||||||
for(var j = 0; j < trackReferences.length; j++){
|
for(var j = 0; j < trackReferences.length; j++){
|
||||||
var key = album.tracks.indexOf(trackReferences[j] );
|
var key = album.tracks.indexOf(trackReferences[j] );
|
||||||
@ -1798,15 +1800,11 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch(coreActions.albumLoaded(album));
|
||||||
type: 'ALBUM_LOADED',
|
|
||||||
key: album.uri,
|
|
||||||
album: album
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =============================================================== ARTIST(S) ============
|
* =============================================================== ARTIST(S) ============
|
||||||
@ -1818,7 +1816,7 @@ const MopidyMiddleware = (function(){
|
|||||||
if (response.length <= 0) return
|
if (response.length <= 0) return
|
||||||
|
|
||||||
var uris = [];
|
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
|
// Convert local URI to actual artist URI
|
||||||
// See https://github.com/mopidy/mopidy-local-sqlite/issues/39
|
// See https://github.com/mopidy/mopidy-local-sqlite/issues/39
|
||||||
@ -1826,13 +1824,10 @@ const MopidyMiddleware = (function(){
|
|||||||
uris.push(response[i].uri);
|
uris.push(response[i].uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch(coreActions.artistsLoaded(response));
|
||||||
type: 'ARTISTS_LOADED',
|
|
||||||
artists: response
|
|
||||||
});
|
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
||||||
uris: uris
|
uris: uris
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1842,7 +1837,7 @@ const MopidyMiddleware = (function(){
|
|||||||
* TODO: Fetch and process library artists
|
* TODO: Fetch and process library artists
|
||||||
*
|
*
|
||||||
* We can't get specific artist artwork from Mopidy. Perhaps we fetch additional
|
* 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':
|
case 'MOPIDY_GET_LIBRARY_ARTISTS':
|
||||||
|
|
||||||
var last_run = store.getState().ui.processes.MOPIDY_LIBRARY_ARTISTS_PROCESSOR
|
var last_run = store.getState().ui.processes.MOPIDY_LIBRARY_ARTISTS_PROCESSOR
|
||||||
@ -1854,8 +1849,8 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
var uris = helpers.arrayOf('uri',response);
|
var uris = helpers.arrayOf('uri',response);
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
type: 'MOPIDY_LIBRARY_ARTISTS_LOADED',
|
||||||
uris: uris
|
uris: uris
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1864,9 +1859,9 @@ const MopidyMiddleware = (function(){
|
|||||||
})
|
})
|
||||||
|
|
||||||
} else if (last_run.status == 'cancelled'){
|
} 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'){
|
} else if (last_run.status == 'finished'){
|
||||||
// TODO: do we want to force a refresh?
|
// TODO: do we want to force a refresh?
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1898,7 +1893,7 @@ const MopidyMiddleware = (function(){
|
|||||||
request(socket, store, 'library.lookup', action.data )
|
request(socket, store, 'library.lookup', action.data )
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.length <= 0) return
|
if (response.length <= 0) return
|
||||||
|
|
||||||
var albums = [];
|
var albums = [];
|
||||||
for (var i = 0; i < response.length; i++){
|
for (var i = 0; i < response.length; i++){
|
||||||
if (response[i].album){
|
if (response[i].album){
|
||||||
@ -1921,10 +1916,7 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (albums){
|
if (albums){
|
||||||
store.dispatch({
|
store.dispatch(coreActions.albumsLoaded(albums));
|
||||||
type: 'ALBUMS_LOADED',
|
|
||||||
albums: albums
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var artist = Object.assign(
|
var artist = Object.assign(
|
||||||
@ -1936,11 +1928,7 @@ const MopidyMiddleware = (function(){
|
|||||||
tracks: response.slice(0,10)
|
tracks: response.slice(0,10)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
store.dispatch({
|
store.dispatch(coreActions.artistLoaded(artist));
|
||||||
type: 'ARTIST_LOADED',
|
|
||||||
key: artist.uri,
|
|
||||||
artist: artist
|
|
||||||
});
|
|
||||||
|
|
||||||
// load artwork from LastFM
|
// load artwork from LastFM
|
||||||
var existing_artist = store.getState().core.artists[artist.uri];
|
var existing_artist = store.getState().core.artists[artist.uri];
|
||||||
@ -1973,11 +1961,8 @@ const MopidyMiddleware = (function(){
|
|||||||
artists.push(artist);
|
artists.push(artist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch(coreActions.artistsLoaded(artists));
|
||||||
type: 'ARTISTS_LOADED',
|
|
||||||
artists: artists
|
|
||||||
});
|
|
||||||
|
|
||||||
// Re-run any consequential processes in 100ms. This allows a small window for other
|
// 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
|
// 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(
|
setTimeout(
|
||||||
function(){
|
function(){
|
||||||
store.dispatch(uiActions.runProcess(action.processor.name, action.processor.data))
|
store.dispatch(uiActions.runProcess(action.processor.name, action.processor.data))
|
||||||
},
|
},
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =============================================================== TRACKS ================
|
* =============================================================== TRACKS ================
|
||||||
@ -2097,10 +2082,7 @@ const MopidyMiddleware = (function(){
|
|||||||
response => {
|
response => {
|
||||||
if (response.length > 0){
|
if (response.length > 0){
|
||||||
var track = Object.assign({}, response[0]);
|
var track = Object.assign({}, response[0]);
|
||||||
store.dispatch({
|
store.dispatch(coreActions.trackLoaded(track));
|
||||||
type: 'TRACKS_LOADED',
|
|
||||||
tracks: [track]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
@ -2111,7 +2093,7 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =============================================================== IMAGES ===============
|
* =============================================================== IMAGES ===============
|
||||||
@ -2140,7 +2122,7 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var action_data = {
|
var action_data = {
|
||||||
type: (action.context+'_LOADED').toUpperCase()
|
type: (action.context+'_LOADED').toUpperCase()
|
||||||
}
|
}
|
||||||
@ -2150,7 +2132,7 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =============================================================== LOCAL ================
|
* =============================================================== LOCAL ================
|
||||||
@ -2161,7 +2143,7 @@ const MopidyMiddleware = (function(){
|
|||||||
store.dispatch({ type: 'MOPIDY_DIRECTORY_LOADED', data: false })
|
store.dispatch({ type: 'MOPIDY_DIRECTORY_LOADED', data: false })
|
||||||
request(socket, store, 'library.browse', action.data)
|
request(socket, store, 'library.browse', action.data)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'MOPIDY_DIRECTORY_LOADED',
|
type: 'MOPIDY_DIRECTORY_LOADED',
|
||||||
data: response
|
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 Icon from '../components/Icon'
|
||||||
|
|
||||||
import * as helpers from '../helpers'
|
import * as helpers from '../helpers'
|
||||||
|
import * as coreActions from '../services/core/actions'
|
||||||
import * as uiActions from '../services/ui/actions'
|
import * as uiActions from '../services/ui/actions'
|
||||||
import * as mopidyActions from '../services/mopidy/actions'
|
import * as mopidyActions from '../services/mopidy/actions'
|
||||||
import * as spotifyActions from '../services/spotify/actions'
|
import * as spotifyActions from '../services/spotify/actions'
|
||||||
@ -28,7 +29,7 @@ class Album extends React.Component{
|
|||||||
|
|
||||||
componentDidMount(){
|
componentDidMount(){
|
||||||
this.setWindowTitle();
|
this.setWindowTitle();
|
||||||
this.loadAlbum();
|
this.props.coreActions.loadAlbum(this.props.params.uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleContextMenu(e){
|
handleContextMenu(e){
|
||||||
@ -41,12 +42,12 @@ class Album extends React.Component{
|
|||||||
|
|
||||||
// if our URI has changed, fetch new album
|
// if our URI has changed, fetch new album
|
||||||
if (nextProps.params.uri != this.props.params.uri){
|
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
|
// if mopidy has just connected AND we're a local album, go get
|
||||||
}else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
|
} else if (!this.props.mopidy_connected && nextProps.mopidy_connected){
|
||||||
if (helpers.uriSource(this.props.params.uri ) != 'spotify'){
|
if (helpers.uriSource(nextProps.params.uri) != 'spotify'){
|
||||||
this.loadAlbum(nextProps);
|
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){
|
if (album){
|
||||||
var artists = "";
|
var artists = "";
|
||||||
for (var i = 0; i < album.artists.length; i++){
|
for (var i = 0; i < album.artists.length; i++){
|
||||||
@ -80,30 +81,6 @@ class Album extends React.Component{
|
|||||||
this.props.uiActions.showContextMenu(data);
|
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(){
|
loadMore(){
|
||||||
this.props.spotifyActions.getMore(
|
this.props.spotifyActions.getMore(
|
||||||
this.props.album.tracks_more,
|
this.props.album.tracks_more,
|
||||||
@ -125,7 +102,7 @@ class Album extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
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)])){
|
if (helpers.isLoading(this.props.load_queue,['spotify_albums/'+helpers.getFromUri('albumid',this.props.params.uri)])){
|
||||||
return (
|
return (
|
||||||
<div className="body-loader loading">
|
<div className="body-loader loading">
|
||||||
@ -217,10 +194,11 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return {
|
return {
|
||||||
|
coreActions: bindActionCreators(coreActions, dispatch),
|
||||||
uiActions: bindActionCreators(uiActions, dispatch),
|
uiActions: bindActionCreators(uiActions, dispatch),
|
||||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||||
spotifyActions: bindActionCreators(spotifyActions, 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 Icon from '../components/Icon'
|
||||||
|
|
||||||
import * as helpers from '../helpers'
|
import * as helpers from '../helpers'
|
||||||
|
import * as coreActions from '../services/core/actions'
|
||||||
import * as uiActions from '../services/ui/actions'
|
import * as uiActions from '../services/ui/actions'
|
||||||
import * as mopidyActions from '../services/mopidy/actions'
|
import * as mopidyActions from '../services/mopidy/actions'
|
||||||
import * as pusherActions from '../services/pusher/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){
|
if (artist){
|
||||||
this.props.uiActions.setWindowTitle(artist.name+" (artist)");
|
this.props.uiActions.setWindowTitle(artist.name+" (artist)");
|
||||||
} else{
|
} else{
|
||||||
@ -126,7 +127,7 @@ class Artist extends React.Component{
|
|||||||
this.props.uiActions.set({artist_albums_filter: value});
|
this.props.uiActions.set({artist_albums_filter: value});
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSubViewMenu(){
|
renderSubViewMenu(){
|
||||||
return (
|
return (
|
||||||
<div className="sub-views">
|
<div className="sub-views">
|
||||||
<Link className="option" activeClassName="active" to={global.baseURL+'artist/'+this.props.params.uri}><h4>Overview</h4></Link>
|
<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 scheme = helpers.uriSource(this.props.params.uri);
|
||||||
|
|
||||||
var related_artists = []
|
var related_artists = []
|
||||||
@ -276,18 +277,18 @@ class Artist extends React.Component{
|
|||||||
<div className="albums">
|
<div className="albums">
|
||||||
<h4>
|
<h4>
|
||||||
Albums
|
Albums
|
||||||
<DropdownField
|
<DropdownField
|
||||||
icon="sort"
|
icon="sort"
|
||||||
name="Sort"
|
name="Sort"
|
||||||
value={this.props.sort}
|
value={this.props.sort}
|
||||||
options={sort_options}
|
options={sort_options}
|
||||||
selected_icon={this.props.sort ? (this.props.sort_reverse ? 'keyboard_arrow_up' : 'keyboard_arrow_down') : null}
|
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() }}
|
handleChange={value => {this.setSort(value); this.props.uiActions.hideContextMenu() }}
|
||||||
/>
|
/>
|
||||||
<DropdownField
|
<DropdownField
|
||||||
icon="filter_list"
|
icon="filter_list"
|
||||||
name="Filter"
|
name="Filter"
|
||||||
value={this.props.filter}
|
value={this.props.filter}
|
||||||
options={filter_options}
|
options={filter_options}
|
||||||
handleChange={value => {this.setFilter(value); this.props.uiActions.hideContextMenu() }}
|
handleChange={value => {this.setFilter(value); this.props.uiActions.hideContextMenu() }}
|
||||||
/>
|
/>
|
||||||
@ -325,7 +326,7 @@ class Artist extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var is_spotify = (scheme == 'spotify')
|
var is_spotify = (scheme == 'spotify')
|
||||||
|
|
||||||
if (this.props.artist.tracks_uris && this.props.artist.tracks_uris.length > 0){
|
if (this.props.artist.tracks_uris && this.props.artist.tracks_uris.length > 0){
|
||||||
var uris_to_play = this.props.artist.tracks_uris
|
var uris_to_play = this.props.artist.tracks_uris
|
||||||
} else {
|
} else {
|
||||||
@ -384,6 +385,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return {
|
return {
|
||||||
|
coreActions: bindActionCreators(coreActions, dispatch),
|
||||||
uiActions: bindActionCreators(uiActions, dispatch),
|
uiActions: bindActionCreators(uiActions, dispatch),
|
||||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||||
pusherActions: bindActionCreators(pusherActions, 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 Popularity from '../components/Popularity'
|
||||||
|
|
||||||
import * as helpers from '../helpers'
|
import * as helpers from '../helpers'
|
||||||
|
import * as coreActions from '../services/core/actions'
|
||||||
import * as uiActions from '../services/ui/actions'
|
import * as uiActions from '../services/ui/actions'
|
||||||
import * as mopidyActions from '../services/mopidy/actions'
|
import * as mopidyActions from '../services/mopidy/actions'
|
||||||
import * as spotifyActions from '../services/spotify/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){
|
if (track){
|
||||||
var artists = "";
|
var artists = "";
|
||||||
for (var i = 0; i < track.artists.length; i++){
|
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
|
* 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){
|
loadTrack(props = this.props){
|
||||||
switch (helpers.uriSource(props.params.uri)){
|
switch (helpers.uriSource(props.params.uri)){
|
||||||
@ -171,8 +172,8 @@ class Track extends React.Component{
|
|||||||
{
|
{
|
||||||
this.props.track.lyrics_results.map(result => {
|
this.props.track.lyrics_results.map(result => {
|
||||||
return (
|
return (
|
||||||
<option
|
<option
|
||||||
key={result.path}
|
key={result.path}
|
||||||
value={result.path}
|
value={result.path}
|
||||||
defaultValue={result.path == this.props.track.lyrics_path}
|
defaultValue={result.path == this.props.track.lyrics_path}
|
||||||
>
|
>
|
||||||
@ -231,10 +232,10 @@ class Track extends React.Component{
|
|||||||
return (
|
return (
|
||||||
<div className="view track-view content-wrapper">
|
<div className="view track-view content-wrapper">
|
||||||
|
|
||||||
{this.props.slim_mode ? <Header
|
{this.props.slim_mode ? <Header
|
||||||
icon="music"
|
icon="music"
|
||||||
title="Track"
|
title="Track"
|
||||||
handleContextMenuTrigger={e => this.handleContextMenu(e)}
|
handleContextMenuTrigger={e => this.handleContextMenu(e)}
|
||||||
uiActions={this.props.uiActions} /> : null}
|
uiActions={this.props.uiActions} /> : null}
|
||||||
|
|
||||||
<div className="thumbnail-wrapper">
|
<div className="thumbnail-wrapper">
|
||||||
@ -307,7 +308,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return {
|
return {
|
||||||
uiActions: bindActionCreators(uiActions, dispatch),
|
coreActions: bindActionCreators(coreActions, dispatch),
|
||||||
uiActions: bindActionCreators(uiActions, dispatch),
|
uiActions: bindActionCreators(uiActions, dispatch),
|
||||||
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
||||||
lastfmActions: bindActionCreators(lastfmActions, 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 Icon from '../components/Icon'
|
||||||
|
|
||||||
import * as helpers from '../helpers'
|
import * as helpers from '../helpers'
|
||||||
|
import * as coreActions from '../services/core/actions'
|
||||||
import * as uiActions from '../services/ui/actions'
|
import * as uiActions from '../services/ui/actions'
|
||||||
import * as mopidyActions from '../services/mopidy/actions'
|
import * as mopidyActions from '../services/mopidy/actions'
|
||||||
import * as spotifyActions from '../services/spotify/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){
|
if (user){
|
||||||
this.props.uiActions.setWindowTitle(user.name+" (user)");
|
this.props.uiActions.setWindowTitle(user.name+" (user)");
|
||||||
} else{
|
} else{
|
||||||
@ -71,7 +72,7 @@ class User extends React.Component{
|
|||||||
render(){
|
render(){
|
||||||
var user_id = helpers.getFromUri('userid',this.props.params.uri);
|
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/?'])){
|
if (helpers.isLoading(this.props.load_queue,['spotify_users/'+user_id,'spotify_users/'+user_id+'/playlists/?'])){
|
||||||
return (
|
return (
|
||||||
<div className="body-loader loading">
|
<div className="body-loader loading">
|
||||||
@ -117,7 +118,7 @@ class User extends React.Component{
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="content-wrapper">
|
<div className="content-wrapper">
|
||||||
<section className="grid-wrapper">
|
<section className="grid-wrapper">
|
||||||
<h4>Playlists</h4>
|
<h4>Playlists</h4>
|
||||||
@ -143,9 +144,10 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return {
|
return {
|
||||||
|
coreActions: bindActionCreators(coreActions, dispatch),
|
||||||
uiActions: bindActionCreators(uiActions, dispatch),
|
uiActions: bindActionCreators(uiActions, dispatch),
|
||||||
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(User)
|
export default connect(mapStateToProps, mapDispatchToProps)(User)
|
||||||
|
|||||||
Reference in New Issue
Block a user