summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-09-14 03:26:46 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-09-14 03:26:46 -0400
commitf0ca473f6a945a34fdcae76148145ac432e78c98 (patch)
tree083f92ef8158f0c3f1faae668317d52438e26ce2
parente5a90b94618bafc6bc99afbbff37f7aa3d6a97cf (diff)
downloadabaddon-portaudio-f0ca473f6a945a34fdcae76148145ac432e78c98.tar.gz
abaddon-portaudio-f0ca473f6a945a34fdcae76148145ac432e78c98.zip
fix categories of same positions not being shown
-rw-r--r--components/channels.cpp16
1 files changed, 9 insertions, 7 deletions
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<int, const Channel *> sorted_categories;
+ std::map<int, std::vector<const Channel *>> 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);
+ }
}
}