mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Rearranged handlers
This commit is contained in:
32
src/electron/ipc/browse/BatchSongDetailsHandler.ipc.ts
Normal file
32
src/electron/ipc/browse/BatchSongDetailsHandler.ipc.ts
Normal 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()
|
||||
Reference in New Issue
Block a user