API issues sorted, can now scrobble and love tracks

This commit is contained in:
James Barnsley
2017-11-07 08:28:57 +13:00
parent 2d3d4c351a
commit 7739a16504
2 changed files with 7 additions and 14 deletions

View File

@ -16,11 +16,11 @@ class FollowButton extends React.Component{
}
remove(){
this.props.lastfmActions.loveTrack(this.props.uri, this.props.artist, this.props.track);
this.props.lastfmActions.unloveTrack(this.props.uri, this.props.artist, this.props.track);
}
add(){
this.props.lastfmActions.unloveTrack(this.props.uri, this.props.artist, this.props.track);
this.props.lastfmActions.loveTrack(this.props.uri, this.props.artist, this.props.track);
}
render(){

View File

@ -95,20 +95,13 @@ const sendSignedRequest = (dispatch, getState, params) => {
url: getState().lastfm.authorization_url+"?action=sign_request&"+params
}
// Get our server proxy to sign our request
$.ajax(config).then(
response => {
var signed_params = "";
for (var key in response){
if (response.hasOwnProperty(key)){
if (signed_params != ""){
signed_params += "&"
}
signed_params += key+'='+response[key];
}
}
dispatch(uiActions.stopLoading(loader_key));
dispatch(uiActions.stopLoading(loader_key))
sendRequest(dispatch, getState, signed_params, true)
// Now we have signed params, we can make the actual request
sendRequest(dispatch, getState, response.params, true)
.then(
response => {
resolve(response);
@ -338,7 +331,7 @@ export function scrobble(track){
var params = 'method=track.scrobble';
params += '&track='+track_name+'&artist='+artist_name;
params += '&timestamp='+Date.now();
params += '&timestamp='+Math.floor(Date.now() / 1000);
sendSignedRequest(dispatch, getState, params)
.then(