summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/channels.cpp5
-rw-r--r--discord/discord.cpp1
-rw-r--r--discord/guild.cpp5
3 files changed, 5 insertions, 6 deletions
diff --git a/components/channels.cpp b/components/channels.cpp
index fc82795..e9b85f9 100644
--- a/components/channels.cpp
+++ b/components/channels.cpp
@@ -433,12 +433,11 @@ void ChannelList::UpdateChannel(Snowflake id) {
auto *new_row = Gtk::manage(new ChannelListRowChannel(&*data));
new_row->IsUserCollapsed = old_collapsed;
m_id_to_row[id] = new_row;
- if (data->ParentID->IsValid()) {
+ if (data->ParentID.has_value()) {
new_row->Parent = m_id_to_row.at(*data->ParentID);
} else {
new_row->Parent = m_guild_id_to_row.at(*data->GuildID);
}
-
new_row->Parent->Children.insert(new_row);
if (new_row->Parent->is_visible() && !new_row->Parent->IsUserCollapsed)
new_row->show();
@@ -599,7 +598,7 @@ void ChannelList::InsertGuildAt(Snowflake id, int pos) {
if (!channel.has_value()) continue;
if (channel->Type != ChannelType::GUILD_TEXT && channel->Type != ChannelType::GUILD_NEWS) continue;
- if (channel->ParentID->IsValid())
+ if (channel->ParentID.has_value())
cat_to_channels[*channel->ParentID].push_back(*channel);
else
orphan_channels[*channel->Position] = *channel;
diff --git a/discord/discord.cpp b/discord/discord.cpp
index 72dba79..e5c739e 100644
--- a/discord/discord.cpp
+++ b/discord/discord.cpp
@@ -751,6 +751,7 @@ void DiscordClient::HandleGatewayGuildUpdate(const GatewayMessage &msg) {
auto current = m_store.GetGuild(id);
if (!current.has_value()) return;
current->update_from_json(msg.Data);
+ m_store.SetGuild(id, *current);
m_signal_guild_update.emit(id);
}
diff --git a/discord/guild.cpp b/discord/guild.cpp
index 6b26f25..40762ad 100644
--- a/discord/guild.cpp
+++ b/discord/guild.cpp
@@ -141,10 +141,9 @@ std::vector<Snowflake> GuildData::GetSortedChannels(Snowflake ignore) const {
std::map<int, std::vector<ChannelData>> orphan_channels;
for (const auto &channel_id : channels) {
const auto data = discord.GetChannel(channel_id);
- if (!data.has_value()) continue;
- if (!data->ParentID->IsValid() && (data->Type == ChannelType::GUILD_TEXT || data->Type == ChannelType::GUILD_NEWS))
+ if (!data->ParentID.has_value() && (data->Type == ChannelType::GUILD_TEXT || data->Type == ChannelType::GUILD_NEWS))
orphan_channels[*data->Position].push_back(*data);
- else if (data->ParentID->IsValid() && (data->Type == ChannelType::GUILD_TEXT || data->Type == ChannelType::GUILD_NEWS))
+ else if (data->ParentID.has_value() && (data->Type == ChannelType::GUILD_TEXT || data->Type == ChannelType::GUILD_NEWS))
category_to_channels[*data->ParentID].push_back(*data);
else if (data->Type == ChannelType::GUILD_CATEGORY)
position_to_categories[*data->Position].push_back(*data);