Fixed bug that on channel tree deletion the channel tree gets not updated
This commit is contained in:
parent
9b77978f8e
commit
f0ca5ff83f
4 changed files with 18 additions and 6 deletions
|
@ -1,4 +1,7 @@
|
||||||
# Changelog:
|
# Changelog:
|
||||||
|
* **11.06.20**
|
||||||
|
- Fixed channel tree deletions
|
||||||
|
|
||||||
* **10.06.20**
|
* **10.06.20**
|
||||||
- Finalize the channel file explorer
|
- Finalize the channel file explorer
|
||||||
- Reworked the file transfer system
|
- Reworked the file transfer system
|
||||||
|
|
|
@ -488,9 +488,10 @@ export class ChannelEntry extends ChannelTreeEntry<ChannelEvents> {
|
||||||
name: tr("Delete channel"),
|
name: tr("Delete channel"),
|
||||||
invalidPermission: !flagDelete,
|
invalidPermission: !flagDelete,
|
||||||
callback: () => {
|
callback: () => {
|
||||||
|
const client = this.channelTree.client;
|
||||||
this.channelTree.client.serverConnection.send_command("channeldelete", {cid: this.channelId}).then(() => {
|
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(),
|
contextmenu.Entry.HR(),
|
||||||
|
|
|
@ -17,6 +17,8 @@ import {ClientEntry as ClientEntryView} from "./Client";
|
||||||
import {ChannelEntry, ChannelEvents} from "tc-shared/ui/channel";
|
import {ChannelEntry, ChannelEvents} from "tc-shared/ui/channel";
|
||||||
import {ServerEntry} from "tc-shared/ui/server";
|
import {ServerEntry} from "tc-shared/ui/server";
|
||||||
import {ClientEntry, ClientType} from "tc-shared/ui/client";
|
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");
|
const viewStyle = require("./View.scss");
|
||||||
|
|
||||||
|
@ -211,6 +213,7 @@ export class ChannelTreeView extends ReactComponentBase<ChannelTreeViewPropertie
|
||||||
}
|
}
|
||||||
|
|
||||||
private rebuild_tree() {
|
private rebuild_tree() {
|
||||||
|
log.debug(LogCategory.CHANNEL, tr("Rebuilding the channel tree"));
|
||||||
const tree = this.props.tree;
|
const tree = this.props.tree;
|
||||||
{
|
{
|
||||||
let index = this.flat_tree.length;
|
let index = this.flat_tree.length;
|
||||||
|
|
|
@ -208,6 +208,8 @@ export class ChannelTree {
|
||||||
|
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
this.events = new Registry<ChannelTreeEvents>();
|
this.events = new Registry<ChannelTreeEvents>();
|
||||||
|
this.events.enable_debug("channel-tree");
|
||||||
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.view = React.createRef();
|
this.view = React.createRef();
|
||||||
this.view_move = React.createRef();
|
this.view_move = React.createRef();
|
||||||
|
@ -305,15 +307,15 @@ export class ChannelTree {
|
||||||
try {
|
try {
|
||||||
if(!this.channels.remove(channel))
|
if(!this.channels.remove(channel))
|
||||||
log.warn(LogCategory.CHANNEL, tr("Deleting an unknown 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) {
|
if(channel.clients(false).length !== 0) {
|
||||||
log.warn(LogCategory.CHANNEL, tr("Deleting a non empty channel! This could cause some errors."));
|
log.warn(LogCategory.CHANNEL, tr("Deleting a non empty channel! This could cause some errors."));
|
||||||
for(const client of channel.clients(false))
|
for(const client of channel.clients(false))
|
||||||
this.deleteClient(client, false);
|
this.deleteClient(client, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const is_root_tree = !!channel.parent;
|
const is_root_tree = !channel.parent;
|
||||||
this.unregisterChannelFromTree(channel);
|
this.unregisterChannelFromTree(channel);
|
||||||
if(is_root_tree) this.events.fire("notify_root_channel_changed");
|
if(is_root_tree) this.events.fire("notify_root_channel_changed");
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -345,14 +347,14 @@ export class ChannelTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
private unregisterChannelFromTree(channel: ChannelEntry, new_parent?: ChannelEntry) {
|
private unregisterChannelFromTree(channel: ChannelEntry, new_parent?: ChannelEntry) {
|
||||||
|
let oldChannelParent;
|
||||||
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;
|
||||||
|
|
||||||
/* We need only trigger this once.
|
/* 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 the new parent is equal to the old one with applying the "new" parent this event will get triggered */
|
||||||
if(new_parent !== channel.parent)
|
oldChannelParent = channel.parent;
|
||||||
channel.parent.events.fire("notify_children_changed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(channel.channel_previous)
|
if(channel.channel_previous)
|
||||||
|
@ -370,6 +372,9 @@ export class ChannelTree {
|
||||||
channel.channel_next = undefined;
|
channel.channel_next = undefined;
|
||||||
channel.channel_previous = undefined;
|
channel.channel_previous = undefined;
|
||||||
channel.parent = undefined;
|
channel.parent = undefined;
|
||||||
|
|
||||||
|
if(oldChannelParent && oldChannelParent !== new_parent)
|
||||||
|
oldChannelParent.events.fire("notify_children_changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
moveChannel(channel: ChannelEntry, channel_previous: ChannelEntry, parent: ChannelEntry) {
|
moveChannel(channel: ChannelEntry, channel_previous: ChannelEntry, parent: ChannelEntry) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue