Customising artist and album library URIs

This commit is contained in:
James Barnsley
2018-06-10 10:02:31 +12:00
parent cd5908630c
commit 25d77b65cc
10 changed files with 225 additions and 75 deletions

View File

@ -58,17 +58,6 @@ const localstorageMiddleware = (function(){
);
break;
case 'MOPIDY_SET_CONFIG':
helpers.setStorage(
'mopidy',
{
host: action.config.host,
port: action.config.port,
ssl: action.config.ssl
}
);
break;
case 'MOPIDY_URISCHEMES_FILTERED':
helpers.setStorage(
'mopidy',
@ -78,13 +67,6 @@ const localstorageMiddleware = (function(){
);
break;
case 'SPOTIFY_SET':
helpers.setStorage(
'spotify',
action.data
);
break;
case 'SPOTIFY_IMPORT_AUTHORIZATION':
case 'SPOTIFY_AUTHORIZATION_GRANTED':
if (action.authorization !== undefined){
@ -149,6 +131,20 @@ const localstorageMiddleware = (function(){
);
break
case 'MOPIDY_SET':
helpers.setStorage(
'mopidy',
action.data
);
break;
case 'SPOTIFY_SET':
helpers.setStorage(
'spotify',
action.data
);
break;
case 'SUPPRESS_BROADCAST':
var ui = helpers.getStorage('ui');
if (ui.suppressed_broadcasts !== undefined){

View File

@ -1,11 +1,11 @@
import * as helpers from '../../helpers'
export function setConfig(config){
return {
type: 'MOPIDY_SET_CONFIG',
config: config
}
export function set(data){
return {
type: 'MOPIDY_SET',
data: data
}
}
export function connect(){
@ -352,6 +352,12 @@ export function getLibraryArtists(){
}
}
export function clearLibraryArtists(){
return {
type: 'MOPIDY_CLEAR_LIBRARY_ARTISTS'
}
}
export function getArtist(uri){
return {
type: 'MOPIDY_GET_ARTIST',
@ -388,6 +394,12 @@ export function getLibraryAlbums(){
}
}
export function clearLibraryAlbums(){
return {
type: 'MOPIDY_CLEAR_LIBRARY_ALBUMS'
}
}
export function runProcessor(processor){
return {
type: processor

View File

@ -1640,7 +1640,7 @@ const MopidyMiddleware = (function(){
var last_run = store.getState().ui.processes.MOPIDY_LIBRARY_ALBUMS_PROCESSOR
if (!last_run){
request(socket, store, 'library.browse', { uri: 'local:directory?type=album' } )
request(socket, store, 'library.browse', { uri: store.getState().mopidy.library_albums_uri } )
.then(response => {
if (response.length <= 0) return
@ -1811,11 +1811,18 @@ const MopidyMiddleware = (function(){
* ======================================================================================
**/
case 'MOPIDY_GET_LIBRARY_ARTISTS':
request(socket, store, 'library.browse', { uri: 'local:directory?type=artist' } )
request(socket, store, 'library.browse', { uri: store.getState().mopidy.library_artists_uri } )
.then(response => {
if (response.length <= 0) return
var uris = helpers.arrayOf('uri',response)
var uris = [];
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
response[i].uri = response[i].uri.replace('local:directory?albumartist=','');
uris.push(response[i].uri);
}
store.dispatch({
type: 'ARTISTS_LOADED',

View File

@ -20,13 +20,6 @@ export default function reducer(mopidy = {}, action){
case 'MOPIDY_DISCONNECTED':
return Object.assign({}, mopidy, { connected: false, connecting: false });
case 'MOPIDY_SET_CONFIG':
return Object.assign({}, mopidy, {
host: action.config.host,
port: action.config.port,
ssl: action.config.ssl
});
case 'MOPIDY_CHANGE_TRACK':
return Object.assign({}, mopidy, {
tlid: action.tlid
@ -37,6 +30,9 @@ export default function reducer(mopidy = {}, action){
uri_schemes: action.uri_schemes
});
case 'MOPIDY_SET':
return Object.assign({}, mopidy, action.data);
/**
* State-oriented actions
@ -142,6 +138,9 @@ export default function reducer(mopidy = {}, action){
}
return Object.assign({}, mopidy, { library_artists: helpers.removeDuplicates(uris) })
case 'MOPIDY_CLEAR_LIBRARY_ARTISTS':
return Object.assign({}, mopidy, { library_artists: null })
case 'MOPIDY_LIBRARY_ALBUMS_LOADED':
if (mopidy.library_albums){
var uris = [...mopidy.library_albums,...action.uris]
@ -150,6 +149,9 @@ export default function reducer(mopidy = {}, action){
}
return Object.assign({}, mopidy, { library_albums: helpers.removeDuplicates(uris) })
case 'MOPIDY_CLEAR_LIBRARY_ALBUMS':
return Object.assign({}, mopidy, { library_albums: null })
/**
* Searching