2016-10-03 15:22:15 +13:00
|
|
|
|
2016-10-16 12:37:37 +13:00
|
|
|
import { createStore, applyMiddleware, combineReducers } from 'redux'
|
|
|
|
|
|
2017-11-23 21:15:35 +13:00
|
|
|
import * as helpers from './helpers'
|
|
|
|
|
|
2017-08-02 10:53:30 +12:00
|
|
|
import core from './services/core/reducer'
|
2016-10-27 10:02:12 +13:00
|
|
|
import ui from './services/ui/reducer'
|
2016-10-27 16:58:11 +13:00
|
|
|
import pusher from './services/pusher/reducer'
|
2016-10-16 12:37:37 +13:00
|
|
|
import mopidy from './services/mopidy/reducer'
|
2016-11-07 21:21:15 +13:00
|
|
|
import lastfm from './services/lastfm/reducer'
|
2016-10-16 12:37:37 +13:00
|
|
|
import spotify from './services/spotify/reducer'
|
2017-10-04 16:47:15 +13:00
|
|
|
import genius from './services/genius/reducer'
|
2016-10-16 12:37:37 +13:00
|
|
|
|
2016-10-14 22:42:45 +13:00
|
|
|
import thunk from 'redux-thunk'
|
2017-08-02 10:53:30 +12:00
|
|
|
import coreMiddleware from './services/core/middleware'
|
2016-11-11 16:47:32 +13:00
|
|
|
import uiMiddleware from './services/ui/middleware'
|
2016-10-27 16:58:11 +13:00
|
|
|
import pusherMiddleware from './services/pusher/middleware'
|
2016-10-14 22:42:45 +13:00
|
|
|
import mopidyMiddleware from './services/mopidy/middleware'
|
2017-11-03 09:06:41 +13:00
|
|
|
import lastfmMiddleware from './services/lastfm/middleware'
|
2016-10-16 12:37:37 +13:00
|
|
|
import spotifyMiddleware from './services/spotify/middleware'
|
2016-10-17 22:00:29 +13:00
|
|
|
import localstorageMiddleware from './services/localstorage/middleware'
|
2016-10-16 12:37:37 +13:00
|
|
|
|
|
|
|
|
let reducers = combineReducers({
|
2017-08-02 10:53:30 +12:00
|
|
|
core,
|
2016-10-27 10:02:12 +13:00
|
|
|
ui,
|
2016-10-27 16:58:11 +13:00
|
|
|
pusher,
|
2016-10-16 12:37:37 +13:00
|
|
|
mopidy,
|
2016-11-07 21:21:15 +13:00
|
|
|
lastfm,
|
2017-10-04 16:47:15 +13:00
|
|
|
genius,
|
2016-10-16 12:37:37 +13:00
|
|
|
spotify
|
|
|
|
|
});
|
2016-10-03 15:22:15 +13:00
|
|
|
|
2016-10-18 08:56:53 +13:00
|
|
|
// set application defaults
|
2016-10-28 09:14:29 +13:00
|
|
|
// TODO: Look at using propTypes in the component for these falsy initial states
|
2016-10-18 08:56:53 +13:00
|
|
|
var initialState = {
|
2017-08-02 10:53:30 +12:00
|
|
|
core: {
|
2018-03-12 21:39:27 +13:00
|
|
|
outputs: [],
|
2017-11-10 15:56:01 +13:00
|
|
|
queue: [],
|
|
|
|
|
queue_metadata: {},
|
2018-04-01 21:26:42 +12:00
|
|
|
current_track: null,
|
2017-08-10 12:00:08 +12:00
|
|
|
albums: {},
|
2017-09-25 20:22:48 +13:00
|
|
|
artists: {},
|
2017-08-10 12:00:08 +12:00
|
|
|
playlists: {},
|
2017-09-25 20:22:48 +13:00
|
|
|
users: {},
|
2018-02-01 08:52:15 +13:00
|
|
|
tracks: {},
|
|
|
|
|
http_streaming_enabled: false,
|
2018-02-02 08:39:37 +13:00
|
|
|
http_streaming_encoding: 'mpeg',
|
2018-02-01 08:52:15 +13:00
|
|
|
http_streaming_url: "http://"+window.location.hostname+":8000/mopidy"
|
2017-08-02 10:53:30 +12:00
|
|
|
},
|
|
|
|
|
ui: {
|
2018-06-06 21:16:00 +12:00
|
|
|
allow_reporting: false,
|
2017-08-02 10:53:30 +12:00
|
|
|
slim_mode: false,
|
|
|
|
|
selected_tracks: [],
|
2018-02-28 08:44:38 +13:00
|
|
|
notifications: {},
|
2017-08-10 12:00:08 +12:00
|
|
|
processes: {}
|
2017-08-02 10:53:30 +12:00
|
|
|
},
|
2016-10-18 08:56:53 +13:00
|
|
|
mopidy: {
|
2016-10-28 09:14:29 +13:00
|
|
|
connected: false,
|
2016-10-18 08:56:53 +13:00
|
|
|
host: window.location.hostname,
|
2017-06-11 20:39:31 +12:00
|
|
|
port: (window.location.port ? window.location.port : (window.location.protocol === 'https:' ? '443' : '80')),
|
2017-11-27 16:38:33 +13:00
|
|
|
ssl: (window.location.protocol === 'https:' ? true : false),
|
2017-05-19 11:33:06 +12:00
|
|
|
mute: false,
|
2016-10-20 17:40:18 +13:00
|
|
|
volume: 0,
|
2016-11-09 13:18:03 +13:00
|
|
|
progress: 0,
|
2018-03-26 10:36:13 +13:00
|
|
|
play_state: false,
|
2018-06-10 10:02:31 +12:00
|
|
|
uri_schemes: [],
|
|
|
|
|
library_albums_uri: 'local:directory?type=album',
|
|
|
|
|
library_artists_uri: 'local:directory?type=artist'
|
2016-10-18 21:57:29 +13:00
|
|
|
},
|
2016-10-27 16:58:11 +13:00
|
|
|
pusher: {
|
2016-10-28 09:14:29 +13:00
|
|
|
connected: false,
|
2018-02-01 08:06:40 +13:00
|
|
|
username: false,
|
2017-02-19 21:27:43 +13:00
|
|
|
connections: {},
|
2016-10-29 22:40:02 +13:00
|
|
|
version: {
|
|
|
|
|
current: '0.0.0'
|
2018-03-26 10:36:13 +13:00
|
|
|
},
|
|
|
|
|
config: {}
|
2016-10-27 16:58:11 +13:00
|
|
|
},
|
2016-11-07 21:21:15 +13:00
|
|
|
lastfm: {
|
2017-11-02 21:20:56 +13:00
|
|
|
me: false,
|
|
|
|
|
authorization_url: 'https://jamesbarnsley.co.nz/auth_lastfm.php'
|
2017-10-04 16:47:15 +13:00
|
|
|
},
|
2018-04-01 11:52:42 +12:00
|
|
|
genius: {},
|
2016-10-18 21:57:29 +13:00
|
|
|
spotify: {
|
2017-05-12 05:22:57 +12:00
|
|
|
me: false,
|
2017-08-02 10:53:30 +12:00
|
|
|
autocomplete_results: {},
|
2017-11-02 21:20:56 +13:00
|
|
|
authorization_url: 'https://jamesbarnsley.co.nz/auth_spotify.php'
|
2016-10-18 08:56:53 +13:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-11-23 17:43:29 +13:00
|
|
|
// load all our stored values from LocalStorage
|
|
|
|
|
initialState.core = Object.assign({}, initialState.core, helpers.getStorage('core'));
|
|
|
|
|
initialState.ui = Object.assign({}, initialState.ui, helpers.getStorage('ui'));
|
|
|
|
|
initialState.mopidy = Object.assign({}, initialState.mopidy, helpers.getStorage('mopidy'));
|
|
|
|
|
initialState.pusher = Object.assign({}, initialState.pusher, helpers.getStorage('pusher'));
|
|
|
|
|
initialState.spotify = Object.assign({}, initialState.spotify, helpers.getStorage('spotify'));
|
|
|
|
|
initialState.lastfm = Object.assign({}, initialState.lastfm, helpers.getStorage('lastfm'));
|
2017-11-03 09:06:41 +13:00
|
|
|
|
2016-11-07 18:09:42 +13:00
|
|
|
console.log('Bootstrapping', initialState)
|
|
|
|
|
|
2016-10-14 22:42:45 +13:00
|
|
|
let store = createStore(
|
2016-10-16 12:37:37 +13:00
|
|
|
reducers,
|
2016-10-17 10:39:11 +13:00
|
|
|
initialState,
|
2017-11-03 09:06:41 +13:00
|
|
|
applyMiddleware(thunk, localstorageMiddleware, coreMiddleware, uiMiddleware, mopidyMiddleware, pusherMiddleware, spotifyMiddleware, lastfmMiddleware )
|
2016-10-14 22:42:45 +13:00
|
|
|
);
|
2016-10-03 16:55:33 +13:00
|
|
|
|
2016-10-03 15:22:15 +13:00
|
|
|
export default store;
|