Rearranged handlers

This commit is contained in:
Geomitron
2020-05-21 14:17:20 -04:00
parent 7a13739ed0
commit 64701e4909
4 changed files with 12 additions and 12 deletions

View File

@@ -0,0 +1,32 @@
import { IPCInvokeHandler } from '../../shared/IPCHandler'
import { VersionResult } from '../../shared/interfaces/songDetails.interface'
import { serverURL } from '../../shared/Paths'
import * as needle from 'needle'
/**
* Handles the 'batch-song-details' event.
*/
class BatchSongDetailsHandler implements IPCInvokeHandler<'batch-song-details'> {
event: 'batch-song-details' = 'batch-song-details'
/**
* @returns an array of all the chart versions with a songID found in `songIDs`.
*/
async handler(songIDs: number[]) {
return new Promise<VersionResult[]>((resolve, reject) => {
needle.request(
'get',
serverURL + `/api/data/songsVersions`, {
songIDs: songIDs
}, (err, response) => {
if (err) {
reject(err)
} else {
resolve(response.body)
}
})
})
}
}
export const batchSongDetailsHandler = new BatchSongDetailsHandler()