mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-19 20:11:59 +03:00
create folders in guild list
This commit is contained in:
@@ -12,15 +12,37 @@ void GuildList::UpdateListing() {
|
||||
Clear();
|
||||
|
||||
// does this function still even work ??lol
|
||||
const auto ids = discord.GetUserSortedGuilds();
|
||||
for (const auto id : ids) {
|
||||
AddGuild(id);
|
||||
const auto folders = discord.GetUserSettings().GuildFolders;
|
||||
const auto guild_ids = discord.GetUserSortedGuilds();
|
||||
|
||||
// same logic from ChannelListTree
|
||||
|
||||
std::set<Snowflake> foldered_guilds;
|
||||
for (const auto &group : folders) {
|
||||
foldered_guilds.insert(group.GuildIDs.begin(), group.GuildIDs.end());
|
||||
}
|
||||
|
||||
for (auto iter = guild_ids.crbegin(); iter != guild_ids.crend(); iter++) {
|
||||
if (foldered_guilds.find(*iter) == foldered_guilds.end()) {
|
||||
AddGuild(*iter);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &group : folders) {
|
||||
AddFolder(group);
|
||||
}
|
||||
}
|
||||
|
||||
void GuildList::AddGuild(Snowflake id) {
|
||||
if (auto item = CreateGuildWidget(id)) {
|
||||
item->show();
|
||||
add(*item);
|
||||
}
|
||||
}
|
||||
|
||||
GuildListGuildItem *GuildList::CreateGuildWidget(Snowflake id) {
|
||||
const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(id);
|
||||
if (!guild.has_value()) return;
|
||||
if (!guild.has_value()) return nullptr;
|
||||
|
||||
auto *item = Gtk::make_managed<GuildListGuildItem>(*guild);
|
||||
item->signal_button_press_event().connect([this, id](GdkEventButton *event) -> bool {
|
||||
@@ -29,8 +51,29 @@ void GuildList::AddGuild(Snowflake id) {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
item->show();
|
||||
add(*item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void GuildList::AddFolder(const UserSettingsGuildFoldersEntry &folder) {
|
||||
// groups with no ID arent actually folders
|
||||
if (!folder.ID.has_value()) {
|
||||
if (!folder.GuildIDs.empty()) {
|
||||
AddGuild(folder.GuildIDs[0]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
auto *folder_widget = Gtk::make_managed<GuildListFolderItem>();
|
||||
for (const auto guild_id : folder.GuildIDs) {
|
||||
if (auto *guild_widget = CreateGuildWidget(guild_id)) {
|
||||
guild_widget->show();
|
||||
folder_widget->AddGuildWidget(guild_widget);
|
||||
}
|
||||
}
|
||||
|
||||
folder_widget->show();
|
||||
add(*folder_widget);
|
||||
}
|
||||
|
||||
void GuildList::Clear() {
|
||||
|
||||
Reference in New Issue
Block a user