Removing spotify connected status - we connect on demand instead

This commit is contained in:
James Barnsley
2018-04-01 11:52:42 +12:00
parent 9ecddcc1b5
commit 407a2d3a10
12 changed files with 22 additions and 129 deletions

View File

@ -1913,7 +1913,6 @@ function refreshToken(dispatch, getState) {
});
resolve(response);
}, function (xhr, status, error) {
dispatch({ type: 'SPOTIFY_DISCONNECTED' });
reject({
config: config,
xhr: xhr,
@ -1932,7 +1931,6 @@ function refreshToken(dispatch, getState) {
$.ajax(config).then(function (response, status, xhr) {
if (response.error) {
dispatch({ type: 'SPOTIFY_DISCONNECTED' });
reject({
config: config,
xhr: xhr,
@ -1951,7 +1949,6 @@ function refreshToken(dispatch, getState) {
resolve(token);
}
}, function (xhr, status, error) {
dispatch({ type: 'SPOTIFY_DISCONNECTED' });
reject({
config: config,
xhr: xhr,
@ -2028,10 +2025,8 @@ function getMe() {
type: 'SPOTIFY_ME_LOADED',
data: response
});
dispatch({ type: 'SPOTIFY_CONNECTED' });
}, function (error) {
dispatch(coreActions.handleException('Could not load your profile', error));
dispatch({ type: 'SPOTIFY_DISCONNECTED' });
});
};
}
@ -4369,7 +4364,6 @@ exports.getBroadcasts = getBroadcasts;
exports.startSearch = startSearch;
exports.handleException = handleException;
exports.debugResponse = debugResponse;
exports.startServices = startServices;
exports.set = set;
exports.reorderPlaylistTracks = reorderPlaylistTracks;
exports.savePlaylist = savePlaylist;
@ -4449,12 +4443,6 @@ function debugResponse(response) {
};
}
function startServices() {
return {
type: 'CORE_START_SERVICES'
};
}
function set(data) {
return {
type: 'CORE_SET',
@ -48754,15 +48742,11 @@ var initialState = {
config: {}
},
lastfm: {
connected: false,
me: false,
authorization_url: 'https://jamesbarnsley.co.nz/auth_lastfm.php'
},
genius: {
connected: false
},
genius: {},
spotify: {
connected: false,
me: false,
autocomplete_results: {},
authorization_url: 'https://jamesbarnsley.co.nz/auth_spotify.php'
@ -49615,16 +49599,6 @@ function reducer() {
switch (action.type) {
case 'SPOTIFY_CONNECT':
case 'SPOTIFY_CONNECTING':
return Object.assign({}, spotify, { connected: false, connecting: true });
case 'SPOTIFY_CONNECTED':
return Object.assign({}, spotify, { connected: true, connecting: false });
case 'SPOTIFY_DISCONNECTED':
return Object.assign({}, spotify, { connected: false, connecting: false });
case 'SPOTIFY_SET':
return Object.assign({}, spotify, action.data);
@ -49672,7 +49646,6 @@ function reducer() {
case 'SPOTIFY_TOKEN_REFRESHED':
return Object.assign({}, spotify, {
connected: true,
refreshing_token: false,
access_token: action.data.access_token,
token_expiry: action.data.token_expiry
@ -49684,9 +49657,6 @@ function reducer() {
token_expiry: action.spotify_token.token_expiry
});
case 'SPOTIFY_DISCONNECTED':
return Object.assign({}, spotify, { connected: false, connecting: false });
case 'SPOTIFY_ME_LOADED':
return Object.assign({}, spotify, { me: action.data });
@ -50060,13 +50030,6 @@ var CoreMiddleware = function () {
console.error(message, description, data);
break;
case 'CORE_START_SERVICES':
store.dispatch(mopidyActions.connect());
store.dispatch(pusherActions.connect());
next(action);
break;
case 'PLAY_PLAYLIST':
_reactGa2.default.event({ category: 'Playlist', action: 'Play', label: action.uri });
next(action);
@ -57043,7 +57006,8 @@ var App = function (_React$Component) {
var _this2 = this;
// Fire up our services
this.props.coreActions.startServices();
this.props.mopidyActions.connect();
this.props.pusherActions.connect();
this.props.coreActions.getBroadcasts();
// when we navigate to a new route
@ -57557,7 +57521,7 @@ var Sidebar = function (_React$Component) {
'Test mode active'
)
) : null,
!this.props.mopidy_connected || !this.props.spotify_connected && this.props.spotify_enabled || !this.props.pusher_connected ? _react2.default.createElement(
!this.props.mopidy_connected || !this.props.pusher_connected ? _react2.default.createElement(
'span',
{ className: 'status has-tooltip right-tooltip' },
_react2.default.createElement(_reactFontawesome2.default, { name: 'exclamation-triangle', className: 'red-text' }),
@ -57575,11 +57539,6 @@ var Sidebar = function (_React$Component) {
null,
'Pusher not connected',
_react2.default.createElement('br', null)
) : null,
!this.props.spotify_connected && this.props.spotify_enabled ? _react2.default.createElement(
'span',
null,
'Spotify not connected'
) : null
)
) : null
@ -74506,7 +74465,7 @@ var LibraryArtists = function (_React$Component) {
this.props.mopidyActions.getLibraryArtists();
}
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_artists_status != 'finished' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')) {
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_artists_status != 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')) {
this.props.spotifyActions.getLibraryArtists();
}
}
@ -74526,12 +74485,7 @@ var LibraryArtists = function (_React$Component) {
}
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && newProps.spotify_connected && (newProps.source == 'all' || newProps.source == 'spotify')) {
// We've just connected
if (!this.props.spotify_connected) {
this.props.spotifyActions.getLibraryArtists();
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')) {
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_artists_status != 'finished') {
@ -74871,7 +74825,7 @@ var LibraryAlbums = function (_React$Component) {
this.props.mopidyActions.getLibraryAlbums();
}
if (this.props.spotify_library_albums_status != 'finished' && this.props.spotify_library_albums_status != 'started' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')) {
if (this.props.spotify_library_albums_status != 'finished' && this.props.spotify_library_albums_status != 'started' && (this.props.source == 'all' || this.props.source == 'spotify')) {
this.props.spotifyActions.getLibraryAlbums();
}
}
@ -74891,12 +74845,7 @@ var LibraryAlbums = function (_React$Component) {
}
}
if (newProps.spotify_connected && newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')) {
// We've just connected
if (!this.props.spotify_connected) {
this.props.spotifyActions.getLibraryAlbums();
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')) {
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_albums_status != 'finished' && newProps.spotify_library_albums_status != 'started') {
@ -75430,7 +75379,7 @@ var LibraryPlaylists = function (_React$Component) {
this.props.mopidyActions.getLibraryPlaylists();
}
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_playlists_status !== 'finished' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')) {
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_playlists_status !== 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')) {
this.props.spotifyActions.getLibraryPlaylists();
}
}
@ -75450,12 +75399,7 @@ var LibraryPlaylists = function (_React$Component) {
}
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && newProps.spotify_connected && (newProps.source == 'all' || newProps.source == 'spotify')) {
// We've just connected
if (!this.props.spotify_connected) {
this.props.spotifyActions.getLibraryPlaylists();
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')) {
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_playlists_status !== 'finished') {

File diff suppressed because one or more lines are too long

View File

@ -48,8 +48,9 @@ class App extends React.Component{
componentDidMount(){
// Fire up our services
this.props.coreActions.startServices()
this.props.coreActions.getBroadcasts()
this.props.mopidyActions.connect();
this.props.pusherActions.connect();
this.props.coreActions.getBroadcasts();
// when we navigate to a new route
hashHistory.listen(location => {

6
src/js/bootstrap.js vendored
View File

@ -75,15 +75,11 @@ var initialState = {
config: {}
},
lastfm: {
connected: false,
me: false,
authorization_url: 'https://jamesbarnsley.co.nz/auth_lastfm.php'
},
genius: {
connected: false
},
genius: {},
spotify: {
connected: false,
me: false,
autocomplete_results: {},
authorization_url: 'https://jamesbarnsley.co.nz/auth_spotify.php'

View File

@ -92,7 +92,7 @@ class Sidebar extends React.Component{
<Icon name="cog" />
Settings
{this.props.test_mode ? <span className="status has-tooltip right-tooltip"><FontAwesome name="info-circle" className="orange-text" /><span className="tooltip">Test mode active</span></span>: null}
{!this.props.mopidy_connected || (!this.props.spotify_connected && this.props.spotify_enabled) || !this.props.pusher_connected ? <span className="status has-tooltip right-tooltip"><FontAwesome name="exclamation-triangle" className="red-text" /><span className="tooltip">{!this.props.mopidy_connected ? <span>Mopidy not connected<br /></span> : null}{!this.props.pusher_connected ? <span>Pusher not connected<br /></span> : null}{!this.props.spotify_connected && this.props.spotify_enabled ? <span>Spotify not connected</span> : null}</span></span> : null}
{!this.props.mopidy_connected || !this.props.pusher_connected ? <span className="status has-tooltip right-tooltip"><FontAwesome name="exclamation-triangle" className="red-text" /><span className="tooltip">{!this.props.mopidy_connected ? <span>Mopidy not connected<br /></span> : null}{!this.props.pusher_connected ? <span>Pusher not connected<br /></span> : null}</span></span> : null}
</Link>
</section>

View File

@ -59,13 +59,6 @@ export function debugResponse(response){
}
}
export function startServices(){
return {
type: 'CORE_START_SERVICES'
}
}
export function set(data){
return {
type: 'CORE_SET',

View File

@ -91,13 +91,6 @@ const CoreMiddleware = (function(){
console.error(message, description, data);
break;
case 'CORE_START_SERVICES':
store.dispatch(mopidyActions.connect());
store.dispatch(pusherActions.connect());
next(action)
break
case 'PLAY_PLAYLIST':
ReactGA.event({ category: 'Playlist', action: 'Play', label: action.uri })
next(action)

View File

@ -141,7 +141,6 @@ function refreshToken(dispatch, getState){
resolve(response)
},
(xhr, status, error) => {
dispatch({ type: 'SPOTIFY_DISCONNECTED' })
reject({
config: config,
xhr: xhr,
@ -164,7 +163,6 @@ function refreshToken(dispatch, getState){
.then(
(response, status, xhr) => {
if (response.error){
dispatch({ type: 'SPOTIFY_DISCONNECTED' })
reject({
config: config,
xhr: xhr,
@ -186,7 +184,6 @@ function refreshToken(dispatch, getState){
},
(xhr, status, error) => {
dispatch({ type: 'SPOTIFY_DISCONNECTED' })
reject({
config: config,
xhr: xhr,
@ -269,14 +266,12 @@ export function getMe(){
type: 'SPOTIFY_ME_LOADED',
data: response
});
dispatch({ type: 'SPOTIFY_CONNECTED' });
},
error => {
dispatch(coreActions.handleException(
'Could not load your profile',
error
));
dispatch({ type: 'SPOTIFY_DISCONNECTED' });
}
);
}

View File

@ -4,16 +4,6 @@ import * as helpers from '../../helpers'
export default function reducer(spotify = {}, action){
switch (action.type){
case 'SPOTIFY_CONNECT':
case 'SPOTIFY_CONNECTING':
return Object.assign({}, spotify, { connected: false, connecting: true })
case 'SPOTIFY_CONNECTED':
return Object.assign({}, spotify, { connected: true, connecting: false })
case 'SPOTIFY_DISCONNECTED':
return Object.assign({}, spotify, { connected: false, connecting: false })
case 'SPOTIFY_SET':
return Object.assign({},spotify,action.data)
@ -61,7 +51,6 @@ export default function reducer(spotify = {}, action){
case 'SPOTIFY_TOKEN_REFRESHED':
return Object.assign({}, spotify, {
connected: true,
refreshing_token: false,
access_token: action.data.access_token,
token_expiry: action.data.token_expiry
@ -73,9 +62,6 @@ export default function reducer(spotify = {}, action){
token_expiry: action.spotify_token.token_expiry
});
case 'SPOTIFY_DISCONNECTED':
return Object.assign({}, spotify, { connected: false, connecting: false })
case 'SPOTIFY_ME_LOADED':
return Object.assign({}, spotify, { me: action.data })

View File

@ -37,7 +37,7 @@ class LibraryAlbums extends React.Component{
this.props.mopidyActions.getLibraryAlbums()
}
if (this.props.spotify_library_albums_status != 'finished' && this.props.spotify_library_albums_status != 'started' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
if (this.props.spotify_library_albums_status != 'finished' && this.props.spotify_library_albums_status != 'started' && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryAlbums()
}
}
@ -56,12 +56,7 @@ class LibraryAlbums extends React.Component{
}
}
if (newProps.spotify_connected && newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')){
// We've just connected
if (!this.props.spotify_connected){
this.props.spotifyActions.getLibraryAlbums();
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')){
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_albums_status != 'finished' && newProps.spotify_library_albums_status != 'started'){

View File

@ -33,7 +33,7 @@ class LibraryArtists extends React.Component{
this.props.mopidyActions.getLibraryArtists();
}
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_artists_status != 'finished' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_artists_status != 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryArtists();
}
}
@ -52,12 +52,7 @@ class LibraryArtists extends React.Component{
}
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && newProps.spotify_connected && (newProps.source == 'all' || newProps.source == 'spotify')){
// We've just connected
if (!this.props.spotify_connected){
this.props.spotifyActions.getLibraryArtists();
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')){
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_artists_status != 'finished'){

View File

@ -35,7 +35,7 @@ class LibraryPlaylists extends React.Component{
this.props.mopidyActions.getLibraryPlaylists()
}
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_playlists_status !== 'finished' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_playlists_status !== 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryPlaylists()
}
}
@ -54,12 +54,7 @@ class LibraryPlaylists extends React.Component{
}
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && newProps.spotify_connected && (newProps.source == 'all' || newProps.source == 'spotify')){
// We've just connected
if (!this.props.spotify_connected){
this.props.spotifyActions.getLibraryPlaylists()
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')){
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_playlists_status !== 'finished'){