import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { bindActionCreators } from 'redux'
import Thumbnail from './Thumbnail'
import Icon from './Icon'
import URILink from './URILink'
import SpotifyAuthenticationFrame from '../components/Fields/SpotifyAuthenticationFrame'
import LastfmAuthenticationFrame from '../components/Fields/LastfmAuthenticationFrame'
import Snapcast from '../components/Snapcast'
import * as uiActions from '../services/ui/actions'
import * as coreActions from '../services/core/actions'
import * as mopidyActions from '../services/mopidy/actions'
import * as pusherActions from '../services/pusher/actions'
import * as spotifyActions from '../services/spotify/actions'
import * as lastfmActions from '../services/lastfm/actions'
class Services extends React.Component{
constructor(props){
super(props);
this.state = {
country: this.props.spotify.country,
locale: this.props.spotify.locale,
input_in_focus: null
}
}
componentDidMount(){
if (this.props.lastfm.session && this.props.core.users["lastfm:user:"+this.props.lastfm.session.name] === undefined){
this.props.lastfmActions.getMe();
}
}
componentWillReceiveProps(newProps){
var changed = false
var state = this.state
if (newProps.spotify.country != this.state.country && this.state.input_in_focus != 'country'){
state.country = newProps.spotify.country
changed = true
}
if (newProps.spotify.locale != this.state.locale && this.state.input_in_focus != 'locale'){
state.locale = newProps.spotify.locale
changed = true
}
if (changed){
this.setState(state)
}
}
handleBlur(name, value){
this.setState({input_in_focus: null})
var data = {}
data[name] = value
this.props.coreActions.set(data)
}
renderSpotify(){
var share_authorization_button = null;
if (this.props.spotify.authorization){
share_authorization_button = (
Share authorization
);
}
var user_object = this.props.spotify.me;
if (user_object){
var user = (
Mopidy-Spotify extension is not running - you will not be able to play any Spotify tracks