Skip to content

Commit

Permalink
Fix Spotify token consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyfran committed Jan 22, 2025
1 parent b7c129d commit e3da573
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dev": "vite",
"build": "yarn workspace @echo/web tsc && vite build --emptyOutDir",
"format": "prettier --check \"packages/**/*.{ts, tsx}\"",
"format:fix": "prettier --write \"packages/**/*.{ts, tsx}\"",
"gen": "yarn plop",
"lint": "yarn workspaces run lint",
"preview": "yarn workspace @echo/web vite preview",
Expand Down Expand Up @@ -45,4 +46,4 @@
"packages/workflows/*",
"packages/workers/*"
]
}
}
5 changes: 4 additions & 1 deletion packages/infrastructure/spotify-player/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
Option,
pipe,
Queue,
Runtime,
Scope,
Stream,
} from "effect";
Expand Down Expand Up @@ -73,12 +74,14 @@ const make = Effect.gen(function* () {

const deferredUntilRegistered = yield* Deferred.make<undefined>();

const runtime = yield* Effect.runtime();

yield* Stream.async<InitCommand>((emit) => {
window.onSpotifyWebPlaybackSDKReady = () => {
const player = new window.Spotify.Player({
name: "Echo",
getOAuthToken: (cb) =>
Effect.runPromise(
Runtime.runPromise(runtime)(
authCache
.get(ApiBasedProviderId.Spotify)
.pipe(Effect.map(Option.getOrElse(() => authInfo))),
Expand Down

0 comments on commit e3da573

Please sign in to comment.