Add service name to handler

This commit is contained in:
AnimeDL 2023-07-14 19:40:40 -07:00
parent b4d0c65cd2
commit f7ddaf1176
5 changed files with 6 additions and 2 deletions

View file

@ -21,7 +21,8 @@ export interface MessageHandler {
removeFromQueue: (index: number) => void,
clearQueue: () => void,
setDownloadQueue: (data: boolean) => void,
getDownloadQueue: () => Promise<boolean>
getDownloadQueue: () => Promise<boolean>,
name: string
}
export type FolderTypes = 'content' | 'config';

View file

@ -48,7 +48,7 @@ export default class ServiceHandler {
return respond({ isOk: false, reason: new Error('No service selected') });
respond(await this.service.auth(data));
});
this.ws.events.on('type', async (_, respond) => respond(this.service === undefined ? undefined : this.service instanceof FunimationHandler ? 'funi' : this.service instanceof CrunchyHandler ? 'crunchy' : 'hidive'));
this.ws.events.on('type', async (_, respond) => respond(this.service === undefined ? undefined : this.service.name as 'hidive'|'crunchy'|'funi'));
this.ws.events.on('checkToken', async (_, respond) => {
if (this.service === undefined)
return respond({ isOk: false, reason: new Error('No service selected') });

View file

@ -9,6 +9,7 @@ import * as yargs from '../../../modules/module.app-args';
class CrunchyHandler extends Base implements MessageHandler {
private crunchy: Crunchy;
public name = 'crunchy';
constructor(ws: WebSocketHandler) {
super(ws);
this.crunchy = new Crunchy();

View file

@ -9,6 +9,7 @@ import * as yargs from '../../../modules/module.app-args';
class FunimationHandler extends Base implements MessageHandler {
private funi: Funimation;
public name = 'funi';
constructor(ws: WebSocketHandler) {
super(ws);
this.funi = new Funimation();

View file

@ -9,6 +9,7 @@ import * as yargs from '../../../modules/module.app-args';
class HidiveHandler extends Base implements MessageHandler {
private hidive: Hidive;
public name = 'hidive';
constructor(ws: WebSocketHandler) {
super(ws);
this.hidive = new Hidive();