Skip to content

Commit

Permalink
only get real active Fissas
Browse files Browse the repository at this point in the history
  • Loading branch information
xiduzo committed Jan 4, 2024
1 parent fc6cd39 commit 5e05db3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
24 changes: 18 additions & 6 deletions apps/expo/app/host/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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 (
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/service/FissaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
};
Expand Down Expand Up @@ -226,6 +226,7 @@ export class FissaService extends ServiceWithContext {
{ trackId, durationMs }: Pick<Track, "trackId" | "durationMs">,
accessToken: string,
) => {
console.log({ accessToken });
const promise = this.spotifyService.playTrack(accessToken, trackId);

await this.db.fissa.update({
Expand Down

1 comment on commit 5e05db3

@vercel
Copy link

@vercel vercel bot commented on 5e05db3 Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.