Added broadcast for alreadyInQueue and loginNeededToDownload errors
This commit is contained in:
parent
a82c4c303e
commit
cc82ee6376
@ -17,7 +17,7 @@ export const sessionDZ: any = {}
|
|||||||
const deemixPlugins = {}
|
const deemixPlugins = {}
|
||||||
|
|
||||||
export const listener = {
|
export const listener = {
|
||||||
send(key: string, data: any) {
|
send(key: string, data?: any) {
|
||||||
console.log(key, data)
|
console.log(key, data)
|
||||||
wss.clients.forEach(client => {
|
wss.clients.forEach(client => {
|
||||||
if (client.readyState === WebSocket.OPEN) {
|
if (client.readyState === WebSocket.OPEN) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
import { ApiHandler } from '../../../types'
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ, addToQueue, settings } from '../../../main'
|
import { sessionDZ, addToQueue, settings, listener } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/addToQueue'
|
const path: ApiHandler['path'] = '/addToQueue'
|
||||||
|
|
||||||
@ -19,13 +19,16 @@ const handler: ApiHandler['handler'] = async (req, res) => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
switch (e.name) {
|
switch (e.name) {
|
||||||
case 'AlreadyInQueue':
|
case 'AlreadyInQueue':
|
||||||
res.send({ result: false, errid: e.name, data: { url, bitrate, obj: e.data } })
|
res.send({ result: false, errid: e.name, data: { url, bitrate, obj: e.item } })
|
||||||
|
listener.send('alreadyInQueue', e.item)
|
||||||
break
|
break
|
||||||
case 'NotLoggedIn':
|
case 'NotLoggedIn':
|
||||||
res.send({ result: false, errid: e.name, data: { url, bitrate } })
|
res.send({ result: false, errid: e.name, data: { url, bitrate } })
|
||||||
|
listener.send('loginNeededToDownload')
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
res.send({ result: false, errid: e.name, data: { url, bitrate } })
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user