Fix Windows channel tree ordering
Build and test / test (macos-latest) (push) Canceled after 0s
Build and test / test (ubuntu-24.04) (push) Canceled after 0s
Build and test / test (windows-latest) (push) Canceled after 0s
Build and test / apple-client (push) Canceled after 0s

This commit is contained in:
2026-09-21 19:47:14 +02:00
parent 4aa0aa4fbd
commit 8471eac363
7 changed files with 66 additions and 16 deletions
@@ -150,8 +150,8 @@ public sealed class ChannelEditDialog : Form
{
Location = new Point(inputX, y - 2),
Size = new Size(120, 23),
Minimum = 0,
Maximum = uint.MaxValue,
Minimum = int.MinValue,
Maximum = int.MaxValue,
Value = existing?.SortOrder ?? 0,
TabIndex = 5,
};
@@ -385,7 +385,7 @@ public sealed class ChannelEditDialog : Form
PasswordProtected: _chkPassword.Checked,
Password: _chkPassword.Checked ? _txtPassword.Text : null,
MaxUsers: (uint)_numMaxUsers.Value,
SortOrder: (uint)_numSortOrder.Value,
SortOrder: (int)_numSortOrder.Value,
Audio: audio);
}
@@ -575,25 +575,21 @@ public partial class MainForm : Form
tvChannels.BeginUpdate();
tvChannels.Nodes.Clear();
var byParent = _channels
.GroupBy(c => c.ParentId)
.ToDictionary(g => g.Key, g => g.ToList());
void AddChildren(TreeNodeCollection nodes, uint parentId)
void AddChildren(TreeNodeCollection nodes, IReadOnlyList<ChannelHierarchyItem> children)
{
if (!byParent.TryGetValue(parentId, out var kids)) return;
foreach (var ch in kids.OrderBy(c => c.Name))
foreach (ChannelHierarchyItem item in children)
{
ChannelInfo ch = item.Channel;
int count = _users.Values.Count(u => u.ChannelId == ch.Id);
var label = $"{ch.Name} ({count})";
if (ch.PasswordProtected) label += " [password]";
if (ch.Id == _currentChannelId) label += " ►";
var node = new TreeNode(label) { Tag = ch.Id };
nodes.Add(node);
AddChildren(node.Nodes, ch.Id);
AddChildren(node.Nodes, item.Children);
}
}
AddChildren(tvChannels.Nodes, 0);
AddChildren(tvChannels.Nodes, ChannelHierarchy.Build(_channels));
tvChannels.ExpandAll();
SeekAndSelect(tvChannels.Nodes, toSelect);
tvChannels.EndUpdate();