Skip to content

Commit

Permalink
allow to stop random randomActivateAudio
Browse files Browse the repository at this point in the history
  • Loading branch information
vpalmisano committed Mar 29, 2024
1 parent 4ecbccf commit b54b8ec
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,18 @@ export async function randomActivateAudio(
} catch (err) {
log.error(`randomActivateAudio error: ${(err as Error).stack}`)
} finally {
const nextTime = randomAudioPeriod * (1 + Math.random())
randomActivateAudioTimeoutId && clearTimeout(randomActivateAudioTimeoutId)
randomActivateAudioTimeoutId = setTimeout(
randomActivateAudio,
nextTime * 1000,
sessions,
randomAudioPeriod,
randomAudioProbability,
randomAudioRange,
)
if (randomActivateAudioRunning) {
const nextTime = randomAudioPeriod * (1 + Math.random())
randomActivateAudioTimeoutId && clearTimeout(randomActivateAudioTimeoutId)
randomActivateAudioTimeoutId = setTimeout(
randomActivateAudio,
nextTime * 1000,
sessions,
randomAudioPeriod,
randomAudioProbability,
randomAudioRange,
)
}
}
}

Expand Down

0 comments on commit b54b8ec

Please sign in to comment.