diff --git a/src/js/App.js b/src/js/App.js index 8d34f390..b0b1efe6 100755 --- a/src/js/App.js +++ b/src/js/App.js @@ -38,9 +38,10 @@ class App extends React.Component{ } componentDidMount(){ - this.props.pusherActions.connect(); - this.props.mopidyActions.connect(); - this.props.spotifyActions.connect(); + this.props.pusherActions.connect() + this.props.mopidyActions.connect() + this.props.spotifyActions.connect() + this.props.uiActions.getBroadcasts() if (this.props.spotify_authorized){ @@ -199,8 +200,8 @@ class App extends React.Component{ + processes={this.props.processes} + broadcasts={this.props.broadcasts} /> {this.props.debug_info ? : null} ); @@ -215,6 +216,7 @@ class App extends React.Component{ const mapStateToProps = (state, ownProps) => { return { + broadcasts: (state.ui.broadcasts ? state.ui.broadcasts : []), volume: (state.mopidy.volume ? state.mopidy.volume : false), notifications: (state.ui.notifications ? state.ui.notifications : []), processes: (state.ui.processes ? state.ui.processes : {}), diff --git a/src/js/services/ui/actions.js b/src/js/services/ui/actions.js index 4170aee0..927820fd 100755 --- a/src/js/services/ui/actions.js +++ b/src/js/services/ui/actions.js @@ -1,6 +1,26 @@ import * as helpers from '../../helpers' +export function getBroadcasts(){ + return (dispatch, getState) => { + var config = { + method: 'GET', + url: 'https://gist.githubusercontent.com/jaedb/b677dccf80daf3ccb2ef12e96e495677/raw' + } + $.ajax(config).then( + response => { + dispatch({ + type: 'BROADCASTS_LOADED', + broadcasts: JSON.parse(response) + }) + }, + (xhr, status, error) => { + console.error('Could not fetch broadcasts from GitHub') + } + ) + } +} + export function showContextMenu(data){ data.position_x = data.e.clientX data.position_y = data.e.clientY diff --git a/src/js/services/ui/reducer.js b/src/js/services/ui/reducer.js index 28f9804d..28a22d1f 100755 --- a/src/js/services/ui/reducer.js +++ b/src/js/services/ui/reducer.js @@ -4,6 +4,9 @@ import * as helpers from '../../helpers' export default function reducer(ui = {}, action){ switch (action.type) { + case 'BROADCASTS_LOADED': + return Object.assign({}, ui, {broadcasts: action.broadcasts}); + case 'LAZY_LOADING': return Object.assign({}, ui, { lazy_loading: action.start });