cody-music
Advanced tools
Comparing version 2.8.9 to 2.9.0
@@ -7,5 +7,7 @@ "use strict"; | ||
const models_1 = require("./models"); | ||
const cache_1 = require("./cache"); | ||
const musicClient = client_1.MusicClient.getInstance(); | ||
const musicPlayerCtr = playerstate_1.MusicPlayerState.getInstance(); | ||
const musicStore = store_1.MusicStore.getInstance(); | ||
const cacheMgr = cache_1.CacheManager.getInstance(); | ||
class SpotifyUser { | ||
@@ -41,3 +43,7 @@ constructor() { | ||
async getUserProfile() { | ||
let spotifyUser = new SpotifyUser(); | ||
let userProfile = cacheMgr.get("user-profile"); | ||
if (userProfile) { | ||
return userProfile; | ||
} | ||
userProfile = new SpotifyUser(); | ||
let api = "/v1/me"; | ||
@@ -53,6 +59,7 @@ let response = await musicClient.spotifyApiGet(api); | ||
if (response && response.status === 200 && response.data) { | ||
spotifyUser = response.data; | ||
musicStore.spotifyUserId = spotifyUser.id; | ||
userProfile = response.data; | ||
cacheMgr.set("user-profile", userProfile, 60 * 10); | ||
musicStore.spotifyUserId = userProfile.id; | ||
} | ||
return spotifyUser; | ||
return userProfile; | ||
} | ||
@@ -59,0 +66,0 @@ async spotifyAuthState() { |
@@ -5,2 +5,3 @@ import { MusicClient } from "./client"; | ||
import { SpotifyAuthState } from "./models"; | ||
import { CacheManager } from "./cache"; | ||
@@ -10,2 +11,3 @@ const musicClient = MusicClient.getInstance(); | ||
const musicStore = MusicStore.getInstance(); | ||
const cacheMgr = CacheManager.getInstance(); | ||
@@ -43,3 +45,7 @@ export class SpotifyUser { | ||
async getUserProfile(): Promise<SpotifyUser> { | ||
let spotifyUser: SpotifyUser = new SpotifyUser(); | ||
let userProfile: SpotifyUser = cacheMgr.get("user-profile"); | ||
if (userProfile) { | ||
return userProfile; | ||
} | ||
userProfile = new SpotifyUser(); | ||
let api = "/v1/me"; | ||
@@ -57,7 +63,8 @@ let response = await musicClient.spotifyApiGet(api); | ||
if (response && response.status === 200 && response.data) { | ||
spotifyUser = response.data; | ||
musicStore.spotifyUserId = spotifyUser.id; | ||
userProfile = response.data; | ||
cacheMgr.set("user-profile", userProfile, 60 * 10); | ||
musicStore.spotifyUserId = userProfile.id; | ||
} | ||
return spotifyUser; | ||
return userProfile; | ||
} | ||
@@ -64,0 +71,0 @@ |
{ | ||
"name": "cody-music", | ||
"version": "2.8.9", | ||
"version": "2.9.0", | ||
"description": "mac osx spotify and itunes music player controller, spotify audio features, itunes and spotify genre, and playlist control", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
557644
13532