use-listen-along
Advanced tools
Comparing version 1.1.5 to 1.1.7
@@ -17,11 +17,7 @@ 'use strict'; | ||
var parseResponse = function parseResponse(res) { | ||
var _res$data, _res$data$spotify; | ||
var _res$error, _res$data, _res$data$spotify; | ||
console.log({ | ||
status: !res.success, | ||
message: res.error.message | ||
}); | ||
var error = { | ||
status: !res.success, | ||
message: res.error.message | ||
message: res == null ? void 0 : (_res$error = res.error) == null ? void 0 : _res$error.message | ||
}; | ||
@@ -28,0 +24,0 @@ var np = res.data.listening_to_spotify; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useListenAlong=function(t,e,r){var s,n=!1,o=null,a=function(t){var e,r;return console.log({status:!t.success,message:t.error.message}),{error:{status:!t.success,message:t.error.message},np:t.data.listening_to_spotify,track:null==(e=t.data)||null==(r=e.spotify)?void 0:r.track_id}},i=function(t){if(t.error.status)throw new Error(JSON.stringify(t.error));t.track!==s&&t.np&&!r&&fetch("https://api.spotify.com/v1/me/player/play",{method:"PUT",headers:{Authorization:"Bearer "+e,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uris:["spotify:track:"+s]})}).then((function(t){n=204==t.status,o=204!==t.status?403==t.status?"User must have a premium account.":t.statusText:null})).catch((function(t){if(t.status)throw new Error(t)})),s=t.track};return setInterval((function(){r||fetch("https://api.lanyard.rest/v1/users/"+t).then((function(t){return t.json()})).then(a).then(i)}),1e3),{connected:n,error:o}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useListenAlong=function(t,e,r){var n,s=!1,o=null,a=function(t){var e,r,n;return{error:{status:!t.success,message:null==t||null==(e=t.error)?void 0:e.message},np:t.data.listening_to_spotify,track:null==(r=t.data)||null==(n=r.spotify)?void 0:n.track_id}},i=function(t){if(t.error.status)throw new Error(JSON.stringify(t.error));t.track!==n&&t.np&&!r&&fetch("https://api.spotify.com/v1/me/player/play",{method:"PUT",headers:{Authorization:"Bearer "+e,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uris:["spotify:track:"+n]})}).then((function(t){s=204==t.status,o=204!==t.status?403==t.status?"User must have a premium account.":t.statusText:null})).catch((function(t){if(t.status)throw new Error(t)})),n=t.track};return setInterval((function(){r||fetch("https://api.lanyard.rest/v1/users/"+t).then((function(t){return t.json()})).then(a).then(i)}),1e3),{connected:s,error:o}}; | ||
//# sourceMappingURL=use-listen-along.cjs.production.min.js.map |
@@ -13,11 +13,7 @@ /** | ||
var parseResponse = function parseResponse(res) { | ||
var _res$data, _res$data$spotify; | ||
var _res$error, _res$data, _res$data$spotify; | ||
console.log({ | ||
status: !res.success, | ||
message: res.error.message | ||
}); | ||
var error = { | ||
status: !res.success, | ||
message: res.error.message | ||
message: res == null ? void 0 : (_res$error = res.error) == null ? void 0 : _res$error.message | ||
}; | ||
@@ -24,0 +20,0 @@ var np = res.data.listening_to_spotify; |
{ | ||
"name": "use-listen-along", | ||
"description": "A react hook to listen alongside others on spotify.", | ||
"version": "1.1.5", | ||
"version": "1.1.7", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -20,4 +20,3 @@ import { LanyardResponse } from './types'; | ||
const parseResponse = (res: LanyardResponse) => { | ||
console.log({ status: !res.success, message: res.error.message }); | ||
const error = { status: !res.success, message: res.error.message }; | ||
const error = { status: !res.success, message: res?.error?.message }; | ||
const np = res.data.listening_to_spotify; | ||
@@ -24,0 +23,0 @@ const track = res.data?.spotify?.track_id; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24721
353