Fixed some compile errors

This commit is contained in:
WolverinDEV 2020-07-20 19:23:44 +02:00
parent 04592e6813
commit 8ca9a8594f
4 changed files with 21 additions and 5 deletions

View file

@ -128,7 +128,7 @@ export class Registry<Events> implements EventReceiver<Events> {
(this.connections[null as any] || (this.connections[null as any] = [])).push(target as any);
}
connect<EOther, T extends keyof Events & keyof EOther>(events: T | T[], target: EventReceiver<Events>) {
connect<EOther, T extends (keyof Events & keyof EOther)>(events: T | T[], target: EventReceiver<EOther>) {
for(const event of Array.isArray(events) ? events : [events])
(this.connections[event as string] || (this.connections[event as string] = [])).push(target as any);
}
@ -138,10 +138,10 @@ export class Registry<Events> implements EventReceiver<Events> {
(this.connections[event as string] || []).remove(target as any);
}
disconnectAll<EOther>(target: EventReceiver<Events>) {
this.connections[null as any]?.remove(target);
disconnectAll<EOther>(target: EventReceiver<EOther>) {
this.connections[null as any]?.remove(target as any);
for(const event of Object.keys(this.connections))
this.connections[event].remove(target);
this.connections[event].remove(target as any);
}
fire<T extends keyof Events>(event_type: T, data?: Events[T], overrideTypeKey?: boolean) {

View file

@ -1,6 +1,7 @@
import * as log from "tc-shared/log";
import {LogCategory} from "tc-shared/log";
import {BasicIPCHandler, IPCChannel, ChannelMessage} from "tc-shared/ipc/BrowserIPC";
import {guid} from "tc-shared/crypto/uid";
export interface MethodProxyInvokeData {
method_name: string;
@ -96,7 +97,7 @@ export abstract class MethodProxy {
return Promise.reject("not connected");
const proxy_callback = {
promise_id: uuidv4()
promise_id: guid()
} as MethodProxyCallback;
this._proxied_callbacks[proxy_callback.promise_id] = proxy_callback;
proxy_callback.promise = new Promise((resolve, reject) => {

View file

@ -386,9 +386,16 @@ export class MusicInfo {
event.new.events.on("music_status_update", callback_time_update);
event.new.events.on("music_song_change", callback_song_change);
// @ts-ignore
event.new.events.connect("playlist_song_add", this.events);
// @ts-ignore
event.new.events.connect("playlist_song_remove", this.events);
// @ts-ignore
event.new.events.connect("playlist_song_reorder", this.events);
// @ts-ignore
event.new.events.connect("playlist_song_loaded", this.events);
}
});

View file

@ -239,6 +239,10 @@ export function spawnClientVolumeChange(client: ClientEntry) {
});
const modal = spawnReactModal(class extends Modal {
constructor() {
super();
}
renderBody() {
return <VolumeChangeModal remote={false} clientName={client.clientNickName()} events={events} />;
}
@ -274,6 +278,10 @@ export function spawnMusicBotVolumeChange(client: MusicClientEntry, maxValue: nu
});
const modal = spawnReactModal(class extends Modal {
constructor() {
super();
}
renderBody() {
return <VolumeChangeModal remote={true} clientName={client.clientNickName()} maxVolume={maxValue} events={events} />;
}