Fixed some small stuff

canary
WolverinDEV 2020-04-18 20:25:58 +02:00
parent c0d17e8348
commit df8136acb1
6 changed files with 18 additions and 12 deletions

View File

@ -31,7 +31,7 @@ export class Registry<Events> {
handlers: {[key: string]: ((event) => void)[]} handlers: {[key: string]: ((event) => void)[]}
}[] = []; }[] = [];
private debug_prefix = undefined; private debug_prefix = undefined;
private warn_unhandled_events = true; private warn_unhandled_events = false;
constructor() { constructor() {
this.registry_uuid = "evreg_data_" + guid(); this.registry_uuid = "evreg_data_" + guid();
@ -139,7 +139,7 @@ export class Registry<Events> {
evhandler.fire_event(type, data); evhandler.fire_event(type, data);
invoke_count++; invoke_count++;
} }
if(invoke_count === 0) { if(this.warn_unhandled_events && invoke_count === 0) {
console.warn(tr("Event handler (%s) triggered event %s which has no consumers."), this.debug_prefix, type); console.warn(tr("Event handler (%s) triggered event %s which has no consumers."), this.debug_prefix, type);
} }
} }

View File

@ -441,7 +441,7 @@ export class ChannelEntry extends ChannelTreeEntry<ChannelEvents> {
name: tr("Edit channel"), name: tr("Edit channel"),
invalidPermission: !channelModify, invalidPermission: !channelModify,
callback: () => { callback: () => {
createChannelModal(this.channelTree.client, this, undefined, this.channelTree.client.permissions, (changes?, permissions?) => { createChannelModal(this.channelTree.client, this, this.parent, this.channelTree.client.permissions, (changes?, permissions?) => {
if(changes) { if(changes) {
changes["cid"] = this.channelId; changes["cid"] = this.channelId;
this.channelTree.client.serverConnection.send_command("channeledit", changes); this.channelTree.client.serverConnection.send_command("channeledit", changes);

View File

@ -358,11 +358,15 @@ export class ChannelTree {
return undefined; return undefined;
} }
private unregisterChannelFromTree(channel: ChannelEntry) { private unregisterChannelFromTree(channel: ChannelEntry, new_parent?: ChannelEntry) {
if(channel.parent) { if(channel.parent) {
if(channel.parent.child_channel_head === channel) if(channel.parent.child_channel_head === channel)
channel.parent.child_channel_head = channel.channel_next; channel.parent.child_channel_head = channel.channel_next;
channel.parent.events.fire("notify_children_changed");
/* We need only trigger this once.
If the new parent is equal to the old one with applying the "new" parent this event will get triggered */
if(new_parent !== channel.parent)
channel.parent.events.fire("notify_children_changed");
} }
if(channel.channel_previous) if(channel.channel_previous)
@ -389,7 +393,7 @@ export class ChannelTree {
} }
let root_tree_updated = !channel.parent; let root_tree_updated = !channel.parent;
this.unregisterChannelFromTree(channel); this.unregisterChannelFromTree(channel, parent);
channel.channel_previous = channel_previous; channel.channel_previous = channel_previous;
channel.channel_next = undefined; channel.channel_next = undefined;
channel.parent = parent; channel.parent = parent;
@ -415,8 +419,6 @@ export class ChannelTree {
if(children.length === 0) { //Self should be already in there if(children.length === 0) { //Self should be already in there
channel.channel_next = undefined; channel.channel_next = undefined;
} else { } else {
channel.channel_previous = undefined;
channel.channel_next = children[0]; channel.channel_next = children[0];
channel.channel_next.channel_previous = channel; channel.channel_next.channel_previous = channel;
} }

View File

@ -345,9 +345,11 @@ export class ServerConnection extends AbstractServerConnection {
return; return;
} }
if(json["type"] === "command") { if(json["type"] === "command") {
/* devel-block(log-networking-commands) */
let group = log.group(log.LogType.DEBUG, LogCategory.NETWORKING, tr("Handling command '%s'"), json["command"]); let group = log.group(log.LogType.DEBUG, LogCategory.NETWORKING, tr("Handling command '%s'"), json["command"]);
group.log(tr("Handling command '%s'"), json["command"]); group.log(tr("Handling command '%s'"), json["command"]);
group.group(log.LogType.TRACE, tr("Json:")).collapsed(true).log("%o", json).end(); group.group(log.LogType.TRACE, tr("Json:")).collapsed(true).log("%o", json).end();
/* devel-block-end */
this._command_boss.invoke_handle({ this._command_boss.invoke_handle({
command: json["command"], command: json["command"],
@ -361,7 +363,9 @@ export class ServerConnection extends AbstractServerConnection {
if(this._voice_connection) if(this._voice_connection)
this._voice_connection.start_rtc_session(); /* FIXME: Move it to a handler boss and not here! */ this._voice_connection.start_rtc_session(); /* FIXME: Move it to a handler boss and not here! */
} }
/* devel-block(log-networking-commands) */
group.end(); group.end();
/* devel-block-end */
} else if(json["type"] === "WebRTC") { } else if(json["type"] === "WebRTC") {
if(this._voice_connection) if(this._voice_connection)
this._voice_connection.handleControlPacket(json); this._voice_connection.handleControlPacket(json);

View File

@ -77,10 +77,7 @@ export namespace codec {
this.entries[index].instance.initialise().then((flag) => { this.entries[index].instance.initialise().then((flag) => {
//TODO test success flag //TODO test success flag
this.ownCodec(clientId, callback_encoded, false).then(resolve).catch(reject); this.ownCodec(clientId, callback_encoded, false).then(resolve).catch(reject);
}).catch(error => { }).catch(reject);
log.error(LogCategory.VOICE, tr("Could not initialize codec!\nError: %o"), error);
reject(typeof(error) === 'string' ? error : tr("Could not initialize codec!"));
});
} }
return; return;
} else if(this.entries[index].owner == 0) { } else if(this.entries[index].owner == 0) {

View File

@ -18,6 +18,9 @@ export default function loader(this: LoaderContext, source: string | Buffer, sou
const pattern = new RegExp("[\\t ]*\\/\\* ?" + start_regex + " ?\\*\\/[\\s\\S]*?\\/\\* ?" + end_regex + " ?\\*\\/[\\t ]*\\n?", "g"); const pattern = new RegExp("[\\t ]*\\/\\* ?" + start_regex + " ?\\*\\/[\\s\\S]*?\\/\\* ?" + end_regex + " ?\\*\\/[\\t ]*\\n?", "g");
source = (source as string).replace(pattern, (value, type) => { source = (source as string).replace(pattern, (value, type) => {
if(type === "log-networking-commands")
return value;
return "/* snipped block \"" + type + "\" */"; return "/* snipped block \"" + type + "\" */";
}); });
this.callback(null, source); this.callback(null, source);