diff --git a/apps/expo/app/host/index.tsx b/apps/expo/app/host/index.tsx index 5674551..0d81c90 100644 --- a/apps/expo/app/host/index.tsx +++ b/apps/expo/app/host/index.tsx @@ -7,6 +7,8 @@ import { Button, ButtonGroup, PageTemplate, Typography } from "../../src/compone import { useCreateFissa } from "../../src/hooks"; import { toast } from "../../src/utils"; +const MAX_SEED_TRACKS = 5; + const Host = () => { const spotify = useSpotify(); @@ -22,13 +24,23 @@ const Host = () => { message: "An explorer I see, making a fissa just for you", duration: 60 * 1000, }); - const { items } = await spotify.getMyTopTracks(); - const { tracks } = await spotify.getRecommendations({ - limit: 5, - seed_tracks: items.map(({ id }) => id).sort(randomSort), - }); + try { + const { items } = await spotify.getMyTopTracks(); + const { tracks } = await spotify.getRecommendations({ + limit: 10, + seed_tracks: items + .map(({ id }) => id) + .sort(randomSort) + .slice(0, MAX_SEED_TRACKS), + }); - await mutateAsync(tracks); + await mutateAsync(tracks); + } catch (e) { + console.error(e); + toast.error({ + message: "Woops, something went wrong. Try again later.", + }); + } }, [spotify, mutateAsync]); return ( diff --git a/packages/api/src/service/FissaService.ts b/packages/api/src/service/FissaService.ts index 4d9bee7..3a2d008 100644 --- a/packages/api/src/service/FissaService.ts +++ b/packages/api/src/service/FissaService.ts @@ -25,7 +25,7 @@ export class FissaService extends ServiceWithContext { activeFissas = async () => { return this.db.fissa.findMany({ - where: { currentlyPlaying: { isNot: undefined } }, + where: { currentlyPlayingId: { not: null } }, select: { pin: true, expectedEndTime: true }, }); }; @@ -226,6 +226,7 @@ export class FissaService extends ServiceWithContext { { trackId, durationMs }: Pick, accessToken: string, ) => { + console.log({ accessToken }); const promise = this.spotifyService.playTrack(accessToken, trackId); await this.db.fissa.update({