Edit tasks

This commit is contained in:
2022-01-15 22:08:53 +01:00
parent c7e3a74e7c
commit eaa03fbbd9
2 changed files with 8 additions and 10 deletions

View File

@@ -1,13 +1,18 @@
import Logger from '@ioc:Adonis/Core/Logger'
import { getCurrentPlayingFromSpotify } from 'App/Utils/SongUtils'
import { getCurrentPlayingFromSpotify, getSpotifyAccount } from 'App/Utils/SongUtils'
const MS = 1000
let taskId
async function SpotifyCurrentListeningWatcher(): Promise<void> {
if (getSpotifyAccount().access === '') return
await getCurrentPlayingFromSpotify()
}
export async function Activate(): Promise<void> {
Logger.info(`Starting task runner for watching spotify current playing [${MS} ms]`)
await getCurrentPlayingFromSpotify()
taskId = setInterval(getCurrentPlayingFromSpotify, MS)
await SpotifyCurrentListeningWatcher()
taskId = setInterval(SpotifyCurrentListeningWatcher, MS)
}
export function ShutDown(): void {