Skip to content

Commit

Permalink
make it easier on the eyes
Browse files Browse the repository at this point in the history
  • Loading branch information
xiduzo committed Jan 28, 2024
1 parent 42eba4f commit 4867df8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/api/src/service/FissaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class FissaService extends ServiceWithContext {
await this.stopFissa(pin, fissa.by.accounts[0]?.access_token);
};

playNextTrack = async (pin: string, instantPlay = false) => {
playNextTrack = async (pin: string, forceToPlay = false) => {
const { by, tracks, currentlyPlayingId, expectedEndTime } =
await this.getFissaDetailedInformation(pin);

Expand All @@ -144,9 +144,10 @@ export class FissaService extends ServiceWithContext {
if (!access_token) throw new NotAbleToAccessSpotify();

try {
const isPlaying = await this.spotifyService.isStillPlaying(access_token);

if (!instantPlay && (!currentlyPlayingId || !isPlaying)) throw new ForceStopFissa();
if (!forceToPlay) {
const isPlaying = await this.spotifyService.isStillPlaying(access_token);
if (!isPlaying || !currentlyPlayingId) throw new ForceStopFissa();
}

const nextTracks = this.getNextTracks(tracks, currentlyPlayingId);
if (!nextTracks[0]) throw new NoNextTrack();
Expand All @@ -155,7 +156,7 @@ export class FissaService extends ServiceWithContext {
await this.addRecommendedTracks(pin, biasSort(tracks), access_token);
}

const timeToPlay = instantPlay ? new Date() : expectedEndTime;
const timeToPlay = forceToPlay ? new Date() : expectedEndTime;
await sleep(differenceInMilliseconds(timeToPlay, new Date())); // Wait for track to end

await this.trackPlayed({ pin, currentlyPlayingId });
Expand Down

1 comment on commit 4867df8

@vercel
Copy link

@vercel vercel bot commented on 4867df8 Jan 28, 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.