diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-08-05 03:32:53 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-08-05 03:32:53 -0400 |
commit | 41a63df1b108a9520a8dfcb862f108b42f9a1bb1 (patch) | |
tree | b9eae63b43a9dd418fe7d7b3b7c8562fd92ec7ab /components | |
parent | 40897ece3ced8bfc051708a8d85f413f330631a9 (diff) | |
download | abaddon-portaudio-41a63df1b108a9520a8dfcb862f108b42f9a1bb1.tar.gz abaddon-portaudio-41a63df1b108a9520a8dfcb862f108b42f9a1bb1.zip |
add temporary row for non-joined threads
Diffstat (limited to 'components')
-rw-r--r-- | components/channels.cpp | 21 | ||||
-rw-r--r-- | components/channels.hpp | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/components/channels.cpp b/components/channels.cpp index f12d56a..b96b2e6 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -292,6 +292,7 @@ void ChannelList::OnThreadMembersUpdate(const ThreadMembersUpdateData &data) { } void ChannelList::UpdateCreateThread(const ChannelData &channel) { + if (GetIteratorForChannelFromID(channel.ID)) return; // dont do anything if already exists auto parent_row = GetIteratorForChannelFromID(*channel.ParentID); if (parent_row) CreateThreadRow(parent_row->children(), channel); @@ -303,13 +304,31 @@ void ChannelList::UpdateDeleteThread(Snowflake id) { m_model->erase(iter); } +// create a temporary channel row for non-joined threads +// and delete them when the active channel switches off of them if still not joined void ChannelList::SetActiveChannel(Snowflake id) { + if (m_temporary_thread_row) { + const auto thread_id = static_cast<Snowflake>((*m_temporary_thread_row)[m_columns.m_id]); + const auto thread = Abaddon::Get().GetDiscordClient().GetChannel(thread_id); + if (thread.has_value() && !thread->IsJoinedThread()) + m_model->erase(m_temporary_thread_row); + m_temporary_thread_row = {}; + } + const auto channel_iter = GetIteratorForChannelFromID(id); if (channel_iter) { m_view.expand_to_path(m_model->get_path(channel_iter)); m_view.get_selection()->select(channel_iter); - } else + } else { m_view.get_selection()->unselect_all(); + // SetActiveChannel should probably just take the channel object + const auto channel = Abaddon::Get().GetDiscordClient().GetChannel(id); + if (!channel.has_value() || !channel->IsThread()) return; + auto parent_iter = GetIteratorForChannelFromID(*channel->ParentID); + if (!parent_iter) return; + m_temporary_thread_row = CreateThreadRow(parent_iter->children(), *channel); + m_view.get_selection()->select(m_temporary_thread_row); + } } Gtk::TreeModel::iterator ChannelList::AddGuild(const GuildData &guild) { diff --git a/components/channels.hpp b/components/channels.hpp index 24c7170..fce3546 100644 --- a/components/channels.hpp +++ b/components/channels.hpp @@ -197,6 +197,9 @@ protected: void OnMessageCreate(const Message &msg); Gtk::TreeModel::Path m_path_for_menu; + // cant be recovered through selection + Gtk::TreeModel::iterator m_temporary_thread_row; + Gtk::Menu m_menu_guild; Gtk::MenuItem m_menu_guild_copy_id; Gtk::MenuItem m_menu_guild_settings; |