From f0ca473f6a945a34fdcae76148145ac432e78c98 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 14 Sep 2020 03:26:46 -0400 Subject: fix categories of same positions not being shown --- components/channels.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'components/channels.cpp') diff --git a/components/channels.cpp b/components/channels.cpp index 013b950..bbb07c4 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -301,19 +301,21 @@ void ChannelList::SetListingFromGuildsInternal() { } } - std::map sorted_categories; + std::map> sorted_categories; for (const auto &channel : guild.Channels) { if (channel.Type == ChannelType::GUILD_CATEGORY) { - assert(channel.Position != -1); - sorted_categories[channel.Position] = &channel; + sorted_categories[channel.Position].push_back(&channel); } } - for (const auto &[pos, channel] : sorted_categories) { - if (channel->Type == ChannelType::GUILD_CATEGORY) { - auto category_row = add_category(channel->ID, *channel); - info.Children.insert(category_row); + for (auto &[pos, channelvec] : sorted_categories) { + std::sort(channelvec.begin(), channelvec.end(), [](const Channel *a, const Channel *b) { return a->ID < b->ID; }); + for (const auto channel : channelvec) { + if (channel->Type == ChannelType::GUILD_CATEGORY) { + auto category_row = add_category(channel->ID, *channel); + info.Children.insert(category_row); + } } } -- cgit v1.2.3