summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-02-16 01:02:12 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2021-02-16 01:02:12 -0500
commit614c6ea59566441fdf91cc4329251b8b0a5561c0 (patch)
tree2ae86acab5e459793f4209f462a0bd29b736e44a
parentb1c7ac7120642799b887ffd41567c0a8fa819a48 (diff)
downloadabaddon-portaudio-614c6ea59566441fdf91cc4329251b8b0a5561c0.tar.gz
abaddon-portaudio-614c6ea59566441fdf91cc4329251b8b0a5561c0.zip
improve message handling with DMs a little
-rw-r--r--components/channels.cpp14
-rw-r--r--components/channels.hpp1
2 files changed, 6 insertions, 9 deletions
diff --git a/components/channels.cpp b/components/channels.cpp
index 70b2a3a..ee53046 100644
--- a/components/channels.cpp
+++ b/components/channels.cpp
@@ -327,10 +327,7 @@ void ChannelList::UpdateRemoveGuild(Snowflake id) {
void ChannelList::UpdateRemoveChannel(Snowflake id) {
auto it = m_id_to_row.find(id);
- if (it == m_id_to_row.end()) {
- it = m_dm_id_to_row.find(id);
- if (it == m_dm_id_to_row.end()) return;
- }
+ if (it == m_id_to_row.end()) return;
auto row = dynamic_cast<ChannelListRow *>(it->second);
if (row == nullptr) return;
DeleteRow(row);
@@ -447,6 +444,7 @@ void ChannelList::UpdateCreateDMChannel(Snowflake id) {
dm_row->IsUserCollapsed = false;
m_list->insert(*dm_row, m_dm_header_row->get_index() + 1);
m_dm_header_row->Children.insert(dm_row);
+ m_id_to_row[id] = dm_row;
if (!m_dm_header_row->IsUserCollapsed)
dm_row->show();
}
@@ -678,7 +676,7 @@ void ChannelList::AddPrivateChannels() {
for (const auto &dm : dms) {
auto *dm_row = Gtk::manage(new ChannelListRowDMChannel(&dm));
dm_row->Parent = m_dm_header_row;
- m_dm_id_to_row[dm.ID] = dm_row;
+ m_id_to_row[dm.ID] = dm_row;
dm_row->IsUserCollapsed = false;
m_list->add(*dm_row);
m_dm_header_row->Children.insert(dm_row);
@@ -721,8 +719,8 @@ void ChannelList::OnGuildMenuSettings(Snowflake id) {
}
void ChannelList::CheckBumpDM(Snowflake channel_id) {
- auto it = m_dm_id_to_row.find(channel_id);
- if (it == m_dm_id_to_row.end()) return;
+ auto it = m_id_to_row.find(channel_id);
+ if (it == m_id_to_row.end()) return;
auto *row = it->second;
const auto index = row->get_index();
if (index == 1) return; // 1 is top of dm list
@@ -733,7 +731,7 @@ void ChannelList::CheckBumpDM(Snowflake channel_id) {
auto *dm_row = Gtk::manage(new ChannelListRowDMChannel(&*chan));
dm_row->Parent = m_dm_header_row;
m_dm_header_row->Children.insert(dm_row);
- m_dm_id_to_row[channel_id] = dm_row;
+ m_id_to_row[channel_id] = dm_row;
dm_row->IsUserCollapsed = false;
m_list->insert(*dm_row, 1);
m_dm_header_row->Children.insert(dm_row);
diff --git a/components/channels.hpp b/components/channels.hpp
index d7fda18..31c494c 100644
--- a/components/channels.hpp
+++ b/components/channels.hpp
@@ -164,7 +164,6 @@ protected:
// i would use one map but in really old guilds there can be a channel w/ same id as the guild so this hacky shit has to do
std::unordered_map<Snowflake, ChannelListRow *> m_guild_id_to_row;
std::unordered_map<Snowflake, ChannelListRow *> m_id_to_row;
- std::unordered_map<Snowflake, ChannelListRow *> m_dm_id_to_row;
void InsertGuildAt(Snowflake id, int pos);