Skip to content

Commit

Permalink
fix: token ref in getOAuthToken callback
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-spinelli committed Jul 14, 2023
1 parent d65b6d7 commit 12239a3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/spotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class SpotifyPlayer {
name,
volume,
getOAuthToken: (cb: SpotifyOAuthCallback) => {
cb(token);
cb(this._token);
},
}) as SpotifyWebPlaybackPlayer;

Expand All @@ -161,7 +161,7 @@ export class SpotifyPlayer {
return Promise.resolve(false)
}
const player = this._player
return new Promise( resolve => {
return new Promise(resolve => {
player.activateElement().then(() => {
resolve(true)
}).catch(() => {
Expand Down Expand Up @@ -228,7 +228,7 @@ export class SpotifyPlayer {
});

player.connect()
//.then((ret: boolean) => resolve(ret));
//.then((ret: boolean) => resolve(ret));
});
}

Expand Down Expand Up @@ -283,7 +283,7 @@ export class SpotifyPlayer {
uris: items,
offset: { position: offset }
});
} else if (items) {
} else if (items) {
const isArtist = items.indexOf('artist') >= 0;
const isTrack = items.indexOf('track') >= 0;
let position;
Expand All @@ -294,7 +294,7 @@ export class SpotifyPlayer {

if (isTrack) {
body = JSON.stringify({
uris: [ items ],
uris: [items],
offset: position
});
} else {
Expand Down Expand Up @@ -454,13 +454,13 @@ export class SpotifyPlayer {
* Get a list of playlists owned by the current user.
*/
async getUsersPlaylists(): Promise<SpotifyPlaylist[]> {
let [ playlists, favorites ] = await Promise.all([
let [playlists, favorites] = await Promise.all([
this.getPlaylists(),
this.getFavorites()
]);

// Set "Your Music" first.
playlists = [ favorites, ...playlists ];
playlists = [favorites, ...playlists];

playlists = playlists.map((item: any) => ({
name: item.name,
Expand Down

0 comments on commit 12239a3

Please sign in to comment.