Skip to content

Commit

Permalink
Reject if playlist empty
Browse files Browse the repository at this point in the history
  • Loading branch information
toresbe committed Aug 8, 2023
1 parent 0b55061 commit efeaab3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/scheduling/Timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Timeline {
item: ScheduleItem,
fireAt: Date,
eventLabel: string,
cb: (firedAt: Date, ...rest: any[]) => Promise<void>,
cb: (firedAt: Date, ...rest: any[]) => Promise<void>
) => {
const invokeCallback = async (firedAt: Date, ...rest: any[]) => {
log.info(`Firing ${eventLabel} at ${compactTimestamp(item)}`);
Expand All @@ -51,13 +51,13 @@ export class Timeline {
if (!job?.cancel) {
log.warn(
`Job ${index + 1}/${this.events.length} ` +
`(${job?.name}) has no cancel method`,
`(${job?.name}) has no cancel method`
);
return;
}

log.info(
`Cancelling job ${index + 1}/${this.events.length} (${job?.name})`,
`Cancelling job ${index + 1}/${this.events.length} (${job?.name})`
);

job.cancel();
Expand All @@ -82,12 +82,13 @@ export class Timeline {
// Run until the last job is finished
run = () => {
log.info("Running timeline");
return new Promise<void>((resolve) => {

return new Promise<void>((resolve, reject) => {
const lastJob = this.events[this.events.length - 1];

if (!lastJob) {
log.info("No jobs in timeline");
resolve();
reject();
return;
}

Expand Down

0 comments on commit efeaab3

Please sign in to comment.