use-listen-along
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -5,4 +5,2 @@ 'use strict'; | ||
var react = require('react'); | ||
/** | ||
@@ -14,3 +12,2 @@ * use-listen-along | ||
*/ | ||
function useListenAlong(snowflake, auth, disconnect) { | ||
@@ -62,15 +59,9 @@ var track; | ||
react.useEffect(function () { | ||
var timer = setInterval(function () { | ||
if (!disconnect) { | ||
fetch("https://api.lanyard.rest/v1/users/" + snowflake).then(function (r) { | ||
return r.json(); | ||
}).then(parseResponse).then(setResponse); | ||
} | ||
}, 1000); // clearing interval | ||
return function () { | ||
return clearInterval(timer); | ||
}; | ||
}); | ||
setInterval(function () { | ||
if (!disconnect) { | ||
fetch("https://api.lanyard.rest/v1/users/" + snowflake).then(function (r) { | ||
return r.json(); | ||
}).then(parseResponse).then(setResponse); | ||
} | ||
}, 1000); | ||
return { | ||
@@ -77,0 +68,0 @@ connected: connected, |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");exports.useListenAlong=function(e,r,n){var s,a=!1,o=null,u=function(t){var e,r;return{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 t.error.message;t.track!==s&&t.np&&!n&&fetch("https://api.spotify.com/v1/me/player/play",{method:"PUT",headers:{Authorization:"Bearer "+r,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uris:["spotify:track:"+s]})}).then((function(t){a=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 t})),s=t.track};return t.useEffect((function(){var t=setInterval((function(){n||fetch("https://api.lanyard.rest/v1/users/"+e).then((function(t){return t.json()})).then(u).then(i)}),1e3);return function(){return clearInterval(t)}})),{connected:a,error:o}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useListenAlong=function(t,e,s){var r,n=!1,a=null,o=function(t){var e,s;return{error:{status:!t.success,message:t.error.message},np:t.data.listening_to_spotify,track:null==(e=t.data)||null==(s=e.spotify)?void 0:s.track_id}},i=function(t){if(t.error.status)throw t.error.message;t.track!==r&&t.np&&!s&&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:"+r]})}).then((function(t){n=204==t.status,a=204!==t.status?403==t.status?"User must have a premium account.":t.statusText:null})).catch((function(t){if(t.status)throw t})),r=t.track};return setInterval((function(){s||fetch("https://api.lanyard.rest/v1/users/"+t).then((function(t){return t.json()})).then(o).then(i)}),1e3),{connected:n,error:a}}; | ||
//# sourceMappingURL=use-listen-along.cjs.production.min.js.map |
@@ -1,3 +0,1 @@ | ||
import { useEffect } from 'react'; | ||
/** | ||
@@ -9,3 +7,2 @@ * use-listen-along | ||
*/ | ||
function useListenAlong(snowflake, auth, disconnect) { | ||
@@ -57,15 +54,9 @@ var track; | ||
useEffect(function () { | ||
var timer = setInterval(function () { | ||
if (!disconnect) { | ||
fetch("https://api.lanyard.rest/v1/users/" + snowflake).then(function (r) { | ||
return r.json(); | ||
}).then(parseResponse).then(setResponse); | ||
} | ||
}, 1000); // clearing interval | ||
return function () { | ||
return clearInterval(timer); | ||
}; | ||
}); | ||
setInterval(function () { | ||
if (!disconnect) { | ||
fetch("https://api.lanyard.rest/v1/users/" + snowflake).then(function (r) { | ||
return r.json(); | ||
}).then(parseResponse).then(setResponse); | ||
} | ||
}, 1000); | ||
return { | ||
@@ -72,0 +63,0 @@ connected: connected, |
{ | ||
"name": "use-listen-along", | ||
"description": "A react hook to listen alongside others on spotify.", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"license": "MIT", | ||
@@ -36,3 +36,2 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/react": "^17.0.18", | ||
"husky": "^4.3.0", | ||
@@ -47,6 +46,3 @@ "tsdx": "^0.14.1", | ||
"hook" | ||
], | ||
"dependencies": { | ||
"react": "^17.0.2" | ||
} | ||
] | ||
} |
import { LanyardResponse } from './types'; | ||
import { useEffect } from 'react'; | ||
@@ -68,16 +67,12 @@ /** | ||
useEffect(() => { | ||
const timer = setInterval(() => { | ||
if (!disconnect) { | ||
fetch(`https://api.lanyard.rest/v1/users/${snowflake}`) | ||
.then((r) => r.json()) | ||
.then(parseResponse) | ||
.then(setResponse); | ||
} | ||
}, 1000); | ||
// clearing interval | ||
return () => clearInterval(timer); | ||
}); | ||
setInterval(() => { | ||
if (!disconnect) { | ||
fetch(`https://api.lanyard.rest/v1/users/${snowflake}`) | ||
.then((r) => r.json()) | ||
.then(parseResponse) | ||
.then(setResponse); | ||
} | ||
}, 1000); | ||
return { connected, error }; | ||
} |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
0
4
1
24083
353
- Removedreact@^17.0.2
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedreact@17.0.2(transitive)