diff --git a/src/js/components/LastfmLoveButton.js b/src/js/components/LastfmLoveButton.js index 3b47ada3..2ef3447d 100755 --- a/src/js/components/LastfmLoveButton.js +++ b/src/js/components/LastfmLoveButton.js @@ -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(){ diff --git a/src/js/services/lastfm/actions.js b/src/js/services/lastfm/actions.js index d93329a8..36c6bfbf 100755 --- a/src/js/services/lastfm/actions.js +++ b/src/js/services/lastfm/actions.js @@ -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 += '×tamp='+Date.now(); + params += '×tamp='+Math.floor(Date.now() / 1000); sendSignedRequest(dispatch, getState, params) .then(