diff --git a/ChangeLog.md b/ChangeLog.md index 53c8d560..eee45a6f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,7 @@ # Changelog: +* **11.06.20** + - Fixed channel tree deletions + * **10.06.20** - Finalize the channel file explorer - Reworked the file transfer system diff --git a/shared/js/ui/channel.ts b/shared/js/ui/channel.ts index 34750da5..951420fc 100644 --- a/shared/js/ui/channel.ts +++ b/shared/js/ui/channel.ts @@ -488,9 +488,10 @@ export class ChannelEntry extends ChannelTreeEntry { name: tr("Delete channel"), invalidPermission: !flagDelete, callback: () => { + const client = this.channelTree.client; this.channelTree.client.serverConnection.send_command("channeldelete", {cid: this.channelId}).then(() => { - this.channelTree.client.sound.play(Sound.CHANNEL_DELETED); - }) + client.sound.play(Sound.CHANNEL_DELETED); + }); } }, contextmenu.Entry.HR(), diff --git a/shared/js/ui/tree/View.tsx b/shared/js/ui/tree/View.tsx index ead95b52..378b7d52 100644 --- a/shared/js/ui/tree/View.tsx +++ b/shared/js/ui/tree/View.tsx @@ -17,6 +17,8 @@ import {ClientEntry as ClientEntryView} from "./Client"; import {ChannelEntry, ChannelEvents} from "tc-shared/ui/channel"; import {ServerEntry} from "tc-shared/ui/server"; import {ClientEntry, ClientType} from "tc-shared/ui/client"; +import * as log from "tc-shared/log"; +import {LogCategory} from "tc-shared/log"; const viewStyle = require("./View.scss"); @@ -211,6 +213,7 @@ export class ChannelTreeView extends ReactComponentBase(); + this.events.enable_debug("channel-tree"); + this.client = client; this.view = React.createRef(); this.view_move = React.createRef(); @@ -305,15 +307,15 @@ export class ChannelTree { try { if(!this.channels.remove(channel)) log.warn(LogCategory.CHANNEL, tr("Deleting an unknown channel!")); - channel.children(false).forEach(e => this.deleteChannel(e)); + channel.children(false).forEach(e => this.deleteChannel(e)); if(channel.clients(false).length !== 0) { log.warn(LogCategory.CHANNEL, tr("Deleting a non empty channel! This could cause some errors.")); for(const client of channel.clients(false)) this.deleteClient(client, false); } - const is_root_tree = !!channel.parent; + const is_root_tree = !channel.parent; this.unregisterChannelFromTree(channel); if(is_root_tree) this.events.fire("notify_root_channel_changed"); } finally { @@ -345,14 +347,14 @@ export class ChannelTree { } private unregisterChannelFromTree(channel: ChannelEntry, new_parent?: ChannelEntry) { + let oldChannelParent; if(channel.parent) { if(channel.parent.child_channel_head === channel) channel.parent.child_channel_head = channel.channel_next; /* 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"); + oldChannelParent = channel.parent; } if(channel.channel_previous) @@ -370,6 +372,9 @@ export class ChannelTree { channel.channel_next = undefined; channel.channel_previous = undefined; channel.parent = undefined; + + if(oldChannelParent && oldChannelParent !== new_parent) + oldChannelParent.events.fire("notify_children_changed"); } moveChannel(channel: ChannelEntry, channel_previous: ChannelEntry, parent: ChannelEntry) {