cody-music
Advanced tools
Comparing version 2.6.10 to 2.6.11
@@ -158,3 +158,3 @@ "use strict"; | ||
api = this.addQueryStringToApi(api, qsOptions); | ||
console.log(`GET API: ${api}`); | ||
// console.log(`GET API: ${api}`); | ||
spotifyClient.defaults.headers.common["Authorization"] = `Bearer ${musicStore.spotifyAccessToken}`; | ||
@@ -161,0 +161,0 @@ return spotifyClient |
@@ -7,5 +7,7 @@ "use strict"; | ||
const client_1 = require("./client"); | ||
const cache_1 = require("./cache"); | ||
const models_1 = require("./models"); | ||
const musicStore = store_1.MusicStore.getInstance(); | ||
const musicClient = client_1.MusicClient.getInstance(); | ||
const cacheUtil = cache_1.CacheUtil.getInstance(); | ||
const musicUtil = new util_1.MusicUtil(); | ||
@@ -66,3 +68,7 @@ class MusicPlayerState { | ||
async getSpotifyDevices() { | ||
let devices = []; | ||
let devices = cacheUtil.getItem("devices"); | ||
if (devices) { | ||
// return the value from cache | ||
return devices; | ||
} | ||
const api = "/v1/me/player/devices"; | ||
@@ -80,2 +86,4 @@ let response = await musicClient.spotifyApiGet(api); | ||
} | ||
cacheUtil.setItem("devices", devices, 60 /* second */); | ||
// cache these results for a minute | ||
return devices; | ||
@@ -82,0 +90,0 @@ } |
@@ -178,3 +178,3 @@ import axios, { AxiosInstance } from "axios"; | ||
console.log(`GET API: ${api}`); | ||
// console.log(`GET API: ${api}`); | ||
@@ -181,0 +181,0 @@ spotifyClient.defaults.headers.common["Authorization"] = `Bearer ${ |
@@ -5,2 +5,3 @@ import { MusicUtil } from "./util"; | ||
import { MusicClient } from "./client"; | ||
import { CacheUtil } from "./cache"; | ||
import { | ||
@@ -17,2 +18,3 @@ PlayerDevice, | ||
const musicClient = MusicClient.getInstance(); | ||
const cacheUtil = CacheUtil.getInstance(); | ||
const musicUtil = new MusicUtil(); | ||
@@ -78,3 +80,7 @@ | ||
async getSpotifyDevices(): Promise<PlayerDevice[]> { | ||
let devices: PlayerDevice[] = []; | ||
let devices: PlayerDevice[] = cacheUtil.getItem("devices"); | ||
if (devices) { | ||
// return the value from cache | ||
return devices; | ||
} | ||
@@ -94,2 +100,5 @@ const api = "/v1/me/player/devices"; | ||
} | ||
cacheUtil.setItem("devices", devices, 60 /* second */); | ||
// cache these results for a minute | ||
return devices; | ||
@@ -96,0 +105,0 @@ } |
{ | ||
"name": "cody-music", | ||
"version": "2.6.10", | ||
"version": "2.6.11", | ||
"description": "mac osx spotify and itunes music player controller, spotify audio features, itunes and spotify genre, and playlist control", | ||
@@ -20,3 +20,4 @@ "main": "dist/index.js", | ||
"nonplaylist-test": "npm run build && mocha -r ts-node/register test/nonplaylists/test.ts --reporter spec --timeout 20000 --exit", | ||
"search-test": "npm run build && mocha -r ts-node/register test/search/test.ts --reporter spec --timeout 20000 --exit" | ||
"search-test": "npm run build && mocha -r ts-node/register test/search/test.ts --reporter spec --timeout 20000 --exit", | ||
"caching-test": "npm run build && mocha -r ts-node/register test/caching/test.ts --reporter spec --timeout 20000 --exit" | ||
}, | ||
@@ -23,0 +24,0 @@ "repository": { |
420314
117
10298